Skip to content

Commit 8b4ca24

Browse files
author
Melissa LeBlanc-Williams
committed
Improved readability of Single Byte Bounds code
1 parent bd4a156 commit 8b4ca24

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

shared-module/displayio/Display.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,21 +212,27 @@ void displayio_display_end_transaction(displayio_display_obj_t* self) {
212212
}
213213

214214
void displayio_display_set_region_to_update(displayio_display_obj_t* self, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
215-
uint16_t data[2];
215+
216216
self->send(self->bus, true, &self->set_column_command, 1);
217217
if (self->single_byte_bounds) {
218-
data[0] = __builtin_bswap16(((x0 + self->colstart) << 8) | ((x1 - 1 + self->colstart) & 0xFF));
218+
uint8_t data[2];
219+
data[0] = (x0 + self->colstart) & 0xFF;
220+
data[1] = (x1 - 1 + self->colstart) & 0xFF;
219221
self->send(self->bus, false, (uint8_t*) data, 2);
220222
} else {
223+
uint16_t data[2];
221224
data[0] = __builtin_bswap16(x0 + self->colstart);
222225
data[1] = __builtin_bswap16(x1 - 1 + self->colstart);
223226
self->send(self->bus, false, (uint8_t*) data, 4);
224227
}
225228
self->send(self->bus, true, &self->set_row_command, 1);
226229
if (self->single_byte_bounds) {
227-
data[0] = __builtin_bswap16(((y0 + self->rowstart) << 8) | ((y1 - 1 + self->rowstart) & 0xFF));
230+
uint8_t data[2];
231+
data[0] = (y0 + self->rowstart) & 0xFF;
232+
data[1] = (y1 - 1 + self->rowstart) & 0xFF;
228233
self->send(self->bus, false, (uint8_t*) data, 2);
229234
} else {
235+
uint16_t data[2];
230236
data[0] = __builtin_bswap16(y0 + self->rowstart);
231237
data[1] = __builtin_bswap16(y1 - 1 + self->rowstart);
232238
self->send(self->bus, false, (uint8_t*) data, 4);

0 commit comments

Comments
 (0)