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
+ }
62
+
55
63
request_display_config (720 , 400 )
56
64
display = supervisor .runtime .display
57
65
70
78
71
79
background_bmp = displayio .Bitmap (display .width , display .height , 1 )
72
80
bg_palette = displayio .Palette (1 )
73
- bg_palette [0 ] = 0x222222
81
+ bg_palette [0 ] = color_palette [ "bg" ]
74
82
bg_tg = displayio .TileGrid (bitmap = background_bmp , pixel_shader = bg_palette )
75
83
scaled_group .append (bg_tg )
76
84
184
192
divider_lines = False )
185
193
scaled_group .append (menu_grid )
186
194
187
- menu_title_txt = Label (font , text = "Fruit Jam OS" )
195
+ menu_title_txt = Label (font , text = "Fruit Jam OS" , color = color_palette [ "fg" ] )
188
196
menu_title_txt .anchor_point = (0.5 , 0.5 )
189
197
menu_title_txt .anchored_position = (display .width // (2 * scale ), 2 )
190
198
scaled_group .append (menu_title_txt )
@@ -268,7 +276,7 @@ def _create_cell_group(app):
268
276
269
277
icon_tg .x = cell_width // 2 - icon_tg .tile_width // 2
270
278
title_txt = TextBox (font , text = app ["title" ], width = WIDTH // config ["width" ], height = 18 ,
271
- align = TextBox .ALIGN_CENTER )
279
+ align = TextBox .ALIGN_CENTER , color = color_palette [ "fg" ] )
272
280
cell_group .append (title_txt )
273
281
title_txt .anchor_point = (0 , 0 )
274
282
title_txt .anchored_position = (0 , icon_tg .y + icon_tg .tile_height )
@@ -289,7 +297,7 @@ def _reuse_cell_group(app, cell_group):
289
297
290
298
icon_tg .x = cell_width // 2 - icon_tg .tile_width // 2
291
299
# title_txt = TextBox(font, text=app["title"], width=WIDTH // config["width"], height=18,
292
- # align=TextBox.ALIGN_CENTER)
300
+ # align=TextBox.ALIGN_CENTER, color=color_palette["fg"] )
293
301
# cell_group.append(title_txt)
294
302
title_txt = cell_group [1 ]
295
303
title_txt .text = app ["title" ]
@@ -338,7 +346,7 @@ def display_page(page_index):
338
346
print (f"{ grid_index } | { grid_index % config ["width" ], grid_index // config ["width" ]} " )
339
347
340
348
341
- page_txt = Label (terminalio .FONT , text = "" , scale = 2 )
349
+ page_txt = Label (terminalio .FONT , text = "" , scale = 2 , color = color_palette [ "fg" ] )
342
350
page_txt .anchor_point = (1.0 , 1.0 )
343
351
page_txt .anchored_position = (display .width - 2 , display .height - 2 )
344
352
main_group .append (page_txt )
@@ -371,8 +379,9 @@ def display_page(page_index):
371
379
scaled_group .append (mouse_tg )
372
380
373
381
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")
382
+ help_txt = Label (terminalio .FONT , text = "[Arrow]: Move\n [E]: Edit\n [Enter]: Run\n [1-9]: Page" ,
383
+ color = color_palette ["fg" ])
384
+ # 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
385
help_txt .anchor_point = (0 , 0 )
377
386
378
387
help_txt .anchored_position = (2 , 2 )
@@ -409,10 +418,10 @@ def change_selected(new_selected):
409
418
410
419
# tuple means an item in the grid is selected
411
420
if isinstance (new_selected , tuple ):
412
- menu_grid .get_content (new_selected )[1 ].background_color = 0x008800
421
+ menu_grid .get_content (new_selected )[1 ].background_color = color_palette [ "accent" ]
413
422
# TileGrid means arrow is selected
414
423
elif isinstance (new_selected , AnchoredTileGrid ):
415
- new_selected .pixel_shader [2 ] = 0x008800
424
+ new_selected .pixel_shader [2 ] = color_palette [ "accent" ]
416
425
selected = new_selected
417
426
418
427
@@ -528,7 +537,7 @@ def handle_key_press(key):
528
537
529
538
handle_key_press (c )
530
539
print ("selected" , selected )
531
- # app_titles[selected].background_color = 0x008800
540
+ # app_titles[selected].background_color = color_palette["accent"]
532
541
533
542
if mouse :
534
543
try :
0 commit comments