sk6812-client/fader.py

37 lines
600 B
Python
Raw Normal View History

2019-12-01 14:21:01 +01:00
#!/usr/bin/env python
import sk6812
import time
import random
s = sk6812.SK6812("zybot", 2703)
s.set_fadestep(10)
colorcycle = [
(255, 0, 0, 0),
(0, 255, 0, 0),
(0, 0, 255, 0),
(0, 0, 0, 255),
(255, 0, 0, 255),
(0, 255, 0, 255),
(0, 0, 255, 255),
(255, 255, 255, 255),
]
k = 0
while True:
r = colorcycle[k][0]
g = colorcycle[k][1]
b = colorcycle[k][2]
w = colorcycle[k][3]
for i in range(300):
s.fade_color(i, r, g, b, w)
s.commit()
time.sleep(0.01)
k = (k + 1) % len(colorcycle)
time.sleep(1)