adafruit / adafruit/Adafruit_CircuitPython_LED_Animation

Nesting AnimateOnce inside AnimationSequence causes random animation order

Open
#91 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
62
Forks
46
PR merge metrics
No merged PRs in 30d

Description

A user commented on this: https://forums.adafruit.com/viewtopic.php?f=60&t=186732

This (simplified) example, after the first round, does the red and blue animations in random order. Each `Pulse` animation is correct, but, successive `Pulse`s do not strictly alternate between red and blue. Note the `AnimateOnce` inside `AnimationSequence`.
```py
import board
import neopixel
from adafruit_led_animation.animation.pulse import Pulse
from adafruit_led_animation.sequence import AnimationSequence
from adafruit_led_animation.sequence import AnimateOnce
from adafruit_led_animation.color import RED, BLUE

num_pixels = 24

pixels = neopixel.NeoPixel(board.A0, num_pixels, auto_write=False)
pixels.brightness = 0.2

pulse0 = Pulse(pixels, speed=.05, color=RED, period=1)
pulse1 = Pulse(pixels, speed=.05, color=BLUE, period=1)

animations = AnimationSequence(
AnimateOnce(pulse0,pulse1,),
auto_clear=True,
auto_reset=True,
advance_interval=5,
)

while True:
animations.animate()
```
Removing the nesting works fine. Red and blue alternate, as expected.
```py
import board
import neopixel
from adafruit_led_animation.animation.pulse import Pulse
from adafruit_led_animation.sequence import AnimateOnce
from adafruit_led_animation.color import RED, BLUE

num_pixels = 24

pixels = neopixel.NeoPixel(board.A0, num_pixels, auto_write=False)
pixels.brightness = 0.2

pulse0 = Pulse(pixels, speed=.05, color=RED, period=1)
pulse1 = Pulse(pixels, speed=.05, color=BLUE, period=1)

animations = AnimateOnce(pulse0,pulse1,
auto_clear=True,
auto_reset=True,
advance_interval=5,
)

while True:
animations.animate()
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.