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:
2026-05-04 22:48:54 +12:00
parent 7ce56b64df
commit 42c14361e8
20 changed files with 513 additions and 0 deletions

37
stubs/neopixel.py Normal file
View File

@@ -0,0 +1,37 @@
"""Host NeoPixel: keeps RGB buffer and notifies the GUI on `write()`."""
# Set by led-simulator main: callable(list[tuple[int,int,int]]) -> None
PIXEL_SINK = None
class NeoPixel:
def __init__(self, pin, n):
self.pin = pin
self.n = n
self._buf = [(0, 0, 0)] * n
def __setitem__(self, index, value):
if isinstance(value, (list, tuple)) and len(value) >= 3:
r, g, b = (int(value[0]), int(value[1]), int(value[2]))
self._buf[index] = (
max(0, min(255, r)),
max(0, min(255, g)),
max(0, min(255, b)),
)
def __getitem__(self, index):
return self._buf[index]
def fill(self, color):
c = (0, 0, 0)
if isinstance(color, (list, tuple)) and len(color) >= 3:
c = (
max(0, min(255, int(color[0]))),
max(0, min(255, int(color[1]))),
max(0, min(255, int(color[2]))),
)
self._buf = [c] * self.n
def write(self):
if PIXEL_SINK is not None:
PIXEL_SINK(list(self._buf))