forked from Yannicked/cm-small-argb-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rainbow.py
40 lines (28 loc) · 752 Bytes
/
rainbow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pywinusb.hid as hid
import time
import colorsys
from cm import Led
def make_rgb(r, g, b):
return [r, g, b]
def create_static(r, g, b, num):
ret = []
for _ in range(num):
ret += make_rgb(r, g, b)
return ret
def main():
led = Led()
led.set_led_count(14)
led.set_mode(7)
while True:
for angle in range(0, 100, 2):
colors = []
for l in range(14):
h = (angle + 100/14*l % 100)/100
s = 1
v = 1
r,g,b = colorsys.hsv_to_rgb(h,s,v)
colors += make_rgb(int(r*255),int(g*255),int(b*255))
led.set_colors(colors)
time.sleep(1/30)
if __name__ == '__main__':
main()