adafruit / adafruit/Adafruit_CircuitPython_LED_Animation
Nesting AnimateOnce inside AnimationSequence causes random animation order
- Vorherrschende Sprache
- Python
- Sterne
- 62
- Forks
- 46
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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()
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne mit adafruit_led_animation/sequence.py und den Einstiegspunkten AnimationSequence und AnimateOnce und führe anschließend das bereitgestellte verschachtelte Beispiel aus, um das Reihenfolgeproblem zu reproduzieren. Vergleiche es mit dem nicht verschachtelten Beispiel; abgeschlossen ist die Aufgabe, wenn verschachteltes AnimateOnce die roten und blauen Pulse-Animationen nach der ersten Runde konsistent abwechselnd ausführt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- embedded-iot
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100