Skip to content

Commit 8f1c25c

Browse files
committed
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)
1 parent 01195c2 commit 8f1c25c

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

shared-module/displayio/Display.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ STATIC bool _refresh_area(displayio_display_obj_t *self, const displayio_area_t
249249
// for SH1107 and other boundary constrained controllers
250250
// write one single row at a time
251251
if (self->SH1107_addressing) {
252-
subrectangles = rows_per_buffer; // vertical (column mode) write each separately (height times)
253-
rows_per_buffer = 1;
252+
subrectangles = rows_per_buffer/8; // vertical (column mode) write each separately (height times)
253+
rows_per_buffer = 8;
254254
} else if (displayio_area_size(&clipped) > buffer_size * pixels_per_word) {
255255
rows_per_buffer = buffer_size * pixels_per_word / displayio_area_width(&clipped);
256256
if (rows_per_buffer == 0) {

shared-module/displayio/display_core.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,15 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self,
260260
data[data_length++] = x2 >> 8;
261261
data[data_length++] = x2 & 0xff;
262262
}
263+
263264
// Quirk for SH1107 "SH1107_addressing"
264-
// Note... column is y! page is x!
265-
// Page address command = 0xB0
265+
// Column lower command = 0x00, Column upper command = 0x10
266266
if (SH1107_addressing) {
267-
// set the page to our x value
268-
data[0] = 0xB0 | (x1 & 0x0F);
269-
data_length = 1;
267+
data[0] = ((x1 >> 4) & 0x0F) | 0x10; // 0x10 to 0x17
268+
data[1] = x1 & 0x0F; // 0x00 to 0x0F
269+
data_length = 2;
270270
}
271+
271272
self->send(self->bus, data_type, chip_select, data, data_length);
272273
displayio_display_core_end_transaction(self);
273274

@@ -299,16 +300,16 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self,
299300
data[data_length++] = y2 >> 8;
300301
data[data_length++] = y2 & 0xff;
301302
}
303+
302304
// Quirk for SH1107 "SH1107_addressing"
303-
// Note... column is y! page is x!
304-
// Column lower command = 0x00, Column upper command = 0x10
305+
// Page address command = 0xB0
305306
if (SH1107_addressing) {
306-
data[0] = y1 & 0x0F; // 0x00 to 0x0F
307-
data[1] = (y1 >> 4 & 0x0F) | 0x10; // 0x10 to 0x17
308-
data_length = 2;
307+
// set the page to our y value
308+
data[0] = 0xB0 | y1;
309+
data_length = 1;
309310
}
310-
self->send(self->bus, data_type, chip_select, data, data_length);
311311

312+
self->send(self->bus, data_type, chip_select, data, data_length);
312313
displayio_display_core_end_transaction(self);
313314

314315
if (set_current_row_command != NO_COMMAND) {

0 commit comments

Comments
 (0)