move the col/row offsets to the top so oleds can take advantage of em

This commit is contained in:
lady ada 2021-06-07 19:43:49 -04:00
parent 2ff9e9766f
commit b39dd84560

View File

@ -216,10 +216,11 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self,
uint8_t row_command, uint16_t set_current_column_command, uint16_t set_current_row_command, uint8_t row_command, uint16_t set_current_column_command, uint16_t set_current_row_command,
bool data_as_commands, bool always_toggle_chip_select, bool data_as_commands, bool always_toggle_chip_select,
displayio_area_t *area, bool SH1107_addressing) { displayio_area_t *area, bool SH1107_addressing) {
uint16_t x1 = area->x1; uint16_t x1 = area->x1 + self->colstart;
uint16_t x2 = area->x2; uint16_t x2 = area->x2 + self->colstart;
uint16_t y1 = area->y1; uint16_t y1 = area->y1 + self->rowstart;
uint16_t y2 = area->y2; uint16_t y2 = area->y2 + self->rowstart;
// Collapse down the dimension where multiple pixels are in a byte. // Collapse down the dimension where multiple pixels are in a byte.
if (self->colorspace.depth < 8) { if (self->colorspace.depth < 8) {
uint8_t pixels_per_byte = 8 / self->colorspace.depth; uint8_t pixels_per_byte = 8 / self->colorspace.depth;
@ -232,6 +233,9 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self,
} }
} }
x2 -= 1;
y2 -= 1;
display_chip_select_behavior_t chip_select = CHIP_SELECT_UNTOUCHED; display_chip_select_behavior_t chip_select = CHIP_SELECT_UNTOUCHED;
if (always_toggle_chip_select || data_as_commands) { if (always_toggle_chip_select || data_as_commands) {
chip_select = CHIP_SELECT_TOGGLE_EVERY_BYTE; chip_select = CHIP_SELECT_TOGGLE_EVERY_BYTE;
@ -249,12 +253,11 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self,
} else { } else {
data_type = DISPLAY_COMMAND; data_type = DISPLAY_COMMAND;
} }
if (self->ram_width < 0x100) { if (self->ram_width < 0x100) {
data[data_length++] = x1 + self->colstart; data[data_length++] = x1;
data[data_length++] = x2 - 1 + self->colstart; data[data_length++] = x2;
} else { } else {
x1 += self->colstart;
x2 += self->colstart - 1;
data[data_length++] = x1 >> 8; data[data_length++] = x1 >> 8;
data[data_length++] = x1 & 0xff; data[data_length++] = x1 & 0xff;
data[data_length++] = x2 >> 8; data[data_length++] = x2 >> 8;
@ -289,12 +292,11 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self,
self->send(self->bus, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, data, 1); self->send(self->bus, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, data, 1);
data_length = 0; data_length = 0;
} }
if (self->ram_height < 0x100) { if (self->ram_height < 0x100) {
data[data_length++] = y1 + self->rowstart; data[data_length++] = y1;
data[data_length++] = y2 - 1 + self->rowstart; data[data_length++] = y2;
} else { } else {
y1 += self->rowstart;
y2 += self->rowstart - 1;
data[data_length++] = y1 >> 8; data[data_length++] = y1 >> 8;
data[data_length++] = y1 & 0xff; data[data_length++] = y1 & 0xff;
data[data_length++] = y2 >> 8; data[data_length++] = y2 >> 8;