feat: simulator bridge, rig seed and web UI (in progress)

Work in progress from the same tree as the controller's sequences-v2 changes.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Haiku 5.5 committed 2026-11-11 14:10:55 +13:00
1 parent 4fc3345fc9
commit 4d8aeb5df8
26 files changed
+3907 -288

No files matched your search

+74 -3
View File
@@ -1,18 +1,89 @@
"""CPython stub for MicroPython `machine` (led-simulator)."""
"""MicroPython ``machine`` stub for led-simulator (Pyodide)."""
import os
import time
try:
import _simlink
except ImportError: # outside the simulator
_simlink = None
PWRON_RESET = 1
HARD_RESET = 2
WDT_RESET = 3
DEEPSLEEP_RESET = 4
SOFT_RESET = 5
# SystemExit code that tells the page to boot this driver again (machine.reset()).
RESET_EXIT_CODE = 75
# The driver main loop calls wdt.feed() once per pass with no sleep. A short
# sleep here keeps 16 simulated drivers from pinning every CPU core, and the
# feed is where the simulator flushes pixels and flash writes.
_LOOP_SLEEP_S = max(0.0, float(os.environ.get("LED_SIM_LOOP_SLEEP_MS", "2")) / 1000.0)
_freq = 160000000
class Pin:
OUT = 1
IN = 0
PULL_UP = 1
PULL_DOWN = 2
def __init__(self, pin_id, mode=None, *, pull=None, value=None):
self.id = pin_id
self.mode = mode
self._value = value or 0
def value(self, v=None):
if v is None:
return self._value
self._value = 1 if v else 0
return None
def on(self):
self._value = 1
def off(self):
self._value = 0
class WDT:
def __init__(self, timeout=10000):
def __init__(self, id=0, timeout=10000):
self._timeout = timeout
def feed(self):
pass
if _LOOP_SLEEP_S:
time.sleep(_LOOP_SLEEP_S)
if _simlink is not None:
_simlink.on_feed()
def freq(hz=None):
global _freq
if hz is None:
return _freq
_freq = int(hz)
return None
def reset():
raise SystemExit(RESET_EXIT_CODE)
def soft_reset():
raise SystemExit(RESET_EXIT_CODE)
def reset_cause():
return PWRON_RESET
def unique_id():
mac = os.environ.get("LED_SIM_MAC", "aabbccddeeff")
return bytes.fromhex(mac)
def idle():
time.sleep(0.001)