feat(simulator): add GUI runner, stubs, and workspace assets
Add host simulator scaffolding, examples, and docs so led-driver main can run end-to-end with MicroPython module stubs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
25
examples/chase.py
Normal file
25
examples/chase.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""Simple one-pixel chase (uses preset c[0] for the dot, preset n3 as step)."""
|
||||
|
||||
import utime
|
||||
|
||||
|
||||
class Chase:
|
||||
def __init__(self, presets):
|
||||
self.presets = presets
|
||||
|
||||
def run(self, preset):
|
||||
n = self.presets.num_leds
|
||||
rgb = preset.c[0] if preset.c else (255, 64, 0)
|
||||
raw_step = int(getattr(preset, "n3", 1))
|
||||
step = raw_step if raw_step != 0 else 1
|
||||
pos = 0
|
||||
delay_ms = max(1, int(preset.d))
|
||||
while True:
|
||||
off = (0, 0, 0)
|
||||
for i in range(n):
|
||||
self.presets.n[i] = off
|
||||
self.presets.n[pos % n] = self.presets.apply_brightness(rgb, preset.b)
|
||||
self.presets.n.write()
|
||||
yield
|
||||
utime.sleep_ms(delay_ms)
|
||||
pos += step
|
||||
Reference in New Issue
Block a user