From f16e51999154f72075a788a392b91ad4b2ce68be Mon Sep 17 00:00:00 2001 From: Tyler Winfield Date: Tue, 19 Dec 2023 23:04:12 -0600 Subject: [PATCH] Corrected variable scoping --- adafruit_led_animation/animation/pulse.py | 6 +++--- adafruit_led_animation/animation/sparklepulse.py | 6 +++--- adafruit_led_animation/helper.py | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/adafruit_led_animation/animation/pulse.py b/adafruit_led_animation/animation/pulse.py index 849b457..b5ff3d7 100644 --- a/adafruit_led_animation/animation/pulse.py +++ b/adafruit_led_animation/animation/pulse.py @@ -46,9 +46,9 @@ class Pulse(Animation): def __init__(self, pixel_object, speed, color, period=5, breath=0, min_intensity=0, max_intensity=1, name=None): super().__init__(pixel_object, speed, color, name=name) self._period = period - self._breath = breath - self._min_intensity = min_intensity - self._max_intensity = max_intensity + self.breath = breath + self.min_intensity = min_intensity + self.max_intensity = max_intensity self._generator = None self.reset() diff --git a/adafruit_led_animation/animation/sparklepulse.py b/adafruit_led_animation/animation/sparklepulse.py index 2132005..0976f9e 100644 --- a/adafruit_led_animation/animation/sparklepulse.py +++ b/adafruit_led_animation/animation/sparklepulse.py @@ -55,10 +55,10 @@ class SparklePulse(Sparkle): min_intensity=0, name=None, ): - self._max_intensity = max_intensity - self._min_intensity = min_intensity self._period = period - self._breath = breath + self.breath = breath + self.min_intensity = min_intensity + self.max_intensity = max_intensity dotstar = len(pixel_object) == 4 and isinstance(pixel_object[0][-1], float) super().__init__( pixel_object, speed=speed, color=color, num_sparkles=1, name=name diff --git a/adafruit_led_animation/helper.py b/adafruit_led_animation/helper.py index 822a74c..466ef63 100644 --- a/adafruit_led_animation/helper.py +++ b/adafruit_led_animation/helper.py @@ -322,8 +322,8 @@ def pulse_generator(period: float, animation_object, dotstar_pwm=False): :param animation_object: An animation object to interact with. :param dotstar_pwm: Whether to use the dostar per pixel PWM value for brightness control. """ - period = int((period + (animation_object._breath * 2)) * MS_PER_SECOND) - breath = int(animation_object._breath * MS_PER_SECOND) + period = int((period + (animation_object.breath * 2)) * MS_PER_SECOND) + breath = int(animation_object.breath * MS_PER_SECOND) half_period = period // 2 last_update = monotonic_ms() @@ -339,11 +339,11 @@ def pulse_generator(period: float, animation_object, dotstar_pwm=False): last_pos = pos if pos > half_period: pos = period - pos - intensity = animation_object._min_intensity + ((pos / (half_period - breath)) * (animation_object._max_intensity - animation_object._min_intensity)) + intensity = animation_object.min_intensity + ((pos / (half_period - breath)) * (animation_object.max_intensity - animation_object.min_intensity)) if pos < half_period and pos > (half_period - breath): - intensity = animation_object._max_intensity + intensity = animation_object.max_intensity if pos > (period - breath): - intensity = animation_object._min_intensity + intensity = animation_object.min_intensity if dotstar_pwm: fill_color = ( animation_object.color[0],