|
15 | 15 |
|
16 | 16 | import supervisor |
17 | 17 | import sys |
| 18 | + |
| 19 | +import terminalio |
18 | 20 | import usb |
19 | 21 | import adafruit_pathlib as pathlib |
20 | 22 | from adafruit_bitmap_font import bitmap_font |
21 | 23 | from adafruit_display_text.text_box import TextBox |
22 | 24 | from adafruit_display_text.bitmap_label import Label |
| 25 | + |
23 | 26 | from adafruit_displayio_layout.layouts.grid_layout import GridLayout |
24 | 27 | from adafruit_anchored_tilegrid import AnchoredTileGrid |
25 | 28 | import adafruit_imageload |
|
63 | 66 |
|
64 | 67 | font_file = "/fonts/terminal.lvfontbin" |
65 | 68 | font = bitmap_font.load_font(font_file) |
66 | | -main_group = displayio.Group(scale=scale) |
| 69 | +scaled_group = displayio.Group(scale=scale) |
| 70 | + |
| 71 | +main_group = displayio.Group() |
| 72 | +main_group.append(scaled_group) |
| 73 | + |
67 | 74 | display.root_group = main_group |
68 | 75 |
|
69 | 76 | background_bmp = displayio.Bitmap(display.width, display.height, 1) |
70 | 77 | bg_palette = displayio.Palette(1) |
71 | 78 | bg_palette[0] = 0x222222 |
72 | 79 | bg_tg = displayio.TileGrid(bitmap=background_bmp, pixel_shader=bg_palette) |
73 | | -main_group.append(bg_tg) |
| 80 | +scaled_group.append(bg_tg) |
74 | 81 |
|
75 | 82 | # load the mouse cursor bitmap |
76 | 83 | mouse_bmp = displayio.OnDiskBitmap("launcher_assets/mouse_cursor.bmp") |
|
199 | 206 | default_icon_palette.make_transparent(0) |
200 | 207 | menu_grid = GridLayout(x=40, y=16, width=WIDTH, height=HEIGHT, grid_size=(config["width"], config["height"]), |
201 | 208 | divider_lines=False) |
202 | | -main_group.append(menu_grid) |
| 209 | +scaled_group.append(menu_grid) |
203 | 210 |
|
204 | 211 | menu_title_txt = Label(font, text="Fruit Jam OS") |
205 | 212 | menu_title_txt.anchor_point = (0.5, 0.5) |
206 | 213 | menu_title_txt.anchored_position = (display.width // (2 * scale), 2) |
207 | | -main_group.append(menu_title_txt) |
| 214 | +scaled_group.append(menu_title_txt) |
208 | 215 |
|
209 | 216 | app_titles = [] |
210 | 217 | apps = [] |
|
248 | 255 | "icon": str(icon_file.absolute()) if icon_file is not None else None, |
249 | 256 | "file": str(code_file.absolute()) |
250 | 257 | }) |
| 258 | + |
251 | 259 | i += 1 |
252 | 260 |
|
253 | 261 |
|
@@ -356,15 +364,26 @@ def display_page(page_index): |
356 | 364 | right_tg.anchored_position = ((display.width // scale) - 4, (display.height // 2 // scale) - 2) |
357 | 365 | original_arrow_btn_color = left_palette[2] |
358 | 366 |
|
359 | | -main_group.append(left_tg) |
360 | | -main_group.append(right_tg) |
| 367 | +scaled_group.append(left_tg) |
| 368 | +scaled_group.append(right_tg) |
361 | 369 |
|
362 | 370 | if len(apps) <= 6: |
363 | 371 | right_tg.hidden = True |
364 | 372 | left_tg.hidden = True |
365 | 373 |
|
366 | 374 | if mouse: |
367 | | - main_group.append(mouse_tg) |
| 375 | + scaled_group.append(mouse_tg) |
| 376 | + |
| 377 | + |
| 378 | +help_txt = Label(terminalio.FONT, text="[Arrow]: Move\n[E]: Edit\n[Enter]: Run") |
| 379 | +# help_txt = TextBox(terminalio.FONT, width=88, height=30, align=TextBox.ALIGN_RIGHT, background_color=0x008800, text="[E]: Edit\n[Enter]: Run") |
| 380 | +help_txt.anchor_point = (0, 0) |
| 381 | + |
| 382 | +help_txt.anchored_position = (2, 2) |
| 383 | +# help_txt.anchored_position = (display.width - 89, 1) |
| 384 | + |
| 385 | +print(help_txt.bounding_box) |
| 386 | +main_group.append(help_txt) |
368 | 387 |
|
369 | 388 |
|
370 | 389 | def atexit_callback(): |
@@ -534,6 +553,8 @@ def handle_key_press(key): |
534 | 553 |
|
535 | 554 | editor_launch_file = "apps/editor/code.py" |
536 | 555 | write_argv(editor_launch_file, [apps[editor_index]["file"]]) |
| 556 | + # with open(argv_filename(launch_file), "w") as f: |
| 557 | + # f.write(json.dumps([apps[editor_index]["file"]])) |
537 | 558 |
|
538 | 559 | supervisor.set_next_code_file(editor_launch_file, sticky_on_reload=False, reload_on_error=True, |
539 | 560 | working_directory="/".join(editor_launch_file.split("/")[:-1])) |
|
0 commit comments