From 8f1c25c8aeecba4d02e7811e5eb49afa96e1a412 Mon Sep 17 00:00:00 2001 From: lady ada Date: Sun, 6 Jun 2021 18:25:40 -0400 Subject: [PATCH] fix SH110x mode, the SH1107 is actually column not row mode BUT the SD1107 module we use is vertical orientation (confusing!) so row/col are NOT swapped. we will have to fix the SH1107 driver to match. this fix required for SH1106 (which uses the same page mode commands but ISNT rotated) --- shared-module/displayio/Display.c | 4 ++-- shared-module/displayio/display_core.c | 29 +++++++++++++------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 9117a50b78..c583ead54b 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -249,8 +249,8 @@ STATIC bool _refresh_area(displayio_display_obj_t *self, const displayio_area_t // for SH1107 and other boundary constrained controllers // write one single row at a time if (self->SH1107_addressing) { - subrectangles = rows_per_buffer; // vertical (column mode) write each separately (height times) - rows_per_buffer = 1; + subrectangles = rows_per_buffer/8; // vertical (column mode) write each separately (height times) + rows_per_buffer = 8; } else if (displayio_area_size(&clipped) > buffer_size * pixels_per_word) { rows_per_buffer = buffer_size * pixels_per_word / displayio_area_width(&clipped); if (rows_per_buffer == 0) { diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 5b4b20b344..86c104d9ad 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -260,14 +260,15 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self, data[data_length++] = x2 >> 8; data[data_length++] = x2 & 0xff; } + // Quirk for SH1107 "SH1107_addressing" - // Note... column is y! page is x! - // Page address command = 0xB0 + // Column lower command = 0x00, Column upper command = 0x10 if (SH1107_addressing) { - // set the page to our x value - data[0] = 0xB0 | (x1 & 0x0F); - data_length = 1; + data[0] = ((x1 >> 4) & 0x0F) | 0x10; // 0x10 to 0x17 + data[1] = x1 & 0x0F; // 0x00 to 0x0F + data_length = 2; } + self->send(self->bus, data_type, chip_select, data, data_length); displayio_display_core_end_transaction(self); @@ -299,16 +300,16 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self, data[data_length++] = y2 >> 8; data[data_length++] = y2 & 0xff; } - // Quirk for SH1107 "SH1107_addressing" - // Note... column is y! page is x! - // Column lower command = 0x00, Column upper command = 0x10 - if (SH1107_addressing) { - data[0] = y1 & 0x0F; // 0x00 to 0x0F - data[1] = (y1 >> 4 & 0x0F) | 0x10; // 0x10 to 0x17 - data_length = 2; - } - self->send(self->bus, data_type, chip_select, data, data_length); + // Quirk for SH1107 "SH1107_addressing" + // Page address command = 0xB0 + if (SH1107_addressing) { + // set the page to our y value + data[0] = 0xB0 | y1; + data_length = 1; + } + + self->send(self->bus, data_type, chip_select, data, data_length); displayio_display_core_end_transaction(self); if (set_current_row_command != NO_COMMAND) {