From d9de1b99263bcc906af35a78ac81a11fff9483ca Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Sun, 24 Mar 2019 08:23:46 -0700 Subject: [PATCH 1/3] Updated RTD comment to reflect new param defaulting True --- shared-bindings/displayio/Display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 8fed5129f9..9cefb95328 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -50,7 +50,7 @@ //| Most people should not use this class directly. Use a specific display driver instead that will //| contain the initialization sequence at minimum. //| -//| .. class:: Display(display_bus, init_sequence, *, width, height, colstart=0, rowstart=0, rotation=0, color_depth=16, set_column_command=0x2a, set_row_command=0x2b, write_ram_command=0x2c, set_vertical_scroll=0, backlight_pin=None, init_cs_toggle=False) +//| .. class:: Display(display_bus, init_sequence, *, width, height, colstart=0, rowstart=0, rotation=0, color_depth=16, set_column_command=0x2a, set_row_command=0x2b, write_ram_command=0x2c, set_vertical_scroll=0, backlight_pin=None, init_cs_toggle=True) //| //| Create a Display object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`). //| @@ -91,7 +91,7 @@ //| :param int write_ram_command: Command used to write pixels values into the update region //| :param int set_vertical_scroll: Command used to set the first row to show //| :param microcontroller.Pin backlight_pin: Pin connected to the display's backlight -//| :param bool init_cs_toggle: Toggle the Chip Select between each initialization command. +//| :param bool init_cs_toggle: Toggle the Chip Select between each initialization command //| 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_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin, ARG_init_cs_toggle }; From 09a1f06bbf6b333aaa3a76dbd93e0a5f5c9d7ef4 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 26 Mar 2019 07:39:40 -0700 Subject: [PATCH 2/3] Added small delay inside toggle for edge cases --- shared-module/displayio/Display.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 8ebe4b543f..bbc23b7b0a 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -85,6 +85,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, uint8_t *data = cmd + 2; if (self->init_cs_toggle && self->set_cs != NULL) { self->set_cs(self->bus, true); + common_hal_time_delay_ms(1); self->set_cs(self->bus, false); } self->send(self->bus, true, cmd, 1); From b2ad16f5c84cd4dc853114e5fc526ab1827580a4 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 26 Mar 2019 18:34:07 -0700 Subject: [PATCH 3/3] Removed parameter so CS is always toggled --- ports/atmel-samd/boards/hallowing_m0_express/board.c | 3 +-- ports/atmel-samd/boards/pybadge/board.c | 3 +-- ports/atmel-samd/boards/pyportal/board.c | 3 +-- shared-bindings/displayio/Display.c | 6 ++---- shared-bindings/displayio/Display.h | 2 +- shared-module/displayio/Display.c | 5 ++--- shared-module/displayio/Display.h | 1 - 7 files changed, 8 insertions(+), 15 deletions(-) diff --git a/ports/atmel-samd/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c index 4f073e2706..23b1194138 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c @@ -93,8 +93,7 @@ void board_init(void) { 0x37, // set vertical scroll command display_init_sequence, sizeof(display_init_sequence), - &pin_PA00, - true); + &pin_PA00); common_hal_displayio_display_set_auto_brightness(display, true); } diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c index ce8c42a435..0881d8f457 100644 --- a/ports/atmel-samd/boards/pybadge/board.c +++ b/ports/atmel-samd/boards/pybadge/board.c @@ -99,8 +99,7 @@ void board_init(void) { 0x37, // set vertical scroll command display_init_sequence, sizeof(display_init_sequence), - &pin_PA00, - true); + &pin_PA00); common_hal_displayio_display_set_auto_brightness(display, true); } diff --git a/ports/atmel-samd/boards/pyportal/board.c b/ports/atmel-samd/boards/pyportal/board.c index 3a306b0b47..d2c328850b 100644 --- a/ports/atmel-samd/boards/pyportal/board.c +++ b/ports/atmel-samd/boards/pyportal/board.c @@ -90,8 +90,7 @@ void board_init(void) { 0x37, // Set vertical scroll command display_init_sequence, sizeof(display_init_sequence), - &pin_PB31, - true); + &pin_PB31); common_hal_displayio_display_set_auto_brightness(display, true); } diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 9cefb95328..ddca9ffd80 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -94,7 +94,7 @@ //| :param bool init_cs_toggle: Toggle the Chip Select between each initialization command //| 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_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin, ARG_init_cs_toggle }; + enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin }; 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 }, @@ -109,7 +109,6 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_write_ram_command, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x2c} }, { MP_QSTR_set_vertical_scroll, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x0} }, { MP_QSTR_backlight_pin, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, - { MP_QSTR_init_cs_toggle, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} }, }; 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); @@ -148,8 +147,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a args[ARG_color_depth].u_int, args[ARG_set_column_command].u_int, args[ARG_set_row_command].u_int, args[ARG_write_ram_command].u_int, args[ARG_set_vertical_scroll].u_int, - bufinfo.buf, bufinfo.len, MP_OBJ_TO_PTR(backlight_pin), - args[ARG_init_cs_toggle].u_bool); + bufinfo.buf, bufinfo.len, MP_OBJ_TO_PTR(backlight_pin)); return self; } diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h index 407afe1c3b..7d6444a2d4 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/displayio/Display.h @@ -40,7 +40,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, 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, bool init_cs_toggle); + uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin); int32_t common_hal_displayio_display_wait_for_frame(displayio_display_obj_t* self); diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index bbc23b7b0a..c693d3c907 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -44,7 +44,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, 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, bool init_cs_toggle) { + const mcu_pin_obj_t* backlight_pin) { self->color_depth = color_depth; self->set_column_command = set_column_command; self->set_row_command = set_row_command; @@ -54,7 +54,6 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, self->colstart = colstart; self->rowstart = rowstart; self->auto_brightness = false; - self->init_cs_toggle = init_cs_toggle; if (MP_OBJ_IS_TYPE(bus, &displayio_parallelbus_type)) { self->begin_transaction = common_hal_displayio_parallelbus_begin_transaction; @@ -83,7 +82,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, bool delay = (data_size & DELAY) != 0; data_size &= ~DELAY; uint8_t *data = cmd + 2; - if (self->init_cs_toggle && self->set_cs != NULL) { + if (self->set_cs != NULL) { self->set_cs(self->bus, true); common_hal_time_delay_ms(1); self->set_cs(self->bus, false); diff --git a/shared-module/displayio/Display.h b/shared-module/displayio/Display.h index 250f440317..70308daa22 100644 --- a/shared-module/displayio/Display.h +++ b/shared-module/displayio/Display.h @@ -50,7 +50,6 @@ typedef struct { uint64_t last_refresh; int16_t colstart; int16_t rowstart; - bool init_cs_toggle; display_bus_begin_transaction begin_transaction; display_bus_send send; display_bus_end_transaction end_transaction;