Skip to content

Commit 60cd407

Browse files
authored
Merge branch 'main' into aspect-ratio
2 parents ebbd201 + 2de4173 commit 60cd407

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

src/code.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@
5353
print(f"launching: {next_code_file}")
5454
supervisor.reload()
5555

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+
5664
display = supervisor.runtime.display
5765
if display is None:
5866
width_config = os.getenv("CIRCUITPY_DISPLAY_WIDTH")
@@ -81,7 +89,7 @@
8189

8290
background_bmp = displayio.Bitmap(display.width, display.height, 1)
8391
bg_palette = displayio.Palette(1)
84-
bg_palette[0] = 0x222222
92+
bg_palette[0] = color_palette["bg"]
8593
bg_tg = displayio.TileGrid(bitmap=background_bmp, pixel_shader=bg_palette)
8694
scaled_group.append(bg_tg)
8795

@@ -198,7 +206,7 @@
198206
divider_lines=False)
199207
scaled_group.append(menu_grid)
200208

201-
menu_title_txt = Label(font, text="Fruit Jam OS")
209+
menu_title_txt = Label(font, text="Fruit Jam OS", color=color_palette["fg"])
202210
menu_title_txt.anchor_point = (0.5, 0.5)
203211
menu_title_txt.anchored_position = (display.width // (2 * scale), 2)
204212
scaled_group.append(menu_title_txt)
@@ -282,7 +290,7 @@ def _create_cell_group(app):
282290

283291
icon_tg.x = cell_width // 2 - icon_tg.tile_width // 2
284292
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"])
286294
icon_tg.y = (cell_height - icon_tg.tile_height - title_txt.height) // 2
287295
cell_group.append(title_txt)
288296
title_txt.anchor_point = (0, 0)
@@ -304,7 +312,7 @@ def _reuse_cell_group(app, cell_group):
304312

305313
icon_tg.x = cell_width // 2 - icon_tg.tile_width // 2
306314
# 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"])
308316
# cell_group.append(title_txt)
309317
title_txt = cell_group[1]
310318
title_txt.text = app["title"]
@@ -353,7 +361,7 @@ def display_page(page_index):
353361
print(f"{grid_index} | {grid_index % config["width"], grid_index // config["width"]}")
354362

355363

356-
page_txt = Label(terminalio.FONT, text="", scale=2)
364+
page_txt = Label(terminalio.FONT, text="", scale=2, color=color_palette["fg"])
357365
page_txt.anchor_point = (1.0, 1.0)
358366
page_txt.anchored_position = (display.width - 2, display.height - 2)
359367
main_group.append(page_txt)
@@ -365,6 +373,8 @@ def display_page(page_index):
365373
left_palette.make_transparent(0)
366374
right_bmp, right_palette = adafruit_imageload.load("launcher_assets/arrow_right.bmp")
367375
right_palette.make_transparent(0)
376+
if color_palette["arrow"] is not None:
377+
left_palette[2] = right_palette[2] = color_palette["arrow"]
368378

369379
left_tg = AnchoredTileGrid(bitmap=left_bmp, pixel_shader=left_palette)
370380
left_tg.anchor_point = (0, 0.5)
@@ -386,8 +396,9 @@ def display_page(page_index):
386396
scaled_group.append(mouse_tg)
387397

388398

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")
391402
help_txt.anchor_point = (0, 0)
392403

393404
help_txt.anchored_position = (2, 2)
@@ -424,10 +435,10 @@ def change_selected(new_selected):
424435

425436
# tuple means an item in the grid is selected
426437
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"]
428439
# TileGrid means arrow is selected
429440
elif isinstance(new_selected, AnchoredTileGrid):
430-
new_selected.pixel_shader[2] = 0x008800
441+
new_selected.pixel_shader[2] = color_palette["accent"]
431442
selected = new_selected
432443

433444

@@ -543,7 +554,7 @@ def handle_key_press(key):
543554

544555
handle_key_press(c)
545556
print("selected", selected)
546-
# app_titles[selected].background_color = 0x008800
557+
# app_titles[selected].background_color = color_palette["accent"]
547558

548559
if mouse:
549560
try:

src/settings.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
CIRCUITPY_PYSTACK_SIZE=4000
2-
# FRUIT_JAM_OS_4x3=1
2+
# FRUIT_JAM_OS_BG=0x222222
3+
# FRUIT_JAM_OS_FG=0xffffff
4+
# FRUIT_JAM_OS_ACCENT=0x008800
5+
# FRUIT_JAM_OS_ARROW=0x004abe

0 commit comments

Comments
 (0)