feat: sequences v2, bridges, and sim-controller

Rework sequences (engine, seqplay, envelope, API, web UI), add bridge
support, add the host sim-controller and rig simulation tests, and
update docs, presets and project tooling config.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Sonnet 5.5 committed 2026-11-10 17:47:27 +13:00
1 parent d664026ee5
commit 2543673bd8
68 files changed
+5761 -460

No files matched your search

+27 -4
View File
@@ -32,6 +32,10 @@ v2 default blob:
u8 target_count
each: u8 len; target name utf-8
v3: as v2, but every preset record is followed by an extension block:
u8 ext_len; then entries u8 key, u8 len, value — key 1 fade-in ms (u16), key 2 beat timing (u8, 1 = durations
in quarter beats). Readers skip keys they don't know. Only frames whose presets use them are v3.
Legacy v1: sections are UTF-8 JSON text (see ``parse_binary_envelope_v1``).
Keep ``5 + lp + ls + ld`` ≤ 245 for a single ESP-NOW frame body.
@@ -45,7 +49,22 @@ from typing import Any, Dict, List, Optional, Tuple
BINARY_ENVELOPE_VERSION_1 = 1
BINARY_ENVELOPE_VERSION_2 = 2
BINARY_ENVELOPE_VERSION_3 = 3
HEADER_LEN = 5
EXT_FADE = 1
EXT_BEAT = 2
def _preset_ext(preset: Dict[str, Any]) -> bytes:
fade = preset.get("f") or preset.get("fade") or 0
fade = max(0, min(10000, int(fade)))
beat = 1 if (preset.get("tb") or preset.get("beat_time")) else 0
body = b""
if fade:
body += bytes([EXT_FADE, 2]) + struct.pack("<H", fade)
if beat:
body += bytes([EXT_BEAT, 1, 1])
return body
def brightness_wire_from_0_255(value: int) -> int:
@@ -126,11 +145,14 @@ def _pack_preset_dict(name: str, preset: Dict[str, Any]) -> bytes:
return b"".join(parts)
def _pack_presets_blob(presets: Dict[str, Any]) -> bytes:
def _pack_presets_blob(presets: Dict[str, Any], v3: bool = False) -> bytes:
items = [(k, v) for k, v in presets.items() if isinstance(v, dict)]
out = [bytes([len(items)])]
for name, pdata in items:
out.append(_pack_preset_dict(str(name), pdata))
if v3:
ext = _preset_ext(pdata)
out.append(bytes([len(ext)]) + ext)
return b"".join(out)
@@ -196,9 +218,10 @@ def pack_binary_envelope_v2(
default_targets: Optional[list] = None,
brightness_0_255: Optional[int] = None,
) -> bytes:
"""Build a v2 envelope (native binary sections, no JSON)."""
"""Build a v2 envelope (native binary sections, no JSON); v3 when a preset has a fade or beat timing."""
v3 = bool(presets) and any(isinstance(v, dict) and _preset_ext(v) for v in presets.values())
presets_bytes = (
_pack_presets_blob(presets) if presets is not None and presets else b""
_pack_presets_blob(presets, v3) if presets is not None and presets else b""
)
select_bytes = (
_pack_select_blob(select) if select is not None and select else b""
@@ -220,7 +243,7 @@ def pack_binary_envelope_v2(
if brightness_0_255 is None
else brightness_wire_from_0_255(brightness_0_255)
)
header = bytes([BINARY_ENVELOPE_VERSION_2, br_wire, lp, ls, ld])
header = bytes([BINARY_ENVELOPE_VERSION_3 if v3 else BINARY_ENVELOPE_VERSION_2, br_wire, lp, ls, ld])
return header + presets_bytes + select_bytes + default_bytes