-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobie_boot_anim.py
executable file
·81 lines (73 loc) · 2.36 KB
/
robie_boot_anim.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
#!/usr/bin/python
import time
from neopixel import *
# configure LED's:
LED_COUNT = 14 # 2 x 7 NeoPixel Jewels
LED_PIN = 18 # Hardware PCM pin (Pin 12, GPIO18)
LED_FREQ_HZ = 800000 # LED frequency (800Khz)
LED_DMA = 5 # DMA channel
LED_BRIGHTNESS = 15 # Can go up to 255, but it's good to keep power usage low
LED_INVERT = False # I believe this is for ws2811's
# This was lifted from the rpi_ws281x strandtest demo. I only added the intensity code:
def wheel(pos, intensity=100):
"""Generate rainbow colors across 0-255 positions."""
if pos < 85:
r = ((pos * 3) * intensity ) / 100
g = ((255 - pos * 3) * intensity ) / 100
return Color(r, g, 0)
elif pos < 170:
pos -= 85
r = ((255 - pos * 3) * intensity ) / 100
b = ((pos * 3) * intensity ) / 100
return Color(r, 0, b)
else:
pos -= 170
g = ((pos * 3) * intensity ) / 100
b = ((255 - pos * 3) * intensity ) / 100
return Color(0, g, b)
def chaseDot(strip):
max_range = 23
chase_speed = 0.1
for x in range(0,max_range):
# This controls the leading pixel:
if x < max_range-4:
pix = (x % 6) + 1
strip.setPixelColor( pix, wheel(x*(256/max_range), 100) )
strip.setPixelColor( pix+7, wheel(x*(256/max_range), 100) )
# This controls the "tail" pixels:
for tail in range(1,5):
if (x-tail)+4 >= max_range:
continue
pix = ((x-tail) % 6) + 1
if pix <= x:
intensity = 100 - (tail * 25)
strip.setPixelColor( pix, wheel((x-tail)*(256/max_range), intensity) )
strip.setPixelColor( pix+7, wheel((x-tail)*(256/max_range), intensity) )
strip.show()
time.sleep(chase_speed)
def fadeFromWhite(strip):
fade_speed = 0.001
for x in range(0,256):
for y in range(0,LED_COUNT):
strip.setPixelColor(y, Color(255-x,255-x,255-x))
strip.show()
time.sleep(fade_speed)
def setMultiColor():
fade_speed = 0.001
step = 256/6
for intensity in range(0,101,10):
for x in range(0,7):
color = wheel( step*x, intensity )
strip.setPixelColor( x, color )
strip.setPixelColor( x+7, color )
strip.show()
time.sleep(fade_speed)
if __name__ == '__main__':
try:
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS)
strip.begin()
chaseDot(strip)
fadeFromWhite(strip)
finally:
setMultiColor()
strip = None