From a855c3b99eb1f5551259fdfd02805cf7e1ec35f1 Mon Sep 17 00:00:00 2001 From: Tyler Winfield Date: Tue, 19 Dec 2023 23:16:10 -0600 Subject: [PATCH] Simplified comparison chain --- adafruit_led_animation/helper.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/adafruit_led_animation/helper.py b/adafruit_led_animation/helper.py index 466ef63..496ee18 100644 --- a/adafruit_led_animation/helper.py +++ b/adafruit_led_animation/helper.py @@ -339,11 +339,12 @@ 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)) - if pos < half_period and pos > (half_period - breath): + if pos < half_period and pox > (half_period - breath): intensity = animation_object.max_intensity - if pos > (period - breath): + elif pos > (period - breath): intensity = animation_object.min_intensity + else: + intensity = animation_object.min_intensity + ((pos / (half_period - breath)) * (animation_object.max_intensity - animation_object.min_intensity)) if dotstar_pwm: fill_color = ( animation_object.color[0],