Skip to content

Improved readability of Single Byte Bounds code #1731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions shared-module/displayio/Display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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);
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;
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);
Expand Down