|
24 | 24 | import adafruit_imageload
|
25 | 25 | import adafruit_usb_host_descriptors
|
26 | 26 | from adafruit_anchored_group import AnchoredGroup
|
27 |
| -from adafruit_fruitjam.peripherals import request_display_config |
| 27 | +from adafruit_fruitjam.peripherals import request_display_config, VALID_DISPLAY_SIZES |
28 | 28 | from adafruit_argv_file import read_argv, write_argv
|
29 | 29 |
|
30 | 30 | """
|
|
53 | 53 | print(f"launching: {next_code_file}")
|
54 | 54 | supervisor.reload()
|
55 | 55 |
|
56 |
| -# read environment variables |
57 |
| -aspect_ratio_4x3 = os.getenv("FRUIT_JAM_OS_4x3", 0) |
58 |
| - |
59 |
| -if aspect_ratio_4x3: |
60 |
| - request_display_config(640, 480) |
61 |
| -else: |
62 |
| - request_display_config(720, 400) |
63 | 56 | display = supervisor.runtime.display
|
| 57 | +if display is None: |
| 58 | + width_config = os.getenv("CIRCUITPY_DISPLAY_WIDTH") |
| 59 | + if width_config is None: |
| 60 | + request_display_config(720, 400) |
| 61 | + elif width_config in [x[0] for x in VALID_DISPLAY_SIZES]: |
| 62 | + for display_size in VALID_DISPLAY_SIZES: |
| 63 | + if display_size[0] == width_config: |
| 64 | + request_display_config(*display_size) |
| 65 | + break |
| 66 | + else: |
| 67 | + raise ValueError(f"Invalid display size. Must be one of: {VALID_DISPLAY_SIZES}") |
64 | 68 |
|
65 | 69 | scale = 1
|
66 | 70 | if display.width > 360:
|
|
142 | 146 |
|
143 | 147 | mouse_buf = array.array("b", [0] * 8)
|
144 | 148 |
|
145 |
| -if aspect_ratio_4x3: |
146 |
| - WIDTH = 248 |
147 |
| - HEIGHT = 218 |
148 |
| -else: |
149 |
| - WIDTH = 280 |
150 |
| - HEIGHT = 182 |
| 149 | +WIDTH = int(280 / 360 * display.width // scale) |
| 150 | +HEIGHT = int(182 / 200 * display.height // scale) |
151 | 151 |
|
152 | 152 | config = {
|
153 | 153 | "menu_title": "Launcher Menu",
|
|
0 commit comments