53
53
print (f"launching: { next_code_file } " )
54
54
supervisor .reload ()
55
55
56
+ # read environment variables
57
+ color_palette = {
58
+ "bg" : os .getenv ("FRUIT_JAM_OS_BG" , 0x222222 ),
59
+ "fg" : os .getenv ("FRUIT_JAM_OS_FG" , 0xffffff ),
60
+ "accent" : os .getenv ("FRUIT_JAM_OS_ACCENT" , 0x008800 ),
61
+ "arrow" : os .getenv ("FRUIT_JAM_OS_ARROW" ),
62
+ }
63
+
56
64
display = supervisor .runtime .display
57
65
if display is None :
58
66
width_config = os .getenv ("CIRCUITPY_DISPLAY_WIDTH" )
81
89
82
90
background_bmp = displayio .Bitmap (display .width , display .height , 1 )
83
91
bg_palette = displayio .Palette (1 )
84
- bg_palette [0 ] = 0x222222
92
+ bg_palette [0 ] = color_palette [ "bg" ]
85
93
bg_tg = displayio .TileGrid (bitmap = background_bmp , pixel_shader = bg_palette )
86
94
scaled_group .append (bg_tg )
87
95
198
206
divider_lines = False )
199
207
scaled_group .append (menu_grid )
200
208
201
- menu_title_txt = Label (font , text = "Fruit Jam OS" )
209
+ menu_title_txt = Label (font , text = "Fruit Jam OS" , color = color_palette [ "fg" ] )
202
210
menu_title_txt .anchor_point = (0.5 , 0.5 )
203
211
menu_title_txt .anchored_position = (display .width // (2 * scale ), 2 )
204
212
scaled_group .append (menu_title_txt )
@@ -282,7 +290,7 @@ def _create_cell_group(app):
282
290
283
291
icon_tg .x = cell_width // 2 - icon_tg .tile_width // 2
284
292
title_txt = TextBox (font , text = app ["title" ], width = cell_width , height = 18 ,
285
- align = TextBox .ALIGN_CENTER )
293
+ align = TextBox .ALIGN_CENTER , color = color_palette [ "fg" ] )
286
294
icon_tg .y = (cell_height - icon_tg .tile_height - title_txt .height ) // 2
287
295
cell_group .append (title_txt )
288
296
title_txt .anchor_point = (0 , 0 )
@@ -304,7 +312,7 @@ def _reuse_cell_group(app, cell_group):
304
312
305
313
icon_tg .x = cell_width // 2 - icon_tg .tile_width // 2
306
314
# title_txt = TextBox(font, text=app["title"], width=cell_width, height=18,
307
- # align=TextBox.ALIGN_CENTER)
315
+ # align=TextBox.ALIGN_CENTER, color=color_palette["fg"] )
308
316
# cell_group.append(title_txt)
309
317
title_txt = cell_group [1 ]
310
318
title_txt .text = app ["title" ]
@@ -353,7 +361,7 @@ def display_page(page_index):
353
361
print (f"{ grid_index } | { grid_index % config ["width" ], grid_index // config ["width" ]} " )
354
362
355
363
356
- page_txt = Label (terminalio .FONT , text = "" , scale = 2 )
364
+ page_txt = Label (terminalio .FONT , text = "" , scale = 2 , color = color_palette [ "fg" ] )
357
365
page_txt .anchor_point = (1.0 , 1.0 )
358
366
page_txt .anchored_position = (display .width - 2 , display .height - 2 )
359
367
main_group .append (page_txt )
@@ -365,6 +373,8 @@ def display_page(page_index):
365
373
left_palette .make_transparent (0 )
366
374
right_bmp , right_palette = adafruit_imageload .load ("launcher_assets/arrow_right.bmp" )
367
375
right_palette .make_transparent (0 )
376
+ if color_palette ["arrow" ] is not None :
377
+ left_palette [2 ] = right_palette [2 ] = color_palette ["arrow" ]
368
378
369
379
left_tg = AnchoredTileGrid (bitmap = left_bmp , pixel_shader = left_palette )
370
380
left_tg .anchor_point = (0 , 0.5 )
@@ -386,8 +396,9 @@ def display_page(page_index):
386
396
scaled_group .append (mouse_tg )
387
397
388
398
389
- help_txt = Label (terminalio .FONT , text = "[Arrow]: Move\n [E]: Edit\n [Enter]: Run\n [1-9]: Page" )
390
- # help_txt = TextBox(terminalio.FONT, width=88, height=30, align=TextBox.ALIGN_RIGHT, background_color=0x008800, text="[E]: Edit\n[Enter]: Run")
399
+ help_txt = Label (terminalio .FONT , text = "[Arrow]: Move\n [E]: Edit\n [Enter]: Run\n [1-9]: Page" ,
400
+ color = color_palette ["fg" ])
401
+ # help_txt = TextBox(terminalio.FONT, width=88, height=30, align=TextBox.ALIGN_RIGHT, background_color=color_palette["accent"], text="[E]: Edit\n[Enter]: Run")
391
402
help_txt .anchor_point = (0 , 0 )
392
403
393
404
help_txt .anchored_position = (2 , 2 )
@@ -424,10 +435,10 @@ def change_selected(new_selected):
424
435
425
436
# tuple means an item in the grid is selected
426
437
if isinstance (new_selected , tuple ):
427
- menu_grid .get_content (new_selected )[1 ].background_color = 0x008800
438
+ menu_grid .get_content (new_selected )[1 ].background_color = color_palette [ "accent" ]
428
439
# TileGrid means arrow is selected
429
440
elif isinstance (new_selected , AnchoredTileGrid ):
430
- new_selected .pixel_shader [2 ] = 0x008800
441
+ new_selected .pixel_shader [2 ] = color_palette [ "accent" ]
431
442
selected = new_selected
432
443
433
444
@@ -543,7 +554,7 @@ def handle_key_press(key):
543
554
544
555
handle_key_press (c )
545
556
print ("selected" , selected )
546
- # app_titles[selected].background_color = 0x008800
557
+ # app_titles[selected].background_color = color_palette["accent"]
547
558
548
559
if mouse :
549
560
try :
0 commit comments