Skip to content

Commit

Permalink
Merge pull request #6088 from dhalbert/merge-7.2.x-to-main
Browse files Browse the repository at this point in the history
Merge 7.2.x to main
  • Loading branch information
tannewt authored Feb 25, 2022
2 parents f39c2b2 + a45f9a8 commit c68b7a2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion setup.py-stubs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ setup(
"root": "..",
"relative_to": __file__,
"local_scheme": local_scheme,
"git_describe_command": "tools/describe",
"git_describe_command": "tools/describe --long",
},
zip_safe=False,
)
3 changes: 2 additions & 1 deletion shared-module/displayio/display_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ bool displayio_display_core_show(displayio_display_core_t *self, displayio_group
// force the circuit_python_splash out of any group (Note: could cause problems with the parent group)
circuitpython_splash.x = 0; // reset position in case someone moved it.
circuitpython_splash.y = 0;
supervisor_stop_terminal();

supervisor_start_terminal(self->width, self->height);

root_group = &circuitpython_splash;
}
if (root_group == self->current_group) {
Expand Down
1 change: 0 additions & 1 deletion shared-module/terminalio/Terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ void common_hal_terminalio_terminal_construct(terminalio_terminal_obj_t *self, d
self->font = font;
self->tilegrid = tilegrid;
self->first_row = 0;

for (uint16_t x = 0; x < self->tilegrid->width_in_tiles; x++) {
for (uint16_t y = 0; y < self->tilegrid->height_in_tiles; y++) {
common_hal_displayio_tilegrid_set_tile(self->tilegrid, x, y, 0);
Expand Down
44 changes: 28 additions & 16 deletions supervisor/shared/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
#if CIRCUITPY_TERMINALIO
displayio_tilegrid_t *grid = &supervisor_terminal_text_grid;
bool tall = height_px > width_px;
bool reset_tiles = false;
uint16_t terminal_width_px = tall ? width_px : width_px - blinka_bitmap.width;
uint16_t terminal_height_px = tall ? height_px - blinka_bitmap.height : height_px;
uint16_t width_in_tiles = terminal_width_px / grid->tile_width;
Expand All @@ -81,37 +82,48 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {

uint16_t total_tiles = width_in_tiles * height_in_tiles;

// check if the terminal tile dimensions are the same
if ((grid->width_in_tiles != width_in_tiles) ||
(grid->height_in_tiles != height_in_tiles)) {
reset_tiles = true;
}
// Reuse the previous allocation if possible
if (tilegrid_tiles) {
if (get_allocation_length(tilegrid_tiles) != align32_size(total_tiles)) {
free_memory(tilegrid_tiles);
tilegrid_tiles = NULL;
reset_tiles = true;
}
}
if (!tilegrid_tiles) {
tilegrid_tiles = allocate_memory(align32_size(total_tiles), false, true);
reset_tiles = true;
if (!tilegrid_tiles) {
return;
}
}
uint8_t *tiles = (uint8_t *)tilegrid_tiles->ptr;

grid->y = tall ? blinka_bitmap.height : 0;
grid->x = tall ? 0 : blinka_bitmap.width;
grid->top_left_y = 0;
if (remaining_pixels > 0) {
grid->y -= (grid->tile_height - remaining_pixels);
}
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;
grid->full_change = true;
if (reset_tiles) {
uint8_t *tiles = (uint8_t *)tilegrid_tiles->ptr;

grid->y = tall ? blinka_bitmap.height : 0;
grid->x = tall ? 0 : blinka_bitmap.width;
grid->top_left_y = 0;
if (remaining_pixels > 0) {
grid->y -= (grid->tile_height - remaining_pixels);
}
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;

grid->full_change = true;

common_hal_terminalio_terminal_construct(&supervisor_terminal, grid, &supervisor_terminal_font);
common_hal_terminalio_terminal_construct(&supervisor_terminal, grid, &supervisor_terminal_font);
}
#endif

circuitpython_splash.scale = scale;
Expand Down
3 changes: 2 additions & 1 deletion tools/describe
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh
git describe --first-parent --dirty --tags --always --match "[1-9].*"
# Add any supplied arguments.
git describe --first-parent --dirty --tags --always --match "[1-9].*" "$@"

0 comments on commit c68b7a2

Please sign in to comment.