diff options
Diffstat (limited to 'shared-module/displayio/Display.c')
| -rw-r--r-- | shared-module/displayio/Display.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 8ebe4b543..3936f3b17 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -44,7 +44,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, uint8_t set_column_command, uint8_t set_row_command, uint8_t write_ram_command, uint8_t set_vertical_scroll, uint8_t* init_sequence, uint16_t init_sequence_len, - const mcu_pin_obj_t* backlight_pin, bool init_cs_toggle) { + const mcu_pin_obj_t* backlight_pin, bool init_cs_toggle, bool single_byte_bounds) { self->color_depth = color_depth; self->set_column_command = set_column_command; self->set_row_command = set_row_command; @@ -55,6 +55,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, self->rowstart = rowstart; self->auto_brightness = false; self->init_cs_toggle = init_cs_toggle; + self->single_byte_bounds = single_byte_bounds; if (MP_OBJ_IS_TYPE(bus, &displayio_parallelbus_type)) { self->begin_transaction = common_hal_displayio_parallelbus_begin_transaction; @@ -218,16 +219,25 @@ void displayio_display_end_transaction(displayio_display_obj_t* self) { } void displayio_display_set_region_to_update(displayio_display_obj_t* self, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - // TODO(tannewt): Handle displays with single byte bounds. uint16_t data[2]; self->send(self->bus, true, &self->set_column_command, 1); - data[0] = __builtin_bswap16(x0 + self->colstart); - data[1] = __builtin_bswap16(x1 - 1 + self->colstart); - self->send(self->bus, false, (uint8_t*) data, 4); + if (self->single_byte_bounds) { + data[0] = __builtin_bswap16((x0 + self->colstart) << 8 | (x1 - 1 + self->colstart) && 0xFF); + self->send(self->bus, false, (uint8_t*) data, 2); + } else { + data[0] = __builtin_bswap16(x0 + self->colstart); + data[1] = __builtin_bswap16(x1 - 1 + self->colstart); + self->send(self->bus, false, (uint8_t*) data, 4); + } self->send(self->bus, true, &self->set_row_command, 1); - data[0] = __builtin_bswap16(y0 + self->rowstart); - data[1] = __builtin_bswap16(y1 - 1 + self->rowstart); - self->send(self->bus, false, (uint8_t*) data, 4); + if (self->single_byte_bounds) { + data[0] = __builtin_bswap16((y0 + self->rowstart) << 8 | (y1 - 1 + self->rowstart) && 0xFF); + self->send(self->bus, false, (uint8_t*) data, 2); + } else { + data[0] = __builtin_bswap16(y0 + self->rowstart); + data[1] = __builtin_bswap16(y1 - 1 + self->rowstart); + self->send(self->bus, false, (uint8_t*) data, 4); + } self->send(self->bus, true, &self->write_ram_command, 1); } |
