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:
31
src/patterns/aurora.py
Normal file
31
src/patterns/aurora.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import utime
|
||||
|
||||
|
||||
class Aurora:
|
||||
def __init__(self, driver):
|
||||
self.driver = driver
|
||||
|
||||
def run(self, preset):
|
||||
colors = preset.c if preset.c else [(40, 200, 140), (80, 120, 255), (160, 80, 220)]
|
||||
bands = max(1, int(preset.n1) if int(preset.n1) > 0 else 3)
|
||||
shimmer = max(0, min(255, int(preset.n2) if int(preset.n2) > 0 else 40))
|
||||
phase = self.driver.step % 256
|
||||
last = utime.ticks_ms()
|
||||
while True:
|
||||
d = max(1, int(preset.d))
|
||||
now = utime.ticks_ms()
|
||||
if utime.ticks_diff(now, last) >= d:
|
||||
for i in range(self.driver.num_leds):
|
||||
idx = ((i * bands) // max(1, self.driver.num_leds) + (phase // 32)) % len(colors)
|
||||
c = self.driver.apply_brightness(colors[idx], preset.b)
|
||||
w = (255 - abs(128 - ((i * 8 + phase) & 255)) * 2)
|
||||
w = max(0, min(255, w + shimmer))
|
||||
self.driver.n[i] = ((c[0]*w)//255, (c[1]*w)//255, (c[2]*w)//255)
|
||||
self.driver.n.write()
|
||||
phase = (phase + 1) & 255
|
||||
self.driver.step = phase
|
||||
last = utime.ticks_add(last, d)
|
||||
if not preset.a:
|
||||
yield
|
||||
return
|
||||
yield
|
||||
Reference in New Issue
Block a user