diff --git a/pybricks/_common.py b/pybricks/_common.py index f769682..e01380f 100644 --- a/pybricks/_common.py +++ b/pybricks/_common.py @@ -404,6 +404,25 @@ class Light: """Turns off the light.""" pass + def pattern(self, pattern, duration, repeat=True): + """Make the light brightness follow a pattern as a function of time. + + The specified pattern function will be sampled at 64 points between 0 + and the specified duration. The light will be held at a constant + brightness between samples. + + This function is not blocking. The pattern will be shown as the + user program continues. + + Arguments: + pattern (callable): Function of the + form ``b = func(t)``` that returns the brightness ``b`` + of the (0--100.0) as a function of time ``t`` in milliseconds. + time (:ref:`time`): Duration of the pattern. + repeat (bool): Whether to keep repeating the pattern after it + completes. + """ + class ColorLight: """Control a multi-color light."""