supervisor_start_terminal: don't crash if display is tiny

Closes: #7222
This commit is contained in:
Jeff Epler 2022-11-17 10:31:36 -06:00
parent ef34378b1d
commit b0d0fcbabc
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE

View File

@ -74,11 +74,8 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
scale = 1; scale = 1;
} }
width_in_tiles = width_px / (scroll_area->tile_width * scale); width_in_tiles = MAX(1, width_px / (scroll_area->tile_width * scale));
if (width_in_tiles < 1) { uint16_t height_in_tiles = MAX(2, height_px / (scroll_area->tile_height * scale));
width_in_tiles = 1;
}
uint16_t height_in_tiles = height_px / (scroll_area->tile_height * scale);
uint16_t total_tiles = width_in_tiles * height_in_tiles; uint16_t total_tiles = width_in_tiles * height_in_tiles;
@ -117,7 +114,6 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
status_bar->top_left_y = 0; status_bar->top_left_y = 0;
status_bar->width_in_tiles = width_in_tiles; status_bar->width_in_tiles = width_in_tiles;
status_bar->height_in_tiles = 1; status_bar->height_in_tiles = 1;
assert(width_in_tiles > 0);
status_bar->pixel_width = width_in_tiles * status_bar->tile_width; status_bar->pixel_width = width_in_tiles * status_bar->tile_width;
status_bar->pixel_height = status_bar->tile_height; status_bar->pixel_height = status_bar->tile_height;
status_bar->tiles = tiles; status_bar->tiles = tiles;
@ -127,8 +123,6 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
scroll_area->top_left_y = 0; scroll_area->top_left_y = 0;
scroll_area->width_in_tiles = width_in_tiles; scroll_area->width_in_tiles = width_in_tiles;
scroll_area->height_in_tiles = height_in_tiles - 1; scroll_area->height_in_tiles = height_in_tiles - 1;
assert(width_in_tiles > 0);
assert(height_in_tiles > 1);
scroll_area->pixel_width = width_in_tiles * scroll_area->tile_width; scroll_area->pixel_width = width_in_tiles * scroll_area->tile_width;
scroll_area->pixel_height = (height_in_tiles - 1) * scroll_area->tile_height; scroll_area->pixel_height = (height_in_tiles - 1) * scroll_area->tile_height;
#if CIRCUITPY_REPL_LOGO #if CIRCUITPY_REPL_LOGO