supervisor: Always allocate at least a 1x1 terminal

Otherwise, out of range writes would occur in tilegrid_set_tile, causing a safe mode reset.
```
Hardware watchpoint 6: -location *stack_alloc->ptr

Old value = 24652061
New value = 24641565
0x000444f2 in common_hal_displayio_tilegrid_set_tile (self=0x200002c8 <supervisor_terminal_text_grid>, x=1, y=1, tile_index=0 '\000')
    at ../../shared-module/displayio/TileGrid.c:236
236	    if (!self->partial_change) {
(gdb)
```
This commit is contained in:
Jeff Epler 2020-09-01 10:29:10 -05:00
parent 952d9bbb4a
commit 9bd2a61d8b

View File

@ -65,10 +65,14 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
if (width_in_tiles < 80) {
scale = 1;
}
width_in_tiles = (width_px - blinka_bitmap.width * scale) / (grid->tile_width * scale);
if (width_in_tiles < 1) {
width_in_tiles = 1;
}
uint16_t height_in_tiles = height_px / (grid->tile_height * scale);
uint16_t remaining_pixels = height_px % (grid->tile_height * scale);
if (remaining_pixels > 0) {
if (height_in_tiles < 1 || remaining_pixels > 0) {
height_in_tiles += 1;
}
@ -94,6 +98,8 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
}
grid->width_in_tiles = width_in_tiles;
grid->height_in_tiles = height_in_tiles;
assert(width_in_tiles > 0);
assert(height_in_tiles > 0);
grid->pixel_width = width_in_tiles * grid->tile_width;
grid->pixel_height = height_in_tiles * grid->tile_height;
grid->tiles = tiles;