9
9
import json
10
10
import math
11
11
import displayio
12
+ import os
12
13
import supervisor
13
14
import sys
14
15
import terminalio
52
53
print (f"launching: { next_code_file } " )
53
54
supervisor .reload ()
54
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" , - 1 ),
62
+ }
63
+
55
64
request_display_config (720 , 400 )
56
65
display = supervisor .runtime .display
57
66
70
79
71
80
background_bmp = displayio .Bitmap (display .width , display .height , 1 )
72
81
bg_palette = displayio .Palette (1 )
73
- bg_palette [0 ] = 0x222222
82
+ bg_palette [0 ] = color_palette [ "bg" ]
74
83
bg_tg = displayio .TileGrid (bitmap = background_bmp , pixel_shader = bg_palette )
75
84
scaled_group .append (bg_tg )
76
85
184
193
divider_lines = False )
185
194
scaled_group .append (menu_grid )
186
195
187
- menu_title_txt = Label (font , text = "Fruit Jam OS" )
196
+ menu_title_txt = Label (font , text = "Fruit Jam OS" , color = color_palette [ "fg" ] )
188
197
menu_title_txt .anchor_point = (0.5 , 0.5 )
189
198
menu_title_txt .anchored_position = (display .width // (2 * scale ), 2 )
190
199
scaled_group .append (menu_title_txt )
@@ -268,7 +277,7 @@ def _create_cell_group(app):
268
277
269
278
icon_tg .x = cell_width // 2 - icon_tg .tile_width // 2
270
279
title_txt = TextBox (font , text = app ["title" ], width = WIDTH // config ["width" ], height = 18 ,
271
- align = TextBox .ALIGN_CENTER )
280
+ align = TextBox .ALIGN_CENTER , color = color_palette [ "fg" ] )
272
281
cell_group .append (title_txt )
273
282
title_txt .anchor_point = (0 , 0 )
274
283
title_txt .anchored_position = (0 , icon_tg .y + icon_tg .tile_height )
@@ -289,7 +298,7 @@ def _reuse_cell_group(app, cell_group):
289
298
290
299
icon_tg .x = cell_width // 2 - icon_tg .tile_width // 2
291
300
# title_txt = TextBox(font, text=app["title"], width=WIDTH // config["width"], height=18,
292
- # align=TextBox.ALIGN_CENTER)
301
+ # align=TextBox.ALIGN_CENTER, color=color_palette["fg"] )
293
302
# cell_group.append(title_txt)
294
303
title_txt = cell_group [1 ]
295
304
title_txt .text = app ["title" ]
@@ -338,7 +347,7 @@ def display_page(page_index):
338
347
print (f"{ grid_index } | { grid_index % config ["width" ], grid_index // config ["width" ]} " )
339
348
340
349
341
- page_txt = Label (terminalio .FONT , text = "" , scale = 2 )
350
+ page_txt = Label (terminalio .FONT , text = "" , scale = 2 , color = color_palette [ "fg" ] )
342
351
page_txt .anchor_point = (1.0 , 1.0 )
343
352
page_txt .anchored_position = (display .width - 2 , display .height - 2 )
344
353
main_group .append (page_txt )
@@ -350,6 +359,8 @@ def display_page(page_index):
350
359
left_palette .make_transparent (0 )
351
360
right_bmp , right_palette = adafruit_imageload .load ("launcher_assets/arrow_right.bmp" )
352
361
right_palette .make_transparent (0 )
362
+ if color_palette ["arrow" ] >= 0 :
363
+ left_palette [2 ] = right_palette [2 ] = color_palette ["arrow" ]
353
364
354
365
left_tg = AnchoredTileGrid (bitmap = left_bmp , pixel_shader = left_palette )
355
366
left_tg .anchor_point = (0 , 0.5 )
@@ -371,8 +382,9 @@ def display_page(page_index):
371
382
scaled_group .append (mouse_tg )
372
383
373
384
374
- help_txt = Label (terminalio .FONT , text = "[Arrow]: Move\n [E]: Edit\n [Enter]: Run\n [1-9]: Page" )
375
- # help_txt = TextBox(terminalio.FONT, width=88, height=30, align=TextBox.ALIGN_RIGHT, background_color=0x008800, text="[E]: Edit\n[Enter]: Run")
385
+ help_txt = Label (terminalio .FONT , text = "[Arrow]: Move\n [E]: Edit\n [Enter]: Run\n [1-9]: Page" ,
386
+ color = color_palette ["fg" ])
387
+ # help_txt = TextBox(terminalio.FONT, width=88, height=30, align=TextBox.ALIGN_RIGHT, background_color=color_palette["accent"], text="[E]: Edit\n[Enter]: Run")
376
388
help_txt .anchor_point = (0 , 0 )
377
389
378
390
help_txt .anchored_position = (2 , 2 )
@@ -409,10 +421,10 @@ def change_selected(new_selected):
409
421
410
422
# tuple means an item in the grid is selected
411
423
if isinstance (new_selected , tuple ):
412
- menu_grid .get_content (new_selected )[1 ].background_color = 0x008800
424
+ menu_grid .get_content (new_selected )[1 ].background_color = color_palette [ "accent" ]
413
425
# TileGrid means arrow is selected
414
426
elif isinstance (new_selected , AnchoredTileGrid ):
415
- new_selected .pixel_shader [2 ] = 0x008800
427
+ new_selected .pixel_shader [2 ] = color_palette [ "accent" ]
416
428
selected = new_selected
417
429
418
430
@@ -528,7 +540,7 @@ def handle_key_press(key):
528
540
529
541
handle_key_press (c )
530
542
print ("selected" , selected )
531
- # app_titles[selected].background_color = 0x008800
543
+ # app_titles[selected].background_color = color_palette["accent"]
532
544
533
545
if mouse :
534
546
try :
0 commit comments