udp for update

This commit is contained in:
gitGnome
2026-04-01 13:38:42 +02:00
parent 541f2ff09c
commit e27ecd85f0
2 changed files with 48 additions and 6 deletions
+19
View File
@@ -7,6 +7,7 @@ Run with: sudo python3 main.py
import time
import random
import socket
import sys
from rpi_ws281x import PixelStrip, ws
@@ -32,6 +33,23 @@ strip = PixelStrip(
strip.begin()
low_level.strip = strip
_udp_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
_udp_addr = ('127.0.0.1', 4210)
def _send_frame():
buf = bytearray(48 * 16 * 3)
off = 0
for y in range(16):
for x in range(48):
r, g, b = low_level.get_pixel_color(x, y)
buf[off] = r
buf[off + 1] = g
buf[off + 2] = b
off += 3
_udp_sock.sendto(buf, _udp_addr)
# ---------------------------------------------------------------------------
# Global state
# ---------------------------------------------------------------------------
@@ -419,6 +437,7 @@ def loop():
handle_disappear_timers()
strip.show()
_send_frame()
if __name__ == '__main__':