fix(patterns): use preset background fallback across animations
Align pattern background rendering to use preset.background_or(...) and update pulse/radiate single-step behaviour to preserve visible frames and step progression.
This commit is contained in:
@@ -6,19 +6,19 @@ class Pulse:
|
||||
self.driver = driver
|
||||
|
||||
def run(self, preset):
|
||||
self.driver.off()
|
||||
|
||||
# Get colors from preset
|
||||
colors = preset.c
|
||||
if not colors:
|
||||
colors = [(255, 255, 255)]
|
||||
bg_base = preset.background_or(colors)
|
||||
self.driver.fill(self.driver.apply_brightness(bg_base, preset.b))
|
||||
|
||||
color_index = 0
|
||||
color_index = self.driver.step % max(1, len(colors))
|
||||
cycle_start = utime.ticks_ms()
|
||||
|
||||
# State machine based pulse using a single generator loop
|
||||
while True:
|
||||
bg_color = self.driver.apply_brightness(colors[-1], preset.b)
|
||||
bg_color = self.driver.apply_brightness(bg_base, preset.b)
|
||||
# Read current timing parameters from preset
|
||||
attack_ms = max(0, int(preset.n1)) # Attack time in ms
|
||||
hold_ms = max(0, int(preset.n2)) # Hold time in ms
|
||||
@@ -53,7 +53,8 @@ class Pulse:
|
||||
self.driver.fill(bg_color)
|
||||
else:
|
||||
# End of cycle, move to next color and restart timing
|
||||
color_index += 1
|
||||
color_index = (color_index + 1) % max(1, len(colors))
|
||||
self.driver.step = color_index
|
||||
cycle_start = now
|
||||
if not preset.a:
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user