added script for displaying animations to fensterbogenbeleuchtung (only command 'r')
This commit is contained in:
commit
ef14360ec8
|
@ -0,0 +1,28 @@
|
|||
import tkinter as tk
|
||||
import socket
|
||||
|
||||
num = 116
|
||||
h = 20
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.bind(("", 49152))
|
||||
|
||||
w = tk.Canvas(width=10*num, height=h)
|
||||
w.pack()
|
||||
|
||||
leds = [w.create_rectangle(i*10, 0, i*10+10, h, outline="black", fill="black") for i in range(num)]
|
||||
|
||||
def update_colors():
|
||||
data = s.recvfrom(1024)[0][5:]
|
||||
for i in range(num):
|
||||
offset = (num - i - 1) * 3
|
||||
c = "#%02x%02x%02x" % (data[offset+1], data[offset], data[offset+2])
|
||||
w.itemconfig(leds[i], fill=c, outline=c)
|
||||
w.after(10, update_colors)
|
||||
|
||||
try:
|
||||
w.after(10, update_colors)
|
||||
tk.mainloop()
|
||||
except KeyboardInterrupt:
|
||||
del w
|
||||
del s
|
Loading…
Reference in New Issue