diff --git a/gpiozero/boards.py b/gpiozero/boards.py index e2a9ea0..55a0e3a 100644 --- a/gpiozero/boards.py +++ b/gpiozero/boards.py @@ -179,6 +179,30 @@ class LEDBoard(LEDCollection): self._blink_thread.stop() self._blink_thread = None + def pulse(self, fade_in_time=1, fade_out_time=1, n=None, background=True): + """ + Make the device fade in and out repeatedly. + + :param float fade_in_time: + Number of seconds to spend fading in. Defaults to 1. + + :param float fade_out_time: + Number of seconds to spend fading out. Defaults to 1. + + :param int n: + Number of times to blink; ``None`` (the default) means forever. + + :param bool background: + If ``True`` (the default), start a background thread to continue + blinking and return immediately. If ``False``, only return when the + blink is finished (warning: the default value of *n* will result in + this method never returning). + """ + on_time = off_time = 0 + self.blink( + on_time, off_time, fade_in_time, fade_out_time, n, background + ) + def _blink_device(self, on_time, off_time, fade_in_time, fade_out_time, n, fps=50): sequence = [] if fade_in_time > 0: diff --git a/gpiozero/output_devices.py b/gpiozero/output_devices.py index 46b355a..3c4a66e 100644 --- a/gpiozero/output_devices.py +++ b/gpiozero/output_devices.py @@ -414,7 +414,9 @@ class PWMOutputDevice(OutputDevice): this method never returning). """ on_time = off_time = 0 - self.blink(on_time, off_time, fade_in_time, fade_out_time, n, background) + self.blink( + on_time, off_time, fade_in_time, fade_out_time, n, background + ) def _stop_blink(self): if self._blink_thread: