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:
71
examples/panel_animations.py
Executable file
71
examples/panel_animations.py
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run LED matrix animations on Pico panel(s) over UDP."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from leds.panel_udp import (
|
||||
add_panel_args,
|
||||
animation_playlist,
|
||||
format_panel_targets,
|
||||
panel_targets_from_args,
|
||||
run_panel_animation_loop,
|
||||
run_panel_playlist,
|
||||
)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
from leds.animations import ANIMATIONS
|
||||
|
||||
names = list(ANIMATIONS.keys())
|
||||
parser = argparse.ArgumentParser(description="Animations for Pico panel(s) over UDP")
|
||||
parser.add_argument(
|
||||
"animation",
|
||||
nargs="?",
|
||||
choices=names + ["all"],
|
||||
default="all",
|
||||
)
|
||||
add_panel_args(parser)
|
||||
parser.add_argument("--duration", type=float, default=12.0)
|
||||
parser.add_argument("--fps", type=float, default=None)
|
||||
parser.add_argument("--once", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
targets = panel_targets_from_args(args)
|
||||
playlist = animation_playlist(args.animation)
|
||||
print(f"Panel animations -> {format_panel_targets(targets, args.port)}")
|
||||
print(f"Playlist: {', '.join(playlist)}")
|
||||
|
||||
try:
|
||||
if len(playlist) == 1 and args.animation != "all":
|
||||
run_panel_animation_loop(
|
||||
targets,
|
||||
args.port,
|
||||
playlist[0],
|
||||
fps=args.fps,
|
||||
brightness=args.brightness,
|
||||
panel_id=args.panel_id,
|
||||
)
|
||||
else:
|
||||
run_panel_playlist(
|
||||
targets,
|
||||
args.port,
|
||||
playlist,
|
||||
duration=args.duration,
|
||||
fps_override=args.fps,
|
||||
brightness=args.brightness,
|
||||
panel_id=args.panel_id,
|
||||
loop=not args.once,
|
||||
)
|
||||
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