forked from Sh4d/LPD8806
-
Notifications
You must be signed in to change notification settings - Fork 28
/
example.py
executable file
·106 lines (81 loc) · 1.68 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
#!/usr/bin/python
from bootstrap import *
#setup colors to loop through for fade
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):
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.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
#sin wave animations
anim = Wave(led, Color(255, 0, 0), 4)
for i in range(led.lastIndex):
anim.step()
led.update()
#sleep(0.15)
anim = Wave(led, Color(0, 0, 100), 2)
for i in range(led.lastIndex):
anim.step()
led.update()
#sleep(0.15)
#rolling rainbow
anim = Rainbow(led)
for i in range(384):
anim.step()
led.update()
led.fillOff()
#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()
#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()
anim = LarsonRainbow(led, 2, 0.5)
for i in range(led.lastIndex*4):
anim.step()
led.update()
#sleep(0.03)
led.all_off()