27
27
current_mode = MODE_SHOW_PATCHWORK
28
28
29
29
# The color pickers will cycle through this list with buttons A and B.
30
- color_options = [0xEE0000 ,
31
- 0xEEEE00 ,
32
- 0x00EE00 ,
33
- 0x00EEEE ,
34
- 0x0000EE ,
35
- 0xEE00EE ,
36
- 0xCCCCCC ,
37
- 0xFF9999 ,
38
- 0x99FF99 ,
39
- 0x9999FF ]
30
+ color_options = [
31
+ 0xEE0000 ,
32
+ 0xEEEE00 ,
33
+ 0x00EE00 ,
34
+ 0x00EEEE ,
35
+ 0x0000EE ,
36
+ 0xEE00EE ,
37
+ 0xCCCCCC ,
38
+ 0xFF9999 ,
39
+ 0x99FF99 ,
40
+ 0x9999FF ,
41
+ ]
40
42
41
43
42
44
# make all pixels in the patchwork bitmap transparent
@@ -57,14 +59,16 @@ def make_white():
57
59
def draw_grid ():
58
60
for i , color in enumerate (nearby_colors ):
59
61
if i < 64 :
60
- palette_mapping [i + 2 ] = color & 0xFFFFFF # Mask 0xFFFFFF to avoid invalid color.
62
+ palette_mapping [i + 2 ] = (
63
+ color & 0xFFFFFF
64
+ ) # Mask 0xFFFFFF to avoid invalid color.
61
65
print (i )
62
66
print (color )
63
67
64
68
65
69
# create a fake mac address and color for testing
66
70
def add_fake ():
67
- fake_mac = '' .join ([random .choice ("0123456789abcdef" ) for _ in range (10 )])
71
+ fake_mac = "" .join ([random .choice ("0123456789abcdef" ) for _ in range (10 )])
68
72
fake_color = random .choice (color_options )
69
73
nearby_addresses .append (fake_mac )
70
74
nearby_colors .append (fake_color )
@@ -144,7 +148,9 @@ def change_advertisement(color):
144
148
left_btn_lbl = label .Label (terminalio .FONT , text = "A" , color = 0x000000 )
145
149
right_btn_lbl = label .Label (terminalio .FONT , text = "B" , color = 0x000000 )
146
150
147
- left_btn_action = label .Label (terminalio .FONT , text = "Next\n Color" , color = 0x000000 , line_spacing = 1 )
151
+ left_btn_action = label .Label (
152
+ terminalio .FONT , text = "Next\n Color" , color = 0x000000 , line_spacing = 1
153
+ )
148
154
right_btn_action = label .Label (terminalio .FONT , text = "Save" , color = 0x000000 )
149
155
150
156
color_select_text_group .append (left_btn_lbl )
@@ -182,8 +188,9 @@ def change_advertisement(color):
182
188
color_preview_group .x = 240 // 2 - 60 // 2
183
189
color_preview_group .y = 240 - (60 + 2 )
184
190
185
- color_preview_tilegrid = displayio .TileGrid (color_select_preview_bmp ,
186
- pixel_shader = color_select_palette )
191
+ color_preview_tilegrid = displayio .TileGrid (
192
+ color_select_preview_bmp , pixel_shader = color_select_palette
193
+ )
187
194
color_preview_group .append (color_preview_tilegrid )
188
195
189
196
# Create a TileGrid using the Bitmap and Palette
@@ -239,7 +246,9 @@ def change_advertisement(color):
239
246
while clue .proximity >= PROXIMITY_LIMIT :
240
247
r , g , b , w = clue .color
241
248
clue .pixel .fill (((r >> 8 ) & 0xFF , (g >> 8 ) & 0xFF , (b >> 8 ) & 0xFF ))
242
- change_advertisement (((r & 0xFF00 ) << 8 ) + (g & 0xFF00 ) + ((b >> 8 ) & 0xFF ))
249
+ change_advertisement (
250
+ ((r & 0xFF00 ) << 8 ) + (g & 0xFF00 ) + ((b >> 8 ) & 0xFF )
251
+ )
243
252
time .sleep (0.1 )
244
253
clue .white_leds = False
245
254
0 commit comments