-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
executable file
·118 lines (93 loc) · 2.12 KB
/
example.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/python
from bootstrap import *
while True:
#setup colors to loop through for fade
colors = [
(178.0,255.0,102.0),
(0.0,128.0,255.0),
(0.0,255.0,255.0),
(255.0,255.0,51.0),
]
# colors = [
# (255.0,0.0,0.0),
# (0.0,255.0,0.0),
# (0.0,0.0,255.0),
# (255.0,255.0,255.0),
# ]
step = 0.01
for c in range(4):
print 'color range'
r, g, b = colors[c]
level = 0.01
dir = step
while level >= 0.0:
led.fill(Color(r, g, b, level))
led.update()
if(level >= 0.99):
dir = -step
level += dir
#sleep(0.005)
led.fillOff()
# led.all_off()
#animations - each animation method moves the animation forward one step on each call
#after each step, call update() to push it to the LED strip
print 'sin wave animations'
anim = Wave(led, Color(0, 255, 255), 4)
for i in range(led.lastIndex):
anim.step()
led.update()
#sleep(0.15)
anim = Wave(led, Color(204, 0, 204), 2)
for i in range(led.lastIndex):
anim.step()
led.update()
#sleep(0.15)
print 'rolling rainbow'
anim = Rainbow(led)
for i in range(384):
anim.step()
led.update()
led.fillOff()
print 'evenly distributed rainbow'
anim = RainbowCycle(led)
for i in range(384*2):
anim.step()
led.update()
led.fillOff()
#setup colors for wipe and chase
colors = [
Color(255, 0, 0),
Color(0, 255, 0),
Color(0, 0, 255),
Color(255, 255, 255),
]
for c in range(4):
anim = ColorWipe(led, colors[c])
for i in range(num):
anim.step()
led.update()
#sleep(0.03)
led.fillOff()
for c in range(4):
anim = ColorChase(led, colors[c])
for i in range(num):
anim.step()
led.update()
#sleep(0.03)
led.fillOff()
print 'scanner: single color and changing color'
anim = LarsonScanner(led, Color(255, 0, 0))
for i in range(led.lastIndex*4):
anim.step()
led.update()
#sleep(0.03)
led.fillOff()
print 'larson rainbow'
anim = LarsonRainbow(led, 2, 0.5)
for i in range(led.lastIndex*4):
anim.step()
led.update()
sleep(0.03)
# led.all_off()
led.fillOff()
print "cycle complete"