Add multi-panel Pico UDP firmware and Python LED control.
Pico panels get static IPs on 10.1.1.10–14 with per-panel LED counts, Makefile deploy targets, and Python examples for animations, sync tests, and direct Pi SPI control. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
44
examples/panel_rgb_cycle.py
Executable file
44
examples/panel_rgb_cycle.py
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Cycle full-panel red / green / blue on Pico panel(s)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import time
|
||||
|
||||
from leds.panel_udp import PanelClient, add_panel_args, format_panel_targets, panel_targets_from_args
|
||||
|
||||
COLORS = (
|
||||
("RED", (255, 0, 0)),
|
||||
("GREEN", (0, 255, 0)),
|
||||
("BLUE", (0, 0, 255)),
|
||||
)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="RGB cycle on Pico panel(s)")
|
||||
add_panel_args(parser)
|
||||
parser.add_argument("--pause", type=float, default=1.0)
|
||||
args = parser.parse_args()
|
||||
|
||||
targets = panel_targets_from_args(args)
|
||||
print(f"RGB cycle -> {format_panel_targets(targets, args.port)} (Ctrl+C to stop)")
|
||||
|
||||
try:
|
||||
with PanelClient.from_args(args) as client:
|
||||
while True:
|
||||
for label, color in COLORS:
|
||||
print(f" {label}")
|
||||
client.fill(color)
|
||||
time.sleep(args.pause)
|
||||
except KeyboardInterrupt:
|
||||
print("\nStopped.")
|
||||
except OSError as exc:
|
||||
print(f"Network error: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user