From 8b4ca24e56b6d7a7c8c15ce30bb2272123bea95e Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Sun, 31 Mar 2019 14:17:54 -0700 Subject: [PATCH] Improved readability of Single Byte Bounds code --- shared-module/displayio/Display.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index c2c98853d3..df6af07b47 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -212,21 +212,27 @@ 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) { - uint16_t data[2]; + self->send(self->bus, true, &self->set_column_command, 1); if (self->single_byte_bounds) { - data[0] = __builtin_bswap16(((x0 + self->colstart) << 8) | ((x1 - 1 + self->colstart) & 0xFF)); + uint8_t data[2]; + data[0] = (x0 + self->colstart) & 0xFF; + data[1] = (x1 - 1 + self->colstart) & 0xFF; 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); if (self->single_byte_bounds) { - data[0] = __builtin_bswap16(((y0 + self->rowstart) << 8) | ((y1 - 1 + self->rowstart) & 0xFF)); + uint8_t data[2]; + data[0] = (y0 + self->rowstart) & 0xFF; + data[1] = (y1 - 1 + self->rowstart) & 0xFF; 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);