diff --git a/include/esp_lcd_panel_gc9a01.h b/include/esp_lcd_panel_gc9a01.h index 2a95be2..2927395 100644 --- a/include/esp_lcd_panel_gc9a01.h +++ b/include/esp_lcd_panel_gc9a01.h @@ -9,7 +9,13 @@ extern "C" { #endif -esp_err_t esp_lcd_new_panel_gc9a01(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *config, esp_lcd_panel_handle_t *handle); + typedef struct + { + const lcd_init_cmd_t *init_cmds; + uint16_t init_cmds_size; + } gc9a01_vendor_config_t; + + esp_err_t esp_lcd_new_panel_gc9a01(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *config, esp_lcd_panel_handle_t *handle); #ifdef __cplusplus } diff --git a/include/esp_lcd_panel_st7796.h b/include/esp_lcd_panel_st7796.h index 7686b1f..35332b4 100644 --- a/include/esp_lcd_panel_st7796.h +++ b/include/esp_lcd_panel_st7796.h @@ -9,7 +9,13 @@ extern "C" { #endif -esp_err_t esp_lcd_new_panel_st7796(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *config, esp_lcd_panel_handle_t *handle); + typedef struct + { + const lcd_init_cmd_t *init_cmds; + uint16_t init_cmds_size; + } st7796_vendor_config_t; + + esp_err_t esp_lcd_new_panel_st7796(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *config, esp_lcd_panel_handle_t *handle); #ifdef __cplusplus } diff --git a/src/esp_lcd_panel_gc9a01.c b/src/esp_lcd_panel_gc9a01.c index 00e598f..660ff1e 100644 --- a/src/esp_lcd_panel_gc9a01.c +++ b/src/esp_lcd_panel_gc9a01.c @@ -67,8 +67,7 @@ const lcd_init_cmd_t gc9a01_vendor_specific_init_default[] = { {0x67, (const uint8_t[]){0x00, 0x3C, 0x00, 0x00, 0x00, 0x01, 0x54, 0x10, 0x32, 0x98}, 10, 0}, {0x74, (const uint8_t[]){0x10, 0x45, 0x80, 0x00, 0x00, 0x4E, 0x00}, 7, 0}, {0x98, (const uint8_t[]){0x3e, 0x07}, 2, 0}, - {0x99, (const uint8_t[]){0x3e, 0x07}, 2, 0} -}; + {0x99, (const uint8_t[]){0x3e, 0x07}, 2, 0}}; esp_err_t gc9a01_reset(esp_lcd_panel_t *panel) { @@ -141,10 +140,10 @@ esp_err_t gc9a01_init(esp_lcd_panel_t *panel) const lcd_init_cmd_t *cmd = gc9a01_vendor_specific_init_default; uint16_t cmds_size = sizeof(gc9a01_vendor_specific_init_default) / sizeof(lcd_init_cmd_t); - if (ph->cmd) + if (ph->config.vendor_config != NULL) { - cmd = ph->cmd; - cmds_size = ph->cmds_size; + cmd = ((gc9a01_vendor_config_t *)ph->config.vendor_config)->init_cmds; + cmds_size = ((gc9a01_vendor_config_t *)ph->config.vendor_config)->init_cmds_size; } while (cmds_size-- > 0) diff --git a/src/esp_lcd_panel_st7796.c b/src/esp_lcd_panel_st7796.c index 7bb80e5..502a2bb 100644 --- a/src/esp_lcd_panel_st7796.c +++ b/src/esp_lcd_panel_st7796.c @@ -19,8 +19,6 @@ typedef struct int x_gap; int y_gap; uint8_t madctl; - const lcd_init_cmd_t *cmd; - const uint16_t cmds_size; } st7796_panel_t; const lcd_init_cmd_t st7796_vendor_specific_init_default[] = { @@ -64,7 +62,7 @@ esp_err_t st7796_reset(esp_lcd_panel_t *panel) } } - vTaskDelay(pdMS_TO_TICKS(120)); + vTaskDelay(pdMS_TO_TICKS(5)); return ESP_OK; } @@ -112,10 +110,10 @@ esp_err_t st7796_init(esp_lcd_panel_t *panel) const lcd_init_cmd_t *cmd = st7796_vendor_specific_init_default; uint16_t cmds_size = sizeof(st7796_vendor_specific_init_default) / sizeof(lcd_init_cmd_t); - if (ph->cmd) + if (ph->config.vendor_config != NULL) { - cmd = ph->cmd; - cmds_size = ph->cmds_size; + cmd = ((st7796_vendor_config_t *)ph->config.vendor_config)->init_cmds; + cmds_size = ((st7796_vendor_config_t *)ph->config.vendor_config)->init_cmds_size; } while (cmds_size-- > 0) @@ -160,8 +158,8 @@ esp_err_t st7796_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, i y_end += ph->y_gap; esp_err_t res; - const uint8_t caset[4] = {x_start >> 8, x_start & 0xff, (x_end - 1) >> 8, (x_end - 1) & 0xff}; - const uint8_t raset[4] = {y_start >> 8, y_start & 0xff, (y_end - 1) >> 8, (y_end - 1) & 0xff}; + const uint8_t caset[4] = {x_start >> 8, x_start, (x_end - 1) >> 8, (x_end - 1)}; + const uint8_t raset[4] = {y_start >> 8, y_start, (y_end - 1) >> 8, (y_end - 1)}; if ((res = esp_lcd_panel_io_tx_param(ph->io, LCD_CMD_CASET, caset, sizeof(caset))) != ESP_OK || (res = esp_lcd_panel_io_tx_param(ph->io, LCD_CMD_RASET, raset, sizeof(raset))) != ESP_OK) {