feat(patterns): add expanded animation pack with smoke tests
Add a broad set of new pattern modules and matching pattern smoke scripts so the new effects can be validated directly on-device.
This commit is contained in:
33
src/patterns/clock_sweep.py
Normal file
33
src/patterns/clock_sweep.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import utime
|
||||
|
||||
|
||||
class ClockSweep:
|
||||
def __init__(self, driver):
|
||||
self.driver = driver
|
||||
|
||||
def run(self, preset):
|
||||
colors = preset.c if preset.c else [(255, 255, 255), (60, 60, 60)]
|
||||
width = max(1, int(preset.n1) if int(preset.n1) > 0 else 1)
|
||||
marker = max(0, int(preset.n2) if int(preset.n2) > 0 else 0)
|
||||
pos = self.driver.step % max(1, self.driver.num_leds)
|
||||
last = utime.ticks_ms()
|
||||
while True:
|
||||
d = max(1, int(preset.d))
|
||||
now = utime.ticks_ms()
|
||||
if utime.ticks_diff(now, last) >= d:
|
||||
bg = self.driver.apply_brightness(colors[1] if len(colors) > 1 else (0, 0, 0), preset.b)
|
||||
fg = self.driver.apply_brightness(colors[0], preset.b)
|
||||
for i in range(self.driver.num_leds):
|
||||
self.driver.n[i] = bg
|
||||
if marker > 0 and i % marker == 0:
|
||||
self.driver.n[i] = ((bg[0]*2)//3, (bg[1]*2)//3, (bg[2]*2)//3)
|
||||
for w in range(width):
|
||||
self.driver.n[(pos + w) % self.driver.num_leds] = fg
|
||||
self.driver.n.write()
|
||||
pos = (pos + 1) % max(1, self.driver.num_leds)
|
||||
self.driver.step = pos
|
||||
last = utime.ticks_add(last, d)
|
||||
if not preset.a:
|
||||
yield
|
||||
return
|
||||
yield
|
||||
Reference in New Issue
Block a user