56 lines
1.1 KiB
Python
Executable File
56 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import sk6812_multistrip as sk6812
|
|
import time
|
|
import math
|
|
import sys
|
|
|
|
s = sk6812.SK6812(sys.argv[1], 2703)
|
|
|
|
phase = 0
|
|
nled = 16
|
|
nstrip = 8
|
|
|
|
interval = 1.0/60
|
|
|
|
scale = 0.15
|
|
|
|
strip = 0
|
|
|
|
tiltphase = 0
|
|
|
|
seq = 0
|
|
rxseq = 0
|
|
lasttxtime = 0
|
|
|
|
while True:
|
|
|
|
rxseq = s.try_read_seq()
|
|
if rxseq != -1:
|
|
print(f"TX: {seq}, RX: {rxseq}")
|
|
|
|
now = time.time()
|
|
|
|
if rxseq >= seq - 3 or (lasttxtime < now - 0.5):
|
|
lasttxtime = now
|
|
|
|
for i in range(nled):
|
|
for strip in range(nstrip):
|
|
x = 2*math.pi * i / nled
|
|
y = 2*math.pi * strip * 2*math.sin(tiltphase) / nstrip
|
|
r = scale * (127 + 127 * math.sin(y + x + 283*phase + 0 * math.pi/2))
|
|
g = scale * (127 + 127 * math.sin(y + x + 293*phase + 1 * math.pi/2))
|
|
b = scale * (127 + 127 * math.sin(y + x + 307*phase + 2 * math.pi/2))
|
|
w = scale * 0.6 * (127 + 127 * math.sin(y + x + 311*phase + 3 * math.pi/2))
|
|
|
|
s.set_color((strip+0)%nstrip, i, r, g, b, w)
|
|
|
|
s.ack_request(seq)
|
|
seq += 1
|
|
s.commit()
|
|
|
|
phase += 2*math.pi * interval / (739*1)
|
|
tiltphase += 2*math.pi * interval / (471/2)
|
|
time.sleep(interval)
|
|
|