From 0b66cc1c113d8cef0ad4218cb41de5848c38251d Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 20 Dec 2024 17:56:28 -0600 Subject: [PATCH] add period property to pulse and sparklepulse, fix typo --- adafruit_led_animation/animation/pulse.py | 14 +++++++++++++- .../animation/sparklepulse.py | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/adafruit_led_animation/animation/pulse.py b/adafruit_led_animation/animation/pulse.py index 7038ce2..ec1373d 100644 --- a/adafruit_led_animation/animation/pulse.py +++ b/adafruit_led_animation/animation/pulse.py @@ -39,7 +39,7 @@ class Pulse(Animation): :param period: Period to pulse the LEDs over. Default 5. :param breath: Duration to hold minimum and maximum intensity levels. Default 0. :param min_intensity: Lowest brightness level of the pulse. Default 0. - :param max_intensity: Highest brightness elvel of the pulse. Default 1. + :param max_intensity: Highest brightness level of the pulse. Default 1. """ # pylint: disable=too-many-arguments @@ -80,3 +80,15 @@ def reset(self): ) self._generator = pulse_generator(self._period, self, dotstar_pwm=dotstar) + + @property + def period(self): + """ + Period to pulse the LEDs over in seconds + """ + return self._period + + @period.setter + def period(self, new_value): + self._period = new_value + self.reset() diff --git a/adafruit_led_animation/animation/sparklepulse.py b/adafruit_led_animation/animation/sparklepulse.py index b85f644..00133a7 100644 --- a/adafruit_led_animation/animation/sparklepulse.py +++ b/adafruit_led_animation/animation/sparklepulse.py @@ -74,3 +74,21 @@ def draw(self): def after_draw(self): self.show() + + @property + def period(self): + """ + Period to pulse the LEDs over in seconds + """ + return self._period + + @period.setter + def period(self, new_value): + self._period = new_value + self.reset() + + def reset(self): + dotstar = len(self.pixel_object) == 4 and isinstance( + self.pixel_object[0][-1], float + ) + self._generator = pulse_generator(self._period, self, dotstar_pwm=dotstar)