Skip to content

Commit a855c3b

Browse files
committed
Simplified comparison chain
1 parent f16e519 commit a855c3b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

adafruit_led_animation/helper.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,12 @@ def pulse_generator(period: float, animation_object, dotstar_pwm=False):
339339
last_pos = pos
340340
if pos > half_period:
341341
pos = period - pos
342-
intensity = animation_object.min_intensity + ((pos / (half_period - breath)) * (animation_object.max_intensity - animation_object.min_intensity))
343-
if pos < half_period and pos > (half_period - breath):
342+
if pos < half_period and pox > (half_period - breath):
344343
intensity = animation_object.max_intensity
345-
if pos > (period - breath):
344+
elif pos > (period - breath):
346345
intensity = animation_object.min_intensity
346+
else:
347+
intensity = animation_object.min_intensity + ((pos / (half_period - breath)) * (animation_object.max_intensity - animation_object.min_intensity))
347348
if dotstar_pwm:
348349
fill_color = (
349350
animation_object.color[0],

0 commit comments

Comments
 (0)