File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change 21
21
0x000011 ,
22
22
0x110011 ,
23
23
0x111111 ,
24
- 0x111111 ,
25
- 0x0 ,
26
- 0x0 ]
24
+ 0x221111 ,
25
+ 0x112211 ,
26
+ 0x111122 ]
27
27
28
28
ble = BLERadio ()
29
29
37
37
led = digitalio .DigitalInOut (board .D13 )
38
38
led .switch_to_output ()
39
39
40
- neopixels = neopixel .NeoPixel (board .NEOPIXEL , 10 )
40
+ neopixels = neopixel .NeoPixel (board .NEOPIXEL , 10 , auto_write = False )
41
41
42
42
i = 0
43
43
advertisement = AdafruitColor ()
71
71
closest_last_time = 0
72
72
print ("Scanning for colors" )
73
73
while not slide_switch .value :
74
- for entry in ble .start_scan (AdafruitColor , minimum_rssi = - 80 , timeout = 1 ):
74
+ for entry in ble .start_scan (AdafruitColor , minimum_rssi = - 100 , timeout = 1 ):
75
75
if slide_switch .value :
76
76
break
77
77
now = time .monotonic ()
84
84
continue
85
85
closest_rssi = entry .rssi
86
86
closest_last_time = now
87
- neopixels .fill (entry .color )
87
+ discrete_strength = min ((100 + entry .rssi ) // 5 , 10 )
88
+ #print(entry.rssi, discrete_strength)
89
+ neopixels .fill (0x000000 )
90
+ for i in range (0 , discrete_strength ):
91
+ neopixels [i ] = entry .color
92
+ neopixels .show ()
93
+
94
+ # Clear the pixels if we haven't heard from anything recently.
95
+ now = time .monotonic ()
96
+ if now - closest_last_time > 1 :
97
+ neopixels .fill (0x000000 )
98
+ neopixels .show ()
88
99
ble .stop_scan ()
You can’t perform that action at this time.
0 commit comments