From f21dc253e094854670b829f6258aac3722eefc26 Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Mon, 21 Sep 2020 18:42:16 -0400 Subject: [PATCH 01/11] Initial commit bool column_and_page_addressing --- shared-bindings/displayio/Display.c | 5 ++++- shared-bindings/displayio/Display.h | 3 ++- shared-module/displayio/Display.c | 4 +++- shared-module/displayio/Display.h | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index f36aeed18c..634156f561 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -105,6 +105,7 @@ //| :param bool auto_brightness: If True, brightness is controlled via an ambient light sensor or other mechanism. //| :param bool single_byte_bounds: Display column and row commands use single bytes //| :param bool data_as_commands: Treat all init and boundary data as SPI commands. Certain displays require this. +//| :param bool column_and_page_addressing: Special quirk for SH1107, use upper/lower column set and page set //| :param bool auto_refresh: Automatically refresh the screen //| :param int native_frames_per_second: Number of display refreshes per second that occur with the given init_sequence. //| :param bool backlight_on_high: If True, pulling the backlight pin high turns the backlight on.""" @@ -139,6 +140,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_auto_refresh, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} }, { MP_QSTR_native_frames_per_second, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 60} }, { MP_QSTR_backlight_on_high, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} }, + { MP_QSTR_column_and_page_addressing, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -180,7 +182,8 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a args[ARG_data_as_commands].u_bool, args[ARG_auto_refresh].u_bool, args[ARG_native_frames_per_second].u_int, - args[ARG_backlight_on_high].u_bool + args[ARG_backlight_on_high].u_bool, + args[ARG_column_and_page_addressing].u_bool ); return self; diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h index e69c5b6b52..d6274a2b24 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/displayio/Display.h @@ -45,7 +45,8 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, uint8_t set_column_command, uint8_t set_row_command, uint8_t write_ram_command, uint8_t set_vertical_scroll, uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command, mp_float_t brightness, bool auto_brightness, - bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, bool backlight_on_high); + bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, + bool backlight_on_high, bool column_and_page_addressing); bool common_hal_displayio_display_show(displayio_display_obj_t* self, displayio_group_t* root_group); diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 021159c0d9..d3e7ee175c 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -48,7 +48,8 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, uint8_t set_row_command, uint8_t write_ram_command, uint8_t set_vertical_scroll, uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command, mp_float_t brightness, bool auto_brightness, - bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, bool backlight_on_high) { + bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, + bool backlight_on_high), bool column_and_page_addressing { // Turn off auto-refresh as we init. self->auto_refresh = false; uint16_t ram_width = 0x100; @@ -68,6 +69,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, self->first_manual_refresh = !auto_refresh; self->data_as_commands = data_as_commands; self->backlight_on_high = backlight_on_high; + self->column_and_page_addressing = column_and_page_addressing; self->native_frames_per_second = native_frames_per_second; self->native_ms_per_frame = 1000 / native_frames_per_second; diff --git a/shared-module/displayio/Display.h b/shared-module/displayio/Display.h index bdb861aa09..86c2a93604 100644 --- a/shared-module/displayio/Display.h +++ b/shared-module/displayio/Display.h @@ -60,6 +60,8 @@ typedef struct { bool auto_brightness; bool updating_backlight; bool backlight_on_high; + // new quirk for sh1107 + bool column_and_page_addressing; } displayio_display_obj_t; void displayio_display_background(displayio_display_obj_t* self); From 08189edf247244c616b0bd4c58fdb678b6c53d0e Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Mon, 21 Sep 2020 21:07:42 -0400 Subject: [PATCH 02/11] Quirk coded up for ...set_region_to_update --- shared-module/displayio/Display.c | 2 +- shared-module/displayio/display_core.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index d3e7ee175c..b0806af291 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -49,7 +49,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command, mp_float_t brightness, bool auto_brightness, bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, - bool backlight_on_high), bool column_and_page_addressing { + bool backlight_on_high, bool column_and_page_addressing) { // Turn off auto-refresh as we init. self->auto_refresh = false; uint16_t ram_width = 0x100; diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 43f2d19375..f046ab9e48 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -253,8 +253,16 @@ 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 "column_and_page_addressing" + // Column lower command = 0x00, Column upper command = 0x10 + if (column_and_page_addressing) { + data[0] = 0x00 | (x1 & 0x0F); + data[1] = 0x10 | (x1 >> 4); + data_length = 2; + } self->send(self->bus, data_type, chip_select, data, data_length); displayio_display_core_end_transaction(self); + if (set_current_column_command != NO_COMMAND) { uint8_t command = set_current_column_command; displayio_display_core_begin_transaction(self); @@ -283,6 +291,14 @@ 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 "column_and_page_addressing" + // Page address command = 0xB0 + if (column_and_page_addressing) { + data[0] = 0xB0 | (y1 & 0x07); + data_length = 1; + } + self->send(self->bus, data_type, chip_select, data, data_length); + self->send(self->bus, data_type, chip_select, data, data_length); displayio_display_core_end_transaction(self); From 5536e574dba604b86ef5f6e8c4d86bc408ef8ac5 Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Mon, 21 Sep 2020 22:08:16 -0400 Subject: [PATCH 03/11] Changes to compile cleanly --- .gitignore | 1 + shared-bindings/displayio/Display.c | 2 +- shared-module/displayio/Display.c | 4 +++- shared-module/displayio/EPaperDisplay.c | 4 +++- shared-module/displayio/display_core.c | 5 ++++- shared-module/displayio/display_core.h | 5 ++++- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 03cd38f35d..a8814be45e 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,7 @@ TAGS *.mo .vscode +.idea # Python Virtual Environments #################### diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 634156f561..2ae2373505 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -112,7 +112,7 @@ //| ... //| STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word, ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands, ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high }; + enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word, ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands, ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high, ARG_column_and_page_addressing }; static const mp_arg_t allowed_args[] = { { MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_init_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index b0806af291..b6979c0b2d 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -288,7 +288,9 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t* } remaining_rows -= rows_per_buffer; - displayio_display_core_set_region_to_update(&self->core, self->set_column_command, self->set_row_command, NO_COMMAND, NO_COMMAND, self->data_as_commands, false, &subrectangle); + displayio_display_core_set_region_to_update(&self->core, self->set_column_command, + self->set_row_command, NO_COMMAND, NO_COMMAND, self->data_as_commands, false, + &subrectangle, self->column_and_page_addressing); uint16_t subrectangle_size_bytes; if (self->core.colorspace.depth >= 8) { diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index 6d9e915b44..397ceb4fdc 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -239,7 +239,9 @@ bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t* self, c uint16_t remaining_rows = displayio_area_height(&clipped); if (self->set_row_window_command != NO_COMMAND) { - displayio_display_core_set_region_to_update(&self->core, self->set_column_window_command, self->set_row_window_command, self->set_current_column_command, self->set_current_row_command, false, self->chip_select, &clipped); + displayio_display_core_set_region_to_update(&self->core, self->set_column_window_command, + self->set_row_window_command, self->set_current_column_command, self->set_current_row_command, + false, self->chip_select, &clipped, false); } uint8_t write_command = self->write_black_ram_command; diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index f046ab9e48..f01fda092b 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -208,7 +208,10 @@ void displayio_display_core_end_transaction(displayio_display_core_t* self) { self->end_transaction(self->bus); } -void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_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, displayio_area_t* area) { +void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_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, + displayio_area_t* area, bool column_and_page_addressing) { uint16_t x1 = area->x1; uint16_t x2 = area->x2; uint16_t y1 = area->y1; diff --git a/shared-module/displayio/display_core.h b/shared-module/displayio/display_core.h index e4fd62d4a5..1c880be443 100644 --- a/shared-module/displayio/display_core.h +++ b/shared-module/displayio/display_core.h @@ -74,7 +74,10 @@ bool displayio_display_core_bus_free(displayio_display_core_t *self); bool displayio_display_core_begin_transaction(displayio_display_core_t* self); void displayio_display_core_end_transaction(displayio_display_core_t* self); -void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_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, displayio_area_t* area); +void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_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, + displayio_area_t* area, bool column_and_page_addressing); void release_display_core(displayio_display_core_t* self); From 5a176c2c67cff17415d1a713ed2ee3cbf94dd020 Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Tue, 22 Sep 2020 13:41:25 -0400 Subject: [PATCH 04/11] Removed redundant send of page setting --- shared-module/displayio/display_core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index f01fda092b..19e45e6b6f 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -302,7 +302,6 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t* self, } self->send(self->bus, data_type, chip_select, data, data_length); - self->send(self->bus, data_type, chip_select, data, data_length); displayio_display_core_end_transaction(self); if (set_current_row_command != NO_COMMAND) { From 06a3d152664a97cc0a2f2faee86d2f5ea4e063e2 Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Thu, 24 Sep 2020 22:07:33 -0400 Subject: [PATCH 05/11] Mostly-working-version with comments --- shared-bindings/displayio/Display.c | 18 +++++++++---- shared-bindings/displayio/Display.h | 2 +- shared-module/displayio/Display.c | 36 ++++++++++++++++++++----- shared-module/displayio/Display.h | 2 +- shared-module/displayio/EPaperDisplay.c | 1 + shared-module/displayio/display_core.c | 33 ++++++++++++----------- shared-module/displayio/display_core.h | 2 +- 7 files changed, 64 insertions(+), 30 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 2ae2373505..a81736e469 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -105,14 +105,22 @@ //| :param bool auto_brightness: If True, brightness is controlled via an ambient light sensor or other mechanism. //| :param bool single_byte_bounds: Display column and row commands use single bytes //| :param bool data_as_commands: Treat all init and boundary data as SPI commands. Certain displays require this. -//| :param bool column_and_page_addressing: Special quirk for SH1107, use upper/lower column set and page set +//| :param bool SH1107_addressing: Special quirk for SH1107, use upper/lower column set and page set //| :param bool auto_refresh: Automatically refresh the screen //| :param int native_frames_per_second: Number of display refreshes per second that occur with the given init_sequence. //| :param bool backlight_on_high: If True, pulling the backlight pin high turns the backlight on.""" //| ... //| -STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word, ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands, ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high, ARG_column_and_page_addressing }; +STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, + const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, + ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, + ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word, + ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, + ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, + ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands, + ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high, + ARG_SH1107_addressing }; static const mp_arg_t allowed_args[] = { { MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_init_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -140,7 +148,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_auto_refresh, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} }, { MP_QSTR_native_frames_per_second, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 60} }, { MP_QSTR_backlight_on_high, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} }, - { MP_QSTR_column_and_page_addressing, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, + { MP_QSTR_SH1107_addressing, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} } }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -183,7 +191,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a args[ARG_auto_refresh].u_bool, args[ARG_native_frames_per_second].u_int, args[ARG_backlight_on_high].u_bool, - args[ARG_column_and_page_addressing].u_bool + args[ARG_SH1107_addressing].u_bool ); return self; diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h index d6274a2b24..c1704eaada 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/displayio/Display.h @@ -46,7 +46,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command, mp_float_t brightness, bool auto_brightness, bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, - bool backlight_on_high, bool column_and_page_addressing); + bool backlight_on_high, bool SH1107_addressing); bool common_hal_displayio_display_show(displayio_display_obj_t* self, displayio_group_t* root_group); diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index b6979c0b2d..afc4b7564c 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -49,7 +49,8 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command, mp_float_t brightness, bool auto_brightness, bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, - bool backlight_on_high, bool column_and_page_addressing) { + bool backlight_on_high, bool SH1107_addressing) { + // Turn off auto-refresh as we init. self->auto_refresh = false; uint16_t ram_width = 0x100; @@ -69,7 +70,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, self->first_manual_refresh = !auto_refresh; self->data_as_commands = data_as_commands; self->backlight_on_high = backlight_on_high; - self->column_and_page_addressing = column_and_page_addressing; + self->SH1107_addressing = SH1107_addressing; self->native_frames_per_second = native_frames_per_second; self->native_ms_per_frame = 1000 / native_frames_per_second; @@ -242,11 +243,23 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t* if (!displayio_display_core_clip_area(&self->core, area, &clipped)) { return true; } - uint16_t subrectangles = 1; uint16_t rows_per_buffer = displayio_area_height(&clipped); uint8_t pixels_per_word = (sizeof(uint32_t) * 8) / self->core.colorspace.depth; uint16_t pixels_per_buffer = displayio_area_size(&clipped); - if (displayio_area_size(&clipped) > buffer_size * pixels_per_word) { + + uint16_t subrectangles = 1; + // 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) + } + + // Skip this recalculation of subrectangles if SH1107 (each subrectangle is a single row) + // [mdroberts1243] I am worried/confused about the pixels_in_byte_share_row calculation though + // since it makes sense to be on a byte boundary (actually a page boundary too) + // seems to work as is though. + if ((displayio_area_size(&clipped) > buffer_size * pixels_per_word) + && (!self->SH1107_addressing)) { rows_per_buffer = buffer_size * pixels_per_word / displayio_area_width(&clipped); if (rows_per_buffer == 0) { rows_per_buffer = 1; @@ -283,14 +296,23 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t* .x2 = clipped.x2, .y2 = clipped.y1 + rows_per_buffer * (j + 1) }; - if (remaining_rows < rows_per_buffer) { + if (self->SH1107_addressing) { + // one row only for SH1107 in vertical (column) mode + subrectangle.y1 = clipped.y1 + j; + subrectangle.y2 = clipped.y1 + (j + 1); + }; + if ((remaining_rows < rows_per_buffer) && (!self->SH1107_addressing)) { subrectangle.y2 = subrectangle.y1 + remaining_rows; } - remaining_rows -= rows_per_buffer; + if (self->SH1107_addressing) { + remaining_rows -= 1; + } else { + remaining_rows -= rows_per_buffer; + } displayio_display_core_set_region_to_update(&self->core, self->set_column_command, self->set_row_command, NO_COMMAND, NO_COMMAND, self->data_as_commands, false, - &subrectangle, self->column_and_page_addressing); + &subrectangle, self->SH1107_addressing); uint16_t subrectangle_size_bytes; if (self->core.colorspace.depth >= 8) { diff --git a/shared-module/displayio/Display.h b/shared-module/displayio/Display.h index 86c2a93604..cc9cd54c40 100644 --- a/shared-module/displayio/Display.h +++ b/shared-module/displayio/Display.h @@ -61,7 +61,7 @@ typedef struct { bool updating_backlight; bool backlight_on_high; // new quirk for sh1107 - bool column_and_page_addressing; + bool SH1107_addressing; } displayio_display_obj_t; void displayio_display_background(displayio_display_obj_t* self); diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index 397ceb4fdc..3391a56b4d 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -238,6 +238,7 @@ bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t* self, c for (uint8_t pass = 0; pass < passes; pass++) { uint16_t remaining_rows = displayio_area_height(&clipped); + // added false parameter at end for SH1107_addressing quirk if (self->set_row_window_command != NO_COMMAND) { displayio_display_core_set_region_to_update(&self->core, self->set_column_window_command, self->set_row_window_command, self->set_current_column_command, self->set_current_row_command, diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 19e45e6b6f..4e36e4dd1f 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -41,7 +41,7 @@ #include #define DISPLAYIO_CORE_DEBUG(...) (void)0 -// #define DISPLAYIO_CORE_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) +//#define DISPLAYIO_CORE_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) void displayio_display_core_construct(displayio_display_core_t* self, mp_obj_t bus, uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation, @@ -57,7 +57,7 @@ void displayio_display_core_construct(displayio_display_core_t* self, self->colstart = colstart; self->rowstart = rowstart; self->last_refresh = 0; - + // (framebufferdisplay already validated its 'bus' is a buffer-protocol object) if (bus) { if (MP_OBJ_IS_TYPE(bus, &displayio_parallelbus_type)) { @@ -211,7 +211,7 @@ void displayio_display_core_end_transaction(displayio_display_core_t* self) { void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_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, - displayio_area_t* area, bool column_and_page_addressing) { + displayio_area_t* area, bool SH1107_addressing) { uint16_t x1 = area->x1; uint16_t x2 = area->x2; uint16_t y1 = area->y1; @@ -256,12 +256,13 @@ 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 "column_and_page_addressing" - // Column lower command = 0x00, Column upper command = 0x10 - if (column_and_page_addressing) { - data[0] = 0x00 | (x1 & 0x0F); - data[1] = 0x10 | (x1 >> 4); - data_length = 2; + // Quirk for SH1107 "SH1107_addressing" + // Note... column is y! page is x! + // Page address command = 0xB0 + if (SH1107_addressing) { + // set the page to our x value + data[0] = 0xB0 | (x1 & 0x07); + data_length = 1; } self->send(self->bus, data_type, chip_select, data, data_length); displayio_display_core_end_transaction(self); @@ -294,11 +295,13 @@ 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 "column_and_page_addressing" - // Page address command = 0xB0 - if (column_and_page_addressing) { - data[0] = 0xB0 | (y1 & 0x07); - data_length = 1; + // 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); @@ -319,7 +322,7 @@ void displayio_display_core_start_refresh(displayio_display_core_t* self) { void displayio_display_core_finish_refresh(displayio_display_core_t* self) { if (self->current_group != NULL) { - DISPLAYIO_CORE_DEBUG("displayiocore group_finish_refresh\n"); +// DISPLAYIO_CORE_DEBUG("displayiocore group_finish_refresh\n"); displayio_group_finish_refresh(self->current_group); } self->full_refresh = false; diff --git a/shared-module/displayio/display_core.h b/shared-module/displayio/display_core.h index 1c880be443..ad9998a2f8 100644 --- a/shared-module/displayio/display_core.h +++ b/shared-module/displayio/display_core.h @@ -77,7 +77,7 @@ void displayio_display_core_end_transaction(displayio_display_core_t* self); void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_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, - displayio_area_t* area, bool column_and_page_addressing); + displayio_area_t* area, bool SH1107_addressing); void release_display_core(displayio_display_core_t* self); From 19dbff67f2a4921ccbe06fdf29e229225e8aed2d Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Fri, 25 Sep 2020 00:26:39 -0400 Subject: [PATCH 06/11] Fixed page set mask to be four bits! --- shared-module/displayio/display_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 4e36e4dd1f..6e05b47571 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -261,7 +261,7 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t* self, // Page address command = 0xB0 if (SH1107_addressing) { // set the page to our x value - data[0] = 0xB0 | (x1 & 0x07); + data[0] = 0xB0 | (x1 & 0x0F); data_length = 1; } self->send(self->bus, data_type, chip_select, data, data_length); From b92154357145f4e7d976306490ef33b5d5fe9c92 Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Fri, 25 Sep 2020 21:27:29 -0400 Subject: [PATCH 07/11] Requested changes take 1 --- .../boards/hallowing_m0_express/board.c | 3 ++- .../boards/hallowing_m4_express/board.c | 3 ++- ports/atmel-samd/boards/monster_m4sk/board.c | 3 ++- ports/atmel-samd/boards/pewpew_m4/board.c | 3 ++- ports/atmel-samd/boards/pybadge/board.c | 3 ++- .../atmel-samd/boards/pybadge_airlift/board.c | 3 ++- ports/atmel-samd/boards/pygamer/board.c | 3 ++- .../atmel-samd/boards/pygamer_advance/board.c | 3 ++- ports/atmel-samd/boards/pyportal/board.c | 3 ++- .../atmel-samd/boards/pyportal_titano/board.c | 3 ++- .../boards/seeeduino_wio_terminal/board.c | 3 ++- .../nrf/boards/clue_nrf52840_express/board.c | 3 ++- ports/nrf/boards/hiibot_bluefi/board.c | 3 ++- .../makerdiary_nrf52840_m2_devkit/board.c | 3 ++- ports/nrf/boards/ohs2020_badge/board.c | 3 ++- ports/stm/boards/meowbit_v121/board.c | 3 ++- shared-module/displayio/Display.c | 25 ++++++------------- shared-module/displayio/display_core.c | 4 +-- 18 files changed, 41 insertions(+), 36 deletions(-) diff --git a/ports/atmel-samd/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c index 4717e6ceb9..14a2bdb816 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c @@ -110,7 +110,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // not SH1107 } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/hallowing_m4_express/board.c b/ports/atmel-samd/boards/hallowing_m4_express/board.c index 7da1d8128c..61e797d652 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m4_express/board.c @@ -91,7 +91,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // not SH1107 } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/monster_m4sk/board.c b/ports/atmel-samd/boards/monster_m4sk/board.c index 4dd65f8c90..45fea9d529 100644 --- a/ports/atmel-samd/boards/monster_m4sk/board.c +++ b/ports/atmel-samd/boards/monster_m4sk/board.c @@ -92,7 +92,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/pewpew_m4/board.c b/ports/atmel-samd/boards/pewpew_m4/board.c index 52a52b4b7d..d02e0dc01d 100644 --- a/ports/atmel-samd/boards/pewpew_m4/board.c +++ b/ports/atmel-samd/boards/pewpew_m4/board.c @@ -143,7 +143,8 @@ void board_init(void) { false, // data_as_commands false, // auto_refresh 20, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c index 45298acc27..35f228c75a 100644 --- a/ports/atmel-samd/boards/pybadge/board.c +++ b/ports/atmel-samd/boards/pybadge/board.c @@ -114,7 +114,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/pybadge_airlift/board.c b/ports/atmel-samd/boards/pybadge_airlift/board.c index 7495c7d48f..fe3e4a0171 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/board.c +++ b/ports/atmel-samd/boards/pybadge_airlift/board.c @@ -92,7 +92,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/pygamer/board.c b/ports/atmel-samd/boards/pygamer/board.c index 2e83440ea6..b478b5947c 100644 --- a/ports/atmel-samd/boards/pygamer/board.c +++ b/ports/atmel-samd/boards/pygamer/board.c @@ -114,7 +114,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/pygamer_advance/board.c b/ports/atmel-samd/boards/pygamer_advance/board.c index 330446b6ff..7dfe07c00d 100644 --- a/ports/atmel-samd/boards/pygamer_advance/board.c +++ b/ports/atmel-samd/boards/pygamer_advance/board.c @@ -92,7 +92,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/pyportal/board.c b/ports/atmel-samd/boards/pyportal/board.c index d14b6b6a58..cd94f68875 100644 --- a/ports/atmel-samd/boards/pyportal/board.c +++ b/ports/atmel-samd/boards/pyportal/board.c @@ -100,7 +100,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/pyportal_titano/board.c b/ports/atmel-samd/boards/pyportal_titano/board.c index 0ee2e68aa2..dc417f5d14 100644 --- a/ports/atmel-samd/boards/pyportal_titano/board.c +++ b/ports/atmel-samd/boards/pyportal_titano/board.c @@ -117,7 +117,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c index b7fc736eb0..58d0beca85 100644 --- a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c +++ b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c @@ -105,7 +105,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/nrf/boards/clue_nrf52840_express/board.c b/ports/nrf/boards/clue_nrf52840_express/board.c index 45452a35ea..523bd7677b 100644 --- a/ports/nrf/boards/clue_nrf52840_express/board.c +++ b/ports/nrf/boards/clue_nrf52840_express/board.c @@ -91,7 +91,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // not SH1107 } bool board_requests_safe_mode(void) { diff --git a/ports/nrf/boards/hiibot_bluefi/board.c b/ports/nrf/boards/hiibot_bluefi/board.c index 6b53cab139..93e31aef0c 100644 --- a/ports/nrf/boards/hiibot_bluefi/board.c +++ b/ports/nrf/boards/hiibot_bluefi/board.c @@ -92,7 +92,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c index e7f946f4d0..e08d00daca 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c +++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c @@ -92,7 +92,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/nrf/boards/ohs2020_badge/board.c b/ports/nrf/boards/ohs2020_badge/board.c index 9fcf9d2bff..ec52690ced 100644 --- a/ports/nrf/boards/ohs2020_badge/board.c +++ b/ports/nrf/boards/ohs2020_badge/board.c @@ -91,7 +91,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - false); // backlight_on_high + false, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/ports/stm/boards/meowbit_v121/board.c b/ports/stm/boards/meowbit_v121/board.c index b74f135165..f67b4a49db 100644 --- a/ports/stm/boards/meowbit_v121/board.c +++ b/ports/stm/boards/meowbit_v121/board.c @@ -111,7 +111,8 @@ void board_init(void) { false, // data_as_commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index afc4b7564c..9864e9f9d4 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -252,14 +252,8 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t* // write one single row at a time if (self->SH1107_addressing) { subrectangles = rows_per_buffer; // vertical (column mode) write each separately (height times) - } - - // Skip this recalculation of subrectangles if SH1107 (each subrectangle is a single row) - // [mdroberts1243] I am worried/confused about the pixels_in_byte_share_row calculation though - // since it makes sense to be on a byte boundary (actually a page boundary too) - // seems to work as is though. - if ((displayio_area_size(&clipped) > buffer_size * pixels_per_word) - && (!self->SH1107_addressing)) { + rows_per_buffer = 1; + } 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) { rows_per_buffer = 1; @@ -297,18 +291,13 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t* .y2 = clipped.y1 + rows_per_buffer * (j + 1) }; if (self->SH1107_addressing) { - // one row only for SH1107 in vertical (column) mode - subrectangle.y1 = clipped.y1 + j; - subrectangle.y2 = clipped.y1 + (j + 1); - }; - if ((remaining_rows < rows_per_buffer) && (!self->SH1107_addressing)) { + // one row only for SH1107 in vertical (column) mode + subrectangle.y1 = clipped.y1 + j; + subrectangle.y2 = clipped.y1 + (j + 1); + } else if (remaining_rows < rows_per_buffer) { subrectangle.y2 = subrectangle.y1 + remaining_rows; } - if (self->SH1107_addressing) { - remaining_rows -= 1; - } else { - remaining_rows -= rows_per_buffer; - } + remaining_rows -= rows_per_buffer; displayio_display_core_set_region_to_update(&self->core, self->set_column_command, self->set_row_command, NO_COMMAND, NO_COMMAND, self->data_as_commands, false, diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 6e05b47571..eb8c8f3b4a 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -41,7 +41,7 @@ #include #define DISPLAYIO_CORE_DEBUG(...) (void)0 -//#define DISPLAYIO_CORE_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) +// #define DISPLAYIO_CORE_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) void displayio_display_core_construct(displayio_display_core_t* self, mp_obj_t bus, uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation, @@ -322,7 +322,7 @@ void displayio_display_core_start_refresh(displayio_display_core_t* self) { void displayio_display_core_finish_refresh(displayio_display_core_t* self) { if (self->current_group != NULL) { -// DISPLAYIO_CORE_DEBUG("displayiocore group_finish_refresh\n"); + DISPLAYIO_CORE_DEBUG("displayiocore group_finish_refresh\n"); displayio_group_finish_refresh(self->current_group); } self->full_refresh = false; From 22a7696faca36bb1abdc938e06bcd5e25fb89f33 Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Fri, 25 Sep 2020 22:17:59 -0400 Subject: [PATCH 08/11] Changes take 2: missed ugame10 board --- ports/atmel-samd/boards/ugame10/board.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/atmel-samd/boards/ugame10/board.c b/ports/atmel-samd/boards/ugame10/board.c index 3bb9eab7de..9f2b8d039d 100644 --- a/ports/atmel-samd/boards/ugame10/board.c +++ b/ports/atmel-samd/boards/ugame10/board.c @@ -111,7 +111,8 @@ void board_init(void) { false, // data as commands true, // auto_refresh 60, // native_frames_per_second - true); // backlight_on_high + true, // backlight_on_high + false); // SH1107_addressing } bool board_requests_safe_mode(void) { From db74f97e60e58c22e6ce73bd068d9279e3daee57 Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Mon, 28 Sep 2020 19:10:47 -0400 Subject: [PATCH 09/11] modified _stage/__init__.c call to set region to update --- shared-module/_stage/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/_stage/__init__.c b/shared-module/_stage/__init__.c index 0323c32cb9..6dfc188801 100644 --- a/shared-module/_stage/__init__.c +++ b/shared-module/_stage/__init__.c @@ -45,7 +45,7 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, area.y2 = y1; displayio_display_core_set_region_to_update( &display->core, display->set_column_command, display->set_row_command, - NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area); + NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area, display->SH1107_addressing); while (!displayio_display_core_begin_transaction(&display->core)) { RUN_BACKGROUND_TASKS; From 9f19a8a7600ad59851953a7c0454d09245eadf4d Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Tue, 29 Sep 2020 15:37:06 -0400 Subject: [PATCH 10/11] Ran pre-commit locally --- shared-bindings/displayio/Display.c | 16 ++++++++-------- shared-bindings/displayio/Display.h | 2 +- shared-module/displayio/Display.c | 8 ++++---- shared-module/displayio/EPaperDisplay.c | 4 ++-- shared-module/displayio/display_core.c | 8 ++++---- shared-module/displayio/display_core.h | 6 +++--- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index a81736e469..e78a893b01 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -111,15 +111,15 @@ //| :param bool backlight_on_high: If True, pulling the backlight pin high turns the backlight on.""" //| ... //| -STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, +STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, - ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, - ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word, - ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, - ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, - ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands, - ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high, + enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, + ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, + ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word, + ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, + ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, + ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands, + ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high, ARG_SH1107_addressing }; static const mp_arg_t allowed_args[] = { { MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h index c1704eaada..f9fbc157c0 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/displayio/Display.h @@ -45,7 +45,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, uint8_t set_column_command, uint8_t set_row_command, uint8_t write_ram_command, uint8_t set_vertical_scroll, uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command, mp_float_t brightness, bool auto_brightness, - bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, + bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, bool backlight_on_high, bool SH1107_addressing); bool common_hal_displayio_display_show(displayio_display_obj_t* self, diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 9864e9f9d4..f2b8e04474 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -48,7 +48,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, uint8_t set_row_command, uint8_t write_ram_command, uint8_t set_vertical_scroll, uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command, mp_float_t brightness, bool auto_brightness, - bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, + bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, bool backlight_on_high, bool SH1107_addressing) { // Turn off auto-refresh as we init. @@ -246,7 +246,7 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t* uint16_t rows_per_buffer = displayio_area_height(&clipped); uint8_t pixels_per_word = (sizeof(uint32_t) * 8) / self->core.colorspace.depth; uint16_t pixels_per_buffer = displayio_area_size(&clipped); - + uint16_t subrectangles = 1; // for SH1107 and other boundary constrained controllers // write one single row at a time @@ -299,8 +299,8 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t* } remaining_rows -= rows_per_buffer; - displayio_display_core_set_region_to_update(&self->core, self->set_column_command, - self->set_row_command, NO_COMMAND, NO_COMMAND, self->data_as_commands, false, + displayio_display_core_set_region_to_update(&self->core, self->set_column_command, + self->set_row_command, NO_COMMAND, NO_COMMAND, self->data_as_commands, false, &subrectangle, self->SH1107_addressing); uint16_t subrectangle_size_bytes; diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index 3391a56b4d..5b055e62e4 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -240,8 +240,8 @@ bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t* self, c // added false parameter at end for SH1107_addressing quirk if (self->set_row_window_command != NO_COMMAND) { - displayio_display_core_set_region_to_update(&self->core, self->set_column_window_command, - self->set_row_window_command, self->set_current_column_command, self->set_current_row_command, + displayio_display_core_set_region_to_update(&self->core, self->set_column_window_command, + self->set_row_window_command, self->set_current_column_command, self->set_current_row_command, false, self->chip_select, &clipped, false); } diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index eb8c8f3b4a..c592202fba 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -57,7 +57,7 @@ void displayio_display_core_construct(displayio_display_core_t* self, self->colstart = colstart; self->rowstart = rowstart; self->last_refresh = 0; - + // (framebufferdisplay already validated its 'bus' is a buffer-protocol object) if (bus) { if (MP_OBJ_IS_TYPE(bus, &displayio_parallelbus_type)) { @@ -208,9 +208,9 @@ void displayio_display_core_end_transaction(displayio_display_core_t* self) { self->end_transaction(self->bus); } -void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_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, +void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_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, displayio_area_t* area, bool SH1107_addressing) { uint16_t x1 = area->x1; uint16_t x2 = area->x2; diff --git a/shared-module/displayio/display_core.h b/shared-module/displayio/display_core.h index ad9998a2f8..3b45f79464 100644 --- a/shared-module/displayio/display_core.h +++ b/shared-module/displayio/display_core.h @@ -74,9 +74,9 @@ bool displayio_display_core_bus_free(displayio_display_core_t *self); bool displayio_display_core_begin_transaction(displayio_display_core_t* self); void displayio_display_core_end_transaction(displayio_display_core_t* self); -void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_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, +void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_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, displayio_area_t* area, bool SH1107_addressing); void release_display_core(displayio_display_core_t* self); From ef245ef54ebab7c483a935dbfb100e2ab100f0ea Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Tue, 29 Sep 2020 19:48:14 -0400 Subject: [PATCH 11/11] Removed redundant subrectangle sizing code --- shared-module/displayio/Display.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index f2b8e04474..37d72a82f2 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -290,11 +290,7 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t* .x2 = clipped.x2, .y2 = clipped.y1 + rows_per_buffer * (j + 1) }; - if (self->SH1107_addressing) { - // one row only for SH1107 in vertical (column) mode - subrectangle.y1 = clipped.y1 + j; - subrectangle.y2 = clipped.y1 + (j + 1); - } else if (remaining_rows < rows_per_buffer) { + if (remaining_rows < rows_per_buffer) { subrectangle.y2 = subrectangle.y1 + remaining_rows; } remaining_rows -= rows_per_buffer;