7 np
= neopixel
.NeoPixel(pin0
, NP_COUNT
)
13 #########################################
15 def fade_all(pixels
, fade_by
=0.9):
16 for i
in range(NP_COUNT
):
17 fade(pixels
, i
, fade_by
=fade_by
)
20 def fade(pixels
, n
, fade_by
=0.9):
22 pixels
[n
] = (int(r
* fade_by
), int(g
* fade_by
), int(b
* fade_by
))
23 # End of functions to add
24 #########################################
27 initial_colour
= (255, 128, 128)
29 for i
in range(BURST_SIZE
):
30 pixels
[NP_COUNT
- BURST_SIZE
+ i
] = initial_colour
31 pixels
[NP_COUNT
- BURST_SIZE
- i
] = initial_colour
32 fade_all(pixels
, fade_by
=0.95) # Add this line
33 # pixels.show() # Remove this line
34 # time.sleep(0.5) # Remove this line
36 for _
in range(30): # Add this line
37 fade_all(pixels
) # Add this line
40 for n
in range(NP_COUNT
):
45 def shoot_firework(pixels
):
46 for pixel
in range(NP_COUNT
- BURST_SIZE
):
55 last_gesture
= accelerometer
.current_gesture()
58 gesture
= accelerometer
.current_gesture()
59 if gesture
!= last_gesture
or button_a
.is_pressed():
64 last_gesture
= gesture