diff options
| author | Sabas <sabasjimenez@gmail.com> | 2019-04-02 23:15:56 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-02 23:15:56 -0600 |
| commit | 19c6b8aa0c572acb2212014e0a2e7e324efbb35d (patch) | |
| tree | fca6187f9f9703d1d8980a3383351b5da9ce3c08 /shared-module/displayio/Display.c | |
| parent | bb7bb80b4afbc62095e0d36a59e6b7ff1050c6f5 (diff) | |
| parent | 19278e0284f0339576b7fe9e0bdd6ad312da208a (diff) | |
Merge branch 'master' into master
Diffstat (limited to 'shared-module/displayio/Display.c')
| -rw-r--r-- | shared-module/displayio/Display.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 0e76a868f..eccb2d0ef 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) { + const mcu_pin_obj_t* backlight_pin, bool single_byte_bounds) { self->color_depth = color_depth; self->set_column_command = set_column_command; self->set_row_command = set_row_command; @@ -54,6 +54,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, self->colstart = colstart; self->rowstart = rowstart; self->auto_brightness = false; + 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; @@ -211,16 +212,31 @@ 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) { + uint8_t data[2]; + data[0] = x0 + self->colstart; + data[1] = x1 - 1 + self->colstart; + self->send(self->bus, false, (uint8_t*) data, 2); + } else { + uint16_t data[2]; + 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) { + uint8_t data[2]; + data[0] = y0 + self->rowstart; + data[1] = y1 - 1 + self->rowstart; + self->send(self->bus, false, (uint8_t*) data, 2); + } else { + uint16_t data[2]; + 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); } |
