sk6812-client/rgbw_prime_sinus.py

40 lines
872 B
Python
Raw Normal View History

2019-12-01 14:21:01 +01:00
#!/usr/bin/env python
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
while True:
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 + 13*phase + 0 * math.pi/2))
g = scale * (127 + 127 * math.sin(y + x + 23*phase + 1 * math.pi/2))
b = scale * (127 + 127 * math.sin(y + x + 42*phase + 2 * math.pi/2))
w = scale * 0.6 * (127 + 127 * math.sin(y + x + 5*phase + 3 * math.pi/2))
s.set_color((strip+5)%nstrip, i, r, g, b, w)
s.commit()
phase += 2*math.pi * interval / 41
tiltphase += 2*math.pi * interval / 11
time.sleep(interval)