feat(patterns): align manual and auto behaviour
Unify manual/auto timing semantics for key patterns, add preset background support, and improve runtime observability while keeping the driver responsive under beat-triggered selects. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -14,6 +14,12 @@ class Pulse:
|
||||
self.driver.fill(self.driver.apply_brightness(bg_base, preset.b))
|
||||
|
||||
color_index = self.driver.step % max(1, len(colors))
|
||||
if not preset.a:
|
||||
# Manual / beat trigger: each select restarts this generator and resets
|
||||
# cycle_start below. Advancing step here makes each beat the next colour
|
||||
# without requiring a full wall-clock cycle between beats.
|
||||
nclr = max(1, len(colors))
|
||||
self.driver.step = (color_index + 1) % nclr
|
||||
cycle_start = utime.ticks_ms()
|
||||
|
||||
# State machine based pulse using a single generator loop
|
||||
@@ -52,13 +58,13 @@ class Pulse:
|
||||
# Delay phase: LEDs off between pulses
|
||||
self.driver.fill(bg_color)
|
||||
else:
|
||||
# End of cycle, move to next color and restart timing
|
||||
# End of cycle: auto advances colour and loops; manual already
|
||||
# advanced step at run start for the next beat.
|
||||
if not preset.a:
|
||||
break
|
||||
color_index = (color_index + 1) % max(1, len(colors))
|
||||
self.driver.step = color_index
|
||||
cycle_start = now
|
||||
if not preset.a:
|
||||
break
|
||||
# Skip drawing this tick, start next cycle
|
||||
yield
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user