Skip to content

Commit 2dda3df

Browse files
authored
Merge pull request adafruit#1731 from makermelissa/ssd1351-fix
Improved readability of Single Byte Bounds code
2 parents 367f658 + f1e4a2f commit 2dda3df

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;
220+
data[1] = x1 - 1 + self->colstart;
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;
232+
data[1] = y1 - 1 + self->rowstart;
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy