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
55
- request_display_config (720 , 400 )
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 )
56
63
display = supervisor .runtime .display
57
64
58
65
scale = 1
135
142
136
143
mouse_buf = array .array ("b" , [0 ] * 8 )
137
144
138
- WIDTH = 280
139
- HEIGHT = 182
145
+ if aspect_ratio_4x3 :
146
+ WIDTH = 248
147
+ HEIGHT = 218
148
+ else :
149
+ WIDTH = 280
150
+ HEIGHT = 182
140
151
141
152
config = {
142
153
"menu_title" : "Launcher Menu" ,
177
188
}
178
189
179
190
cell_width = WIDTH // config ["width" ]
191
+ cell_height = HEIGHT // config ["height" ]
180
192
181
193
default_icon_bmp , default_icon_palette = adafruit_imageload .load ("launcher_assets/default_icon.bmp" )
182
194
default_icon_palette .make_transparent (0 )
183
- menu_grid = GridLayout (x = 40 , y = 16 , width = WIDTH , height = HEIGHT , grid_size = (config ["width" ], config ["height" ]),
195
+ menu_grid = GridLayout (x = (display .width // scale - WIDTH ) // 2 ,
196
+ y = (display .height // scale - HEIGHT ) // 2 ,
197
+ width = WIDTH , height = HEIGHT , grid_size = (config ["width" ], config ["height" ]),
184
198
divider_lines = False )
185
199
scaled_group .append (menu_grid )
186
200
@@ -267,8 +281,9 @@ def _create_cell_group(app):
267
281
cell_group .append (icon_tg )
268
282
269
283
icon_tg .x = cell_width // 2 - icon_tg .tile_width // 2
270
- title_txt = TextBox (font , text = app ["title" ], width = WIDTH // config [ "width" ] , height = 18 ,
284
+ title_txt = TextBox (font , text = app ["title" ], width = cell_width , height = 18 ,
271
285
align = TextBox .ALIGN_CENTER )
286
+ icon_tg .y = (cell_height - icon_tg .tile_height - title_txt .height ) // 2
272
287
cell_group .append (title_txt )
273
288
title_txt .anchor_point = (0 , 0 )
274
289
title_txt .anchored_position = (0 , icon_tg .y + icon_tg .tile_height )
@@ -288,7 +303,7 @@ def _reuse_cell_group(app, cell_group):
288
303
icon_tg .pixel_shader = icon_palette
289
304
290
305
icon_tg .x = cell_width // 2 - icon_tg .tile_width // 2
291
- # title_txt = TextBox(font, text=app["title"], width=WIDTH // config["width"] , height=18,
306
+ # title_txt = TextBox(font, text=app["title"], width=cell_width , height=18,
292
307
# align=TextBox.ALIGN_CENTER)
293
308
# cell_group.append(title_txt)
294
309
title_txt = cell_group [1 ]
0 commit comments