forked from Lord-Awesome/Chris_Code_Database
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserialized_hue_shift.py
More file actions
28 lines (26 loc) · 1.04 KB
/
serialized_hue_shift.py
File metadata and controls
28 lines (26 loc) · 1.04 KB
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
def serialized_hue_shift(wait, speed):
pixels.clear()
pixels.show()
time.sleep(2)
color_list = []
# Generate the colors
for i in range(math.floor(256/speed)):
color = Adafruit_WS2801.RGB_to_color(0, 255, math.floor(i*speed))
color_list.append(color)
for i in range(math.floor(256/speed)):
color = Adafruit_WS2801.RGB_to_color(0, 255-math.floor(i*speed), 255)
color_list.append(color)
for i in range(math.floor(256/speed)):
color = Adafruit_WS2801.RGB_to_color(math.floor(i*speed), 0, 255)
color_list.append(color)
for i in range(math.floor(256/speed)):
color = Adafruit_WS2801.RGB_to_color(255, 0, 255-math.floor(i*speed))
color_list.append(color)
#Light the LEDs
for i in range(len(color_list)):
for j in range(pixels.count()):
k = (i+j)%len(color_list) #if we exceed the list, wrap around
pixels.set_pixel(j, color_list[k])
pixels.show()
if wait > 0:
time.sleep(wait)