Merge pull request #6077 from kmatch98/trial_repl
fix REPL terminal garbled characters upon code.py finished
This commit is contained in:
commit
aeeb58fd45
@ -62,7 +62,7 @@ STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n
|
||||
terminalio_terminal_obj_t *self = m_new_obj(terminalio_terminal_obj_t);
|
||||
self->base.type = &terminalio_terminal_type;
|
||||
|
||||
common_hal_terminalio_terminal_construct(self, tilegrid, font, true);
|
||||
common_hal_terminalio_terminal_construct(self, tilegrid, font);
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
extern const mp_obj_type_t terminalio_terminal_type;
|
||||
|
||||
extern void common_hal_terminalio_terminal_construct(terminalio_terminal_obj_t *self,
|
||||
displayio_tilegrid_t *tilegrid, const fontio_builtinfont_t *font, const bool reset_tiles);
|
||||
displayio_tilegrid_t *tilegrid, const fontio_builtinfont_t *font);
|
||||
|
||||
// Write characters. len is in characters NOT bytes!
|
||||
extern size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self,
|
||||
|
@ -30,18 +30,15 @@
|
||||
#include "shared-bindings/displayio/TileGrid.h"
|
||||
#include "shared-bindings/terminalio/Terminal.h"
|
||||
|
||||
void common_hal_terminalio_terminal_construct(terminalio_terminal_obj_t *self, displayio_tilegrid_t *tilegrid, const fontio_builtinfont_t *font, const bool reset_tiles) {
|
||||
void common_hal_terminalio_terminal_construct(terminalio_terminal_obj_t *self, displayio_tilegrid_t *tilegrid, const fontio_builtinfont_t *font) {
|
||||
self->cursor_x = 0;
|
||||
self->cursor_y = 0;
|
||||
self->font = font;
|
||||
self->tilegrid = tilegrid;
|
||||
self->first_row = 0;
|
||||
|
||||
if (reset_tiles) {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,11 @@ 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)) {
|
||||
@ -97,24 +102,28 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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, reset_tiles);
|
||||
#endif
|
||||
|
||||
circuitpython_splash.scale = scale;
|
||||
|
Loading…
Reference in New Issue
Block a user