From c190beb4d9154ff261683e296ec902fd30ba7c8d Mon Sep 17 00:00:00 2001 From: "Planck (Lu Zeyu)" Date: Wed, 5 Jul 2023 15:45:20 +0800 Subject: [PATCH] bugfix(esp_lcd): propagate the errors in the IO link layer Closes https://github.com/espressif/esp-idf/issues/11741 Check the result of each esp_lcd_panel_io_tx_param/esp_lcd_panel_io_tx_color call Add runner and modify test rules Update .build-test-rules.yml --- .gitlab/ci/target-test.yml | 8 ++ components/esp_lcd/.build-test-rules.yml | 5 ++ .../esp_lcd/src/esp_lcd_panel_nt35510.c | 74 +++++++++++-------- .../esp_lcd/src/esp_lcd_panel_ssd1306.c | 44 ++++++----- components/esp_lcd/src/esp_lcd_panel_st7789.c | 50 ++++++++----- .../test_apps/i2c_lcd/pytest_i2c_lcd.py | 4 +- conftest.py | 1 + 7 files changed, 114 insertions(+), 72 deletions(-) diff --git a/.gitlab/ci/target-test.yml b/.gitlab/ci/target-test.yml index 2499d1d257..aa8d87bcbb 100644 --- a/.gitlab/ci/target-test.yml +++ b/.gitlab/ci/target-test.yml @@ -813,6 +813,14 @@ pytest_components_esp32c3_generic: tags: [ esp32c3, generic ] parallel: 3 +pytest_components_esp32c3_i2c_oled: + extends: + - .pytest_components_dir_template + - .rules:test:component_ut-esp32c3 + needs: + - build_pytest_components_esp32c3 + tags: [ esp32c3, i2c_oled ] + pytest_components_esp32c3_generic_multi_device: extends: - .pytest_components_dir_template diff --git a/components/esp_lcd/.build-test-rules.yml b/components/esp_lcd/.build-test-rules.yml index bf0d5f66a5..eb513846ae 100644 --- a/components/esp_lcd/.build-test-rules.yml +++ b/components/esp_lcd/.build-test-rules.yml @@ -3,6 +3,11 @@ components/esp_lcd/test_apps/i2c_lcd: disable: - if: SOC_I2C_SUPPORTED != 1 + disable_test: + - if: IDF_TARGET not in ["esp32c3"] + temporary: true + reason: insufficient runners + components/esp_lcd/test_apps/i80_lcd: disable: diff --git a/components/esp_lcd/src/esp_lcd_panel_nt35510.c b/components/esp_lcd/src/esp_lcd_panel_nt35510.c index 0f4a446483..81346ce5e5 100644 --- a/components/esp_lcd/src/esp_lcd_panel_nt35510.c +++ b/components/esp_lcd/src/esp_lcd_panel_nt35510.c @@ -7,11 +7,13 @@ #include #include #include "sdkconfig.h" + #if CONFIG_LCD_ENABLE_DEBUG_LOG // The local log level must be defined before including esp_log.h // Set the maximum log level for this source file #define LOG_LOCAL_LEVEL ESP_LOG_DEBUG #endif + #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_lcd_panel_interface.h" @@ -28,7 +30,8 @@ static const char *TAG = "lcd_panel.nt35510"; static esp_err_t panel_nt35510_del(esp_lcd_panel_t *panel); static esp_err_t panel_nt35510_reset(esp_lcd_panel_t *panel); static esp_err_t panel_nt35510_init(esp_lcd_panel_t *panel); -static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data); +static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, + const void *color_data); static esp_err_t panel_nt35510_invert_color(esp_lcd_panel_t *panel, bool invert_color_data); static esp_err_t panel_nt35510_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y); static esp_err_t panel_nt35510_swap_xy(esp_lcd_panel_t *panel, bool swap_axes); @@ -47,7 +50,9 @@ typedef struct { uint8_t colmod_cal; // save surrent value of LCD_CMD_COLMOD register } nt35510_panel_t; -esp_err_t esp_lcd_new_panel_nt35510(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel) +esp_err_t +esp_lcd_new_panel_nt35510(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, + esp_lcd_panel_handle_t *ret_panel) { #if CONFIG_LCD_ENABLE_DEBUG_LOG esp_log_level_set(TAG, ESP_LOG_DEBUG); @@ -151,7 +156,8 @@ static esp_err_t panel_nt35510_reset(esp_lcd_panel_t *panel) vTaskDelay(pdMS_TO_TICKS(10)); } else { // perform software reset - esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET << 8, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET << 8, NULL, 0), TAG, + "io tx param LCD_CMD_SWRESET failed"); vTaskDelay(pdMS_TO_TICKS(20)); // spec, wait at least 5m before sending new command } @@ -163,19 +169,21 @@ static esp_err_t panel_nt35510_init(esp_lcd_panel_t *panel) nt35510_panel_t *nt35510 = __containerof(panel, nt35510_panel_t, base); esp_lcd_panel_io_handle_t io = nt35510->io; // LCD goes into sleep mode and display will be turned off after power on reset, exit sleep mode first - esp_lcd_panel_io_tx_param(io, LCD_CMD_SLPOUT << 8, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_SLPOUT << 8, NULL, 0), TAG, + "io tx param LCD_CMD_SLPOUT failed");; vTaskDelay(pdMS_TO_TICKS(100)); - esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) { + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) { nt35510->madctl_val, - }, 2); - esp_lcd_panel_io_tx_param(io, LCD_CMD_COLMOD << 8, (uint16_t[]) { + }, 2), TAG, "io tx param LCD_CMD_MADCTL failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_COLMOD << 8, (uint16_t[]) { nt35510->colmod_cal, - }, 2); + }, 2), TAG, "io tx param LCD_CMD_COLMOD failed"); return ESP_OK; } -static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data) +static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, + const void *color_data) { nt35510_panel_t *nt35510 = __containerof(panel, nt35510_panel_t, base); assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position"); @@ -187,33 +195,33 @@ static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start, y_end += nt35510->y_gap; // define an area of frame memory where MCU can access - esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 0, (uint16_t[]) { + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 0, (uint16_t[]) { (x_start >> 8) & 0xFF, - }, 2); - esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 1, (uint16_t[]) { + }, 2), TAG, "io tx param LCD_CMD_CASET failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 1, (uint16_t[]) { x_start & 0xFF, - }, 2); - esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 2, (uint16_t[]) { + }, 2), TAG, "io tx param LCD_CMD_CASET failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 2, (uint16_t[]) { ((x_end - 1) >> 8) & 0xFF, - }, 2); - esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 3, (uint16_t[]) { + }, 2), TAG, "io tx param LCD_CMD_CASET failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 3, (uint16_t[]) { (x_end - 1) & 0xFF, - }, 2); - esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 0, (uint16_t[]) { + }, 2), TAG, "io tx param LCD_CMD_CASET failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 0, (uint16_t[]) { (y_start >> 8) & 0xFF, - }, 2); - esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 1, (uint16_t[]) { + }, 2), TAG, "io tx param LCD_CMD_RASET failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 1, (uint16_t[]) { y_start & 0xFF, - }, 2); - esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 2, (uint16_t[]) { + }, 2), TAG, "io tx param LCD_CMD_RASET failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 2, (uint16_t[]) { ((y_end - 1) >> 8) & 0xFF, - }, 2); - esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 3, (uint16_t[]) { + }, 2), TAG, "io tx param LCD_CMD_RASET failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 3, (uint16_t[]) { (y_end - 1) & 0xFF, - }, 2); + }, 2), TAG, "io tx param LCD_CMD_RASET failed"); // transfer frame buffer size_t len = (x_end - x_start) * (y_end - y_start) * nt35510->fb_bits_per_pixel / 8; - esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR << 8, color_data, len); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR << 8, color_data, len), TAG, "io tx color failed"); return ESP_OK; } @@ -228,7 +236,8 @@ static esp_err_t panel_nt35510_invert_color(esp_lcd_panel_t *panel, bool invert_ } else { command = LCD_CMD_INVOFF; } - esp_lcd_panel_io_tx_param(io, command << 8, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command << 8, NULL, 0), TAG, + "io tx param LCD_CMD_INVON/LCD_CMD_INVOFF failed"); return ESP_OK; } @@ -246,9 +255,9 @@ static esp_err_t panel_nt35510_mirror(esp_lcd_panel_t *panel, bool mirror_x, boo } else { nt35510->madctl_val &= ~LCD_CMD_MY_BIT; } - esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) { + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) { nt35510->madctl_val - }, 2); + }, 2), TAG, "io tx param LCD_CMD_MADCTL failed"); return ESP_OK; } @@ -261,9 +270,9 @@ static esp_err_t panel_nt35510_swap_xy(esp_lcd_panel_t *panel, bool swap_axes) } else { nt35510->madctl_val &= ~LCD_CMD_MV_BIT; } - esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) { + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) { nt35510->madctl_val - }, 2); + }, 2), TAG, "io tx param LCD_CMD_MADCTL failed"); return ESP_OK; } @@ -285,6 +294,7 @@ static esp_err_t panel_nt35510_disp_on_off(esp_lcd_panel_t *panel, bool on_off) } else { command = LCD_CMD_DISPOFF; } - esp_lcd_panel_io_tx_param(io, command << 8, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command << 8, NULL, 0), TAG, + "io tx param LCD_CMD_DISPON/LCD_CMD_DISPOFF failed"); return ESP_OK; } diff --git a/components/esp_lcd/src/esp_lcd_panel_ssd1306.c b/components/esp_lcd/src/esp_lcd_panel_ssd1306.c index 8d78eba72c..0520146c10 100644 --- a/components/esp_lcd/src/esp_lcd_panel_ssd1306.c +++ b/components/esp_lcd/src/esp_lcd_panel_ssd1306.c @@ -5,6 +5,7 @@ */ #include +#include #include #include "sdkconfig.h" #if CONFIG_LCD_ENABLE_DEBUG_LOG @@ -137,15 +138,18 @@ static esp_err_t panel_ssd1306_init(esp_lcd_panel_t *panel) { ssd1306_panel_t *ssd1306 = __containerof(panel, ssd1306_panel_t, base); esp_lcd_panel_io_handle_t io = ssd1306->io; - esp_lcd_panel_io_tx_param(io, SSD1306_CMD_DISP_OFF, NULL, 0); - esp_lcd_panel_io_tx_param(io, SSD1306_CMD_SET_MEMORY_ADDR_MODE, (uint8_t[]) { - 0x00 // horizontal addressing mode - }, 1); - esp_lcd_panel_io_tx_param(io, SSD1306_CMD_SET_CHARGE_PUMP, (uint8_t[]) { - 0x14 // enable charge pump - }, 1); - esp_lcd_panel_io_tx_param(io, SSD1306_CMD_MIRROR_X_OFF, NULL, 0); - esp_lcd_panel_io_tx_param(io, SSD1306_CMD_MIRROR_Y_OFF, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, SSD1306_CMD_DISP_OFF, NULL, 0), TAG, + "io tx param SSD1306_CMD_DISP_OFF failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, SSD1306_CMD_SET_MEMORY_ADDR_MODE, (uint8_t[]) { + 0x00 // horizontal addressing mode + }, 1), TAG, "io tx param SSD1306_CMD_SET_MEMORY_ADDR_MODE failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, SSD1306_CMD_SET_CHARGE_PUMP, (uint8_t[]) { + 0x14 // enable charge pump + }, 1), TAG, "io tx param SSD1306_CMD_SET_CHARGE_PUMP failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, SSD1306_CMD_MIRROR_X_OFF, NULL, 0), TAG, + "io tx param SSD1306_CMD_MIRROR_X_OFF failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, SSD1306_CMD_MIRROR_Y_OFF, NULL, 0), TAG, + "io tx param SSD1306_CMD_MIRROR_Y_OFF failed"); return ESP_OK; } @@ -174,17 +178,17 @@ static esp_err_t panel_ssd1306_draw_bitmap(esp_lcd_panel_t *panel, int x_start, uint8_t page_start = y_start / 8; uint8_t page_end = (y_end - 1) / 8; // define an area of frame memory where MCU can access - esp_lcd_panel_io_tx_param(io, SSD1306_CMD_SET_COLUMN_RANGE, (uint8_t[]) { + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, SSD1306_CMD_SET_COLUMN_RANGE, (uint8_t[]) { (x_start & 0x7F), ((x_end - 1) & 0x7F), - }, 2); - esp_lcd_panel_io_tx_param(io, SSD1306_CMD_SET_PAGE_RANGE, (uint8_t[]) { + }, 2), TAG, "io tx param SSD1306_CMD_SET_COLUMN_RANGE failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, SSD1306_CMD_SET_PAGE_RANGE, (uint8_t[]) { (page_start & 0x07), (page_end & 0x07), - }, 2); + }, 2), TAG, "io tx param SSD1306_CMD_SET_PAGE_RANGE failed"); // transfer frame buffer size_t len = (y_end - y_start) * (x_end - x_start) * ssd1306->bits_per_pixel / 8; - esp_lcd_panel_io_tx_color(io, -1, color_data, len); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_color(io, -1, color_data, len), TAG, "io tx color failed"); return ESP_OK; } @@ -199,7 +203,8 @@ static esp_err_t panel_ssd1306_invert_color(esp_lcd_panel_t *panel, bool invert_ } else { command = SSD1306_CMD_INVERT_OFF; } - esp_lcd_panel_io_tx_param(io, command, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, + "io tx param SSD1306_CMD_INVERT_ON/OFF failed"); return ESP_OK; } @@ -214,13 +219,15 @@ static esp_err_t panel_ssd1306_mirror(esp_lcd_panel_t *panel, bool mirror_x, boo } else { command = SSD1306_CMD_MIRROR_X_OFF; } - esp_lcd_panel_io_tx_param(io, command, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, + "io tx param SSD1306_CMD_MIRROR_X_ON/OFF failed"); if (mirror_y) { command = SSD1306_CMD_MIRROR_Y_ON; } else { command = SSD1306_CMD_MIRROR_Y_OFF; } - esp_lcd_panel_io_tx_param(io, command, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, + "io tx param SSD1306_CMD_MIRROR_Y_ON/OFF failed"); return ESP_OK; } @@ -250,7 +257,8 @@ static esp_err_t panel_ssd1306_disp_on_off(esp_lcd_panel_t *panel, bool on_off) } else { command = SSD1306_CMD_DISP_OFF; } - esp_lcd_panel_io_tx_param(io, command, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, + "io tx param SSD1306_CMD_DISP_ON/OFF failed"); // SEG/COM will be ON/OFF after 100ms after sending DISP_ON/OFF command vTaskDelay(pdMS_TO_TICKS(100)); return ESP_OK; diff --git a/components/esp_lcd/src/esp_lcd_panel_st7789.c b/components/esp_lcd/src/esp_lcd_panel_st7789.c index 60ea7ec40b..6503400696 100644 --- a/components/esp_lcd/src/esp_lcd_panel_st7789.c +++ b/components/esp_lcd/src/esp_lcd_panel_st7789.c @@ -7,11 +7,13 @@ #include #include #include "sdkconfig.h" + #if CONFIG_LCD_ENABLE_DEBUG_LOG // The local log level must be defined before including esp_log.h // Set the maximum log level for this source file #define LOG_LOCAL_LEVEL ESP_LOG_DEBUG #endif + #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_lcd_panel_interface.h" @@ -28,7 +30,8 @@ static const char *TAG = "lcd_panel.st7789"; static esp_err_t panel_st7789_del(esp_lcd_panel_t *panel); static esp_err_t panel_st7789_reset(esp_lcd_panel_t *panel); static esp_err_t panel_st7789_init(esp_lcd_panel_t *panel); -static esp_err_t panel_st7789_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data); +static esp_err_t panel_st7789_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, + const void *color_data); static esp_err_t panel_st7789_invert_color(esp_lcd_panel_t *panel, bool invert_color_data); static esp_err_t panel_st7789_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y); static esp_err_t panel_st7789_swap_xy(esp_lcd_panel_t *panel, bool swap_axes); @@ -47,7 +50,9 @@ typedef struct { uint8_t colmod_cal; // save surrent value of LCD_CMD_COLMOD register } st7789_panel_t; -esp_err_t esp_lcd_new_panel_st7789(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel) +esp_err_t +esp_lcd_new_panel_st7789(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, + esp_lcd_panel_handle_t *ret_panel) { #if CONFIG_LCD_ENABLE_DEBUG_LOG esp_log_level_set(TAG, ESP_LOG_DEBUG); @@ -146,7 +151,8 @@ static esp_err_t panel_st7789_reset(esp_lcd_panel_t *panel) gpio_set_level(st7789->reset_gpio_num, !st7789->reset_level); vTaskDelay(pdMS_TO_TICKS(10)); } else { // perform software reset - esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET, NULL, 0), TAG, + "io tx param LCD_CMD_SWRESET failed"); vTaskDelay(pdMS_TO_TICKS(20)); // spec, wait at least 5m before sending new command } @@ -158,19 +164,21 @@ static esp_err_t panel_st7789_init(esp_lcd_panel_t *panel) st7789_panel_t *st7789 = __containerof(panel, st7789_panel_t, base); esp_lcd_panel_io_handle_t io = st7789->io; // LCD goes into sleep mode and display will be turned off after power on reset, exit sleep mode first - esp_lcd_panel_io_tx_param(io, LCD_CMD_SLPOUT, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_SLPOUT, NULL, 0), TAG, + "io tx param LCD_CMD_SLPOUT failed"); vTaskDelay(pdMS_TO_TICKS(100)); - esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) { + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) { st7789->madctl_val, - }, 1); - esp_lcd_panel_io_tx_param(io, LCD_CMD_COLMOD, (uint8_t[]) { + }, 1), TAG, "io tx param LCD_CMD_MADCTL failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_COLMOD, (uint8_t[]) { st7789->colmod_cal, - }, 1); + }, 1), TAG, "io tx param LCD_CMD_COLMOD failed"); return ESP_OK; } -static esp_err_t panel_st7789_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data) +static esp_err_t panel_st7789_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, + const void *color_data) { st7789_panel_t *st7789 = __containerof(panel, st7789_panel_t, base); assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position"); @@ -182,21 +190,21 @@ static esp_err_t panel_st7789_draw_bitmap(esp_lcd_panel_t *panel, int x_start, i y_end += st7789->y_gap; // define an area of frame memory where MCU can access - esp_lcd_panel_io_tx_param(io, LCD_CMD_CASET, (uint8_t[]) { + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_CASET, (uint8_t[]) { (x_start >> 8) & 0xFF, x_start & 0xFF, ((x_end - 1) >> 8) & 0xFF, (x_end - 1) & 0xFF, - }, 4); - esp_lcd_panel_io_tx_param(io, LCD_CMD_RASET, (uint8_t[]) { + }, 4), TAG, "io tx param LCD_CMD_CASET failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_RASET, (uint8_t[]) { (y_start >> 8) & 0xFF, y_start & 0xFF, ((y_end - 1) >> 8) & 0xFF, (y_end - 1) & 0xFF, - }, 4); + }, 4), TAG, "io tx param LCD_CMD_RASET failed"); // transfer frame buffer size_t len = (x_end - x_start) * (y_end - y_start) * st7789->fb_bits_per_pixel / 8; - esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR, color_data, len); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR, color_data, len), TAG, "io tx color failed"); return ESP_OK; } @@ -211,7 +219,8 @@ static esp_err_t panel_st7789_invert_color(esp_lcd_panel_t *panel, bool invert_c } else { command = LCD_CMD_INVOFF; } - esp_lcd_panel_io_tx_param(io, command, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, + "io tx param LCD_CMD_INVON/LCD_CMD_INVOFF failed"); return ESP_OK; } @@ -229,9 +238,9 @@ static esp_err_t panel_st7789_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool } else { st7789->madctl_val &= ~LCD_CMD_MY_BIT; } - esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) { + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) { st7789->madctl_val - }, 1); + }, 1), TAG, "io tx param LCD_CMD_MADCTL failed"); return ESP_OK; } @@ -244,9 +253,9 @@ static esp_err_t panel_st7789_swap_xy(esp_lcd_panel_t *panel, bool swap_axes) } else { st7789->madctl_val &= ~LCD_CMD_MV_BIT; } - esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) { + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) { st7789->madctl_val - }, 1); + }, 1), TAG, "io tx param LCD_CMD_MADCTL failed"); return ESP_OK; } @@ -268,6 +277,7 @@ static esp_err_t panel_st7789_disp_on_off(esp_lcd_panel_t *panel, bool on_off) } else { command = LCD_CMD_DISPOFF; } - esp_lcd_panel_io_tx_param(io, command, NULL, 0); + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, + "io tx param LCD_CMD_DISPON/LCD_CMD_DISPOFF failed"); return ESP_OK; } diff --git a/components/esp_lcd/test_apps/i2c_lcd/pytest_i2c_lcd.py b/components/esp_lcd/test_apps/i2c_lcd/pytest_i2c_lcd.py index f92080ccb9..610d15c48b 100644 --- a/components/esp_lcd/test_apps/i2c_lcd/pytest_i2c_lcd.py +++ b/components/esp_lcd/test_apps/i2c_lcd/pytest_i2c_lcd.py @@ -5,8 +5,8 @@ import pytest from pytest_embedded import Dut -@pytest.mark.supported_targets -@pytest.mark.generic +@pytest.mark.esp32c3 +@pytest.mark.i2c_oled @pytest.mark.parametrize( 'config', [ diff --git a/conftest.py b/conftest.py index 881d01d182..56efd465c0 100644 --- a/conftest.py +++ b/conftest.py @@ -127,6 +127,7 @@ ENV_MARKERS = { 'ccs811': 'Runner with CCS811 connected', 'ethernet_w5500': 'SPI Ethernet module with two W5500', 'nvs_encr_hmac': 'Runner with test HMAC key programmed in efuse', + 'i2c_oled': 'Runner with ssd1306 I2C oled connected', # multi-dut markers 'ieee802154': 'ieee802154 related tests should run on ieee802154 runners.', 'openthread_br': 'tests should be used for openthread border router.',