patterns: add rainbow, specto, and radiate (out then dark-out)

radiate: origins every n1, step by delay, stop when full, dark wave outward, ensure strip off at end, run once

alternating: use n1 as ON width and n2 as OFF width; phase via self.step

pulse: attack (n1), hold (delay), decay (n2); stop at end

tests: add specto sweep (n1_sequence) and radiate demo; include n index per message; use nested {name:{...}} schema; support iterations/repeat-delay
This commit is contained in:
2025-09-16 22:28:51 +12:00
parent d599af271b
commit 8cfb3e156b
2 changed files with 143 additions and 7 deletions

View File

@@ -18,6 +18,10 @@ PATTERN_SUITE = [
{"pattern": "n_chase", "n1": 5, "n2": 5, "delay": 250, "iterations": 40, "repeat_delay": 120, "colors": ["#00ff88"]},
{"pattern": "alternating", "n1": 6, "n2": 6, "delay": 300, "iterations": 20, "repeat_delay": 300, "colors": ["#ff8800"]},
{"pattern": "pulse", "delay": 200, "iterations": 6, "repeat_delay": 300, "colors": ["#ffffff"]},
# Specto sweep demo: increase n1 from 0 to 30 repeatedly
{"pattern": "specto", "delay": 80, "iterations": 32, "repeat_delay": 80, "colors": ["#00ff00"], "n1_sequence": list(range(0, 31)) + [30]},
# Radiate demo: origins every 8 LEDs, moderate speed
{"pattern": "radiate", "delay": 60, "iterations": 6, "repeat_delay": 600, "colors": ["#ffffff"], "n1": 8},
]
@@ -70,6 +74,9 @@ async def run_suite(uri: str):
interval_ms = int(cfg.get("interval_ms", cfg.get("delay", 100) or 100))
repeat_ms = int(cfg.get("repeat_delay", interval_ms))
for i in range(iterations):
# Optional per-iteration n1 for specto
seq = cfg.get("n1_sequence")
n1_val = (seq[i % len(seq)] if seq else cfg.get("n1"))
msg = build_message(
cfg.get("pattern", "off"),
i,
@@ -77,7 +84,7 @@ async def run_suite(uri: str):
colors=cfg.get("colors"),
brightness=cfg.get("brightness", 127),
num_leds=cfg.get("num_leds"),
n1=cfg.get("n1"),
n1=n1_val,
n2=cfg.get("n2"),
name=cfg.get("name", "0"),
pattern_step=cfg.get("pattern_step"),