Expand browser editor runtime and LED simulation workflows.
Add Docker deployment support, richer Selenium/LED pattern tests, in-browser diagnostics, responsive UI improvements, and 16x16 panel simulation tooling to speed iteration and hardware-style prototyping. Made-with: Cursor
This commit is contained in:
26
workspace/code/panel16_utils.py
Normal file
26
workspace/code/panel16_utils.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Helpers for 16x16 serpentine NeoPixel panel animations.
|
||||
|
||||
Mapping matches the simulator's 16x16 mode:
|
||||
- first LED at top-right
|
||||
- row 0 goes right -> left
|
||||
- row 1 goes left -> right
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
PANEL_W = 16
|
||||
PANEL_H = 16
|
||||
|
||||
|
||||
def xy_to_index(x: int, y: int, width: int = PANEL_W) -> int:
|
||||
"""Map panel coordinate (x, y) to LED index."""
|
||||
x = int(x)
|
||||
y = int(y)
|
||||
if y % 2 == 0:
|
||||
return y * width + (width - 1 - x)
|
||||
return y * width + x
|
||||
|
||||
|
||||
def clamp8(v: int) -> int:
|
||||
return max(0, min(255, int(v)))
|
||||
Reference in New Issue
Block a user