Files
portal/examples/panel_rgb_cycle.py
Jimmy 5094c7bcee Add portal web simulator, SPI bridges, and Pico firmware updates.
Bring the five-panel hex portal online with a browser 3D/schematic preview, Pi SPI backends, and renamed multi-panel Pico UDP firmware.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 14:54:51 +12:00

40 lines
1.1 KiB
Python
Executable File

#!/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.colors import RGB_CYCLE
from leds.panel_udp import PanelClient, add_panel_args, format_panel_targets, panel_targets_from_args
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 RGB_CYCLE:
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())