18
18
# Set how many LEDs you have
19
19
NUM_LEDS = 50
20
20
21
+ # Set the brightness
22
+ BRIGHTNESS = 0.5
23
+
21
24
22
25
def status_handler (mode , status , ip ):
23
26
# reports wifi connection status
24
27
print (mode , status , ip )
25
28
print ('Connecting to wifi...' )
26
29
# flash while connecting
27
30
for i in range (NUM_LEDS ):
28
- led_strip .set_rgb (i , 255 , 255 , 255 )
31
+ led_strip .set_hsv (i , 0 , 0 , BRIGHTNESS )
29
32
time .sleep (0.02 )
30
33
for i in range (NUM_LEDS ):
31
- led_strip .set_rgb (i , 0 , 0 , 0 )
34
+ led_strip .set_hsv (i , 0 , 0 , 0 )
32
35
if status is not None :
33
36
if status :
34
37
print ('Wifi connection successful!' )
@@ -52,7 +55,7 @@ def spooky_rainbows():
52
55
j = max (0 , 1 - abs (distance - i ) / (NUM_LEDS / 3 ))
53
56
hue = HUE_START + j * (HUE_END - HUE_START )
54
57
55
- led_strip .set_hsv (i , hue / 360 , 1.0 , 0.8 )
58
+ led_strip .set_hsv (i , hue / 360 , 1.0 , BRIGHTNESS )
56
59
57
60
# reverse direction at the end of colour segment to avoid an abrupt change
58
61
distance += direction
@@ -109,6 +112,9 @@ def hex_to_rgb(hex):
109
112
# and convert it to RGB
110
113
r , g , b = hex_to_rgb (hex )
111
114
115
+ # adjust the brightness
116
+ r , g , b = (int (i * BRIGHTNESS ) for i in (r , g , b ))
117
+
112
118
# light up the LEDs
113
119
for i in range (NUM_LEDS ):
114
120
led_strip .set_rgb (i , r , g , b )
0 commit comments