From 8992f084eecd6547e0fae6d50b86a80a4ada412f Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Thu, 7 Mar 2024 21:26:04 +0100 Subject: [PATCH] Fixes --- src/esp_lcd_panel_st7796.c | 2 +- src/lvgl_gc9a01_spi.c | 14 ++++++++------ src/lvgl_ili9341_spi.c | 6 +++--- src/lvgl_st7789_spi.c | 6 +++--- src/lvgl_st7796_spi.c | 6 +++--- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/esp_lcd_panel_st7796.c b/src/esp_lcd_panel_st7796.c index daa73bf..5f672a4 100644 --- a/src/esp_lcd_panel_st7796.c +++ b/src/esp_lcd_panel_st7796.c @@ -99,7 +99,7 @@ esp_err_t st7796_init(esp_lcd_panel_t *panel) colmod = 0x07; break; default: - log_e("Invalid bits per pixel: %d. Only RGB565 and RGB666 are supported", ph->config.bits_per_pixel); + log_e("Invalid bits per pixel: %d. Only RGB565, RGB666 and RGB888 are supported", ph->config.bits_per_pixel); return ESP_ERR_INVALID_ARG; } diff --git a/src/lvgl_gc9a01_spi.c b/src/lvgl_gc9a01_spi.c index a7a1f2b..8228c92 100644 --- a/src/lvgl_gc9a01_spi.c +++ b/src/lvgl_gc9a01_spi.c @@ -22,6 +22,13 @@ void gc9a01_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color16_t *co log_v("drv:0x%08x, area:%0x%08x, color_map:0x%08x", drv, area, color_map); esp_lcd_panel_handle_t panel_handle = drv->user_data; +#if LV_COLOR_16_SWAP != 1 +#warning "LV_COLOR_16_SWAP should be 1 for max performance" + ushort pixels = lv_area_get_size(area); + lv_color16_t *p = color_map; + while (pixels--) + p++->full = (uint16_t)((p->full >> 8) | (p->full << 8)); +#endif ESP_ERROR_CHECK(esp_lcd_panel_draw_bitmap(panel_handle, area->x1, area->y1, area->x2 + 1, area->y2 + 1, color_map)); }; @@ -61,12 +68,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv) .dc_as_cmd_phase = GC9A01_SPI_CONFIG_FLAGS_DC_AS_CMD_PHASE, .dc_low_on_data = GC9A01_SPI_CONFIG_FLAGS_DC_LOW_ON_DATA, .octal_mode = GC9A01_SPI_CONFIG_FLAGS_OCTAL_MODE, -#if LV_COLOR_16_SWAP == 1 - .lsb_first = GC9A01_SPI_CONFIG_FLAGS_LSB_FIRST -#else - .lsb_first = !GC9A01_SPI_CONFIG_FLAGS_LSB_FIRST -#endif - }}; + .lsb_first = GC9A01_SPI_CONFIG_FLAGS_LSB_FIRST}}; log_d("io_spi_config: cs_gpio_num:%d, dc_gpio_num:%d, spi_mode:%d, pclk_hz:%d, trans_queue_depth:%d, user_ctx:0x%08x, on_color_trans_done:0x%08x, lcd_cmd_bits:%d, lcd_param_bits:%d, flags.dc_as_cmd_phase:%d, flags.dc_low_on_data:%d, flags.octal_mode:%d, flags.lsb_first:%d", io_spi_config.cs_gpio_num, io_spi_config.dc_gpio_num, io_spi_config.spi_mode, io_spi_config.pclk_hz, io_spi_config.trans_queue_depth, io_spi_config.user_ctx, io_spi_config.on_color_trans_done, io_spi_config.lcd_cmd_bits, io_spi_config.lcd_param_bits, io_spi_config.flags.dc_as_cmd_phase, io_spi_config.flags.dc_low_on_data, io_spi_config.flags.octal_mode, io_spi_config.flags.lsb_first); esp_lcd_panel_io_handle_t io_handle; ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)GC9A01_SPI_HOST, &io_spi_config, &io_handle)); diff --git a/src/lvgl_ili9341_spi.c b/src/lvgl_ili9341_spi.c index f39e59c..8038b9a 100644 --- a/src/lvgl_ili9341_spi.c +++ b/src/lvgl_ili9341_spi.c @@ -45,6 +45,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv) .max_transfer_sz = ILI9341_SPI_BUS_MAX_TRANSFER_SZ, .flags = ILI9341_SPI_BUS_FLAGS, .intr_flags = ILI9341_SPI_BUS_INTR_FLAGS}; + log_d("spi_bus_config: mosi_io_num:%d, miso_io_num:%d, sclk_io_num:%d, quadwp_io_num:%d, quadhd_io_num:%d, max_transfer_sz:%d, flags:0x%08x, intr_flags:0x%04x", spi_bus_config.mosi_io_num, spi_bus_config.miso_io_num, spi_bus_config.sclk_io_num, spi_bus_config.quadwp_io_num, spi_bus_config.quadhd_io_num, spi_bus_config.max_transfer_sz, spi_bus_config.flags, spi_bus_config.intr_flags); ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(ILI9341_SPI_HOST, &spi_bus_config, ILI9341_SPI_DMA_CHANNEL)); // Attach the LCD controller to the SPI bus @@ -63,6 +64,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv) .dc_low_on_data = ILI9341_SPI_CONFIG_FLAGS_DC_LOW_ON_DATA, .octal_mode = ILI9341_SPI_CONFIG_FLAGS_OCTAL_MODE, .lsb_first = ILI9341_SPI_CONFIG_FLAGS_LSB_FIRST}}; + log_d("io_spi_config: cs_gpio_num:%d, dc_gpio_num:%d, spi_mode:%d, pclk_hz:%d, trans_queue_depth:%d, user_ctx:0x%08x, on_color_trans_done:0x%08x, lcd_cmd_bits:%d, lcd_param_bits:%d, flags.dc_as_cmd_phase:%d, flags.dc_low_on_data:%d, flags.octal_mode:%d, flags.lsb_first:%d", io_spi_config.cs_gpio_num, io_spi_config.dc_gpio_num, io_spi_config.spi_mode, io_spi_config.pclk_hz, io_spi_config.trans_queue_depth, io_spi_config.user_ctx, io_spi_config.on_color_trans_done, io_spi_config.lcd_cmd_bits, io_spi_config.lcd_param_bits, io_spi_config.flags.dc_as_cmd_phase, io_spi_config.flags.dc_low_on_data, io_spi_config.flags.octal_mode, io_spi_config.flags.lsb_first); esp_lcd_panel_io_handle_t io_handle; ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)ILI9341_SPI_HOST, &io_config, &io_handle)); @@ -74,9 +76,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv) .flags = { .reset_active_high = ILI9341_DEV_CONFIG_FLAGS_RESET_ACTIVE_HIGH}, .vendor_config = ILI9341_DEV_CONFIG_VENDOR_CONFIG}; - if (panel_dev_config.vendor_config) - log_d("Initialization with vendor config"); - + log_d("panel_dev_config: reset_gpio_num:%d, color_space:%d, bits_per_pixel:%d, flags.reset_active_high:%d, vendor_config: 0x%08x", panel_dev_config.reset_gpio_num, panel_dev_config.color_space, panel_dev_config.bits_per_pixel, panel_dev_config.flags.reset_active_high, panel_dev_config.vendor_config); esp_lcd_panel_handle_t panel_handle; ESP_ERROR_CHECK(esp_lcd_new_panel_ili9341(io_handle, &panel_dev_config, &panel_handle)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle)); diff --git a/src/lvgl_st7789_spi.c b/src/lvgl_st7789_spi.c index e2915c9..90c2850 100644 --- a/src/lvgl_st7789_spi.c +++ b/src/lvgl_st7789_spi.c @@ -43,6 +43,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv) .max_transfer_sz = ST7789_SPI_BUS_MAX_TRANSFER_SZ, .flags = ST7789_SPI_BUS_FLAGS, .intr_flags = ST7789_SPI_BUS_INTR_FLAGS}; + log_d("spi_bus_config: mosi_io_num:%d, miso_io_num:%d, sclk_io_num:%d, quadwp_io_num:%d, quadhd_io_num:%d, max_transfer_sz:%d, flags:0x%08x, intr_flags:0x%04x", spi_bus_config.mosi_io_num, spi_bus_config.miso_io_num, spi_bus_config.sclk_io_num, spi_bus_config.quadwp_io_num, spi_bus_config.quadhd_io_num, spi_bus_config.max_transfer_sz, spi_bus_config.flags, spi_bus_config.intr_flags); ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(ST7789_SPI_HOST, &spi_bus_config, ST7789_SPI_DMA_CHANNEL)); // Attach the LCD controller to the SPI bus @@ -61,6 +62,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv) .dc_low_on_data = ST7789_SPI_CONFIG_FLAGS_DC_LOW_ON_DATA, .octal_mode = ST7789_SPI_CONFIG_FLAGS_OCTAL_MODE, .lsb_first = ST7789_SPI_CONFIG_FLAGS_LSB_FIRST}}; + log_d("io_spi_config: cs_gpio_num:%d, dc_gpio_num:%d, spi_mode:%d, pclk_hz:%d, trans_queue_depth:%d, user_ctx:0x%08x, on_color_trans_done:0x%08x, lcd_cmd_bits:%d, lcd_param_bits:%d, flags.dc_as_cmd_phase:%d, flags.dc_low_on_data:%d, flags.octal_mode:%d, flags.lsb_first:%d", io_spi_config.cs_gpio_num, io_spi_config.dc_gpio_num, io_spi_config.spi_mode, io_spi_config.pclk_hz, io_spi_config.trans_queue_depth, io_spi_config.user_ctx, io_spi_config.on_color_trans_done, io_spi_config.lcd_cmd_bits, io_spi_config.lcd_param_bits, io_spi_config.flags.dc_as_cmd_phase, io_spi_config.flags.dc_low_on_data, io_spi_config.flags.octal_mode, io_spi_config.flags.lsb_first); esp_lcd_panel_io_handle_t io_handle; ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)ST7789_SPI_HOST, &io_spi_config, &io_handle)); @@ -72,9 +74,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv) .flags = { .reset_active_high = ST7789_DEV_CONFIG_FLAGS_RESET_ACTIVE_HIGH}, .vendor_config = ST7789_DEV_CONFIG_VENDOR_CONFIG}; - if (panel_dev_config.vendor_config) - log_d("Initialization with vendor config"); - + log_d("panel_dev_config: reset_gpio_num:%d, color_space:%d, bits_per_pixel:%d, flags.reset_active_high:%d, vendor_config: 0x%08x", panel_dev_config.reset_gpio_num, panel_dev_config.color_space, panel_dev_config.bits_per_pixel, panel_dev_config.flags.reset_active_high, panel_dev_config.vendor_config); esp_lcd_panel_handle_t panel_handle; ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_dev_config, &panel_handle)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle)); diff --git a/src/lvgl_st7796_spi.c b/src/lvgl_st7796_spi.c index b6806fc..9a665ca 100644 --- a/src/lvgl_st7796_spi.c +++ b/src/lvgl_st7796_spi.c @@ -45,6 +45,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv) .max_transfer_sz = ST7796_SPI_BUS_MAX_TRANSFER_SZ, .flags = ST7796_SPI_BUS_FLAGS, .intr_flags = ST7796_SPI_BUS_INTR_FLAGS}; + log_d("spi_bus_config: mosi_io_num:%d, miso_io_num:%d, sclk_io_num:%d, quadwp_io_num:%d, quadhd_io_num:%d, max_transfer_sz:%d, flags:0x%08x, intr_flags:0x%04x", spi_bus_config.mosi_io_num, spi_bus_config.miso_io_num, spi_bus_config.sclk_io_num, spi_bus_config.quadwp_io_num, spi_bus_config.quadhd_io_num, spi_bus_config.max_transfer_sz, spi_bus_config.flags, spi_bus_config.intr_flags); ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(ST7796_SPI_HOST, &spi_bus_config, ST7796_SPI_DMA_CHANNEL)); // Attach the LCD controller to the SPI bus @@ -63,6 +64,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv) .dc_low_on_data = ST7796_SPI_CONFIG_FLAGS_DC_LOW_ON_DATA, .octal_mode = ST7796_SPI_CONFIG_FLAGS_OCTAL_MODE, .lsb_first = ST7796_SPI_CONFIG_FLAGS_LSB_FIRST}}; + log_d("io_spi_config: cs_gpio_num:%d, dc_gpio_num:%d, spi_mode:%d, pclk_hz:%d, trans_queue_depth:%d, user_ctx:0x%08x, on_color_trans_done:0x%08x, lcd_cmd_bits:%d, lcd_param_bits:%d, flags.dc_as_cmd_phase:%d, flags.dc_low_on_data:%d, flags.octal_mode:%d, flags.lsb_first:%d", io_spi_config.cs_gpio_num, io_spi_config.dc_gpio_num, io_spi_config.spi_mode, io_spi_config.pclk_hz, io_spi_config.trans_queue_depth, io_spi_config.user_ctx, io_spi_config.on_color_trans_done, io_spi_config.lcd_cmd_bits, io_spi_config.lcd_param_bits, io_spi_config.flags.dc_as_cmd_phase, io_spi_config.flags.dc_low_on_data, io_spi_config.flags.octal_mode, io_spi_config.flags.lsb_first); esp_lcd_panel_io_handle_t io_handle; ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)ST7796_SPI_HOST, &io_spi_config, &io_handle)); @@ -74,9 +76,7 @@ void lvgl_lcd_init(lv_disp_drv_t *drv) .flags = { .reset_active_high = ST7796_DEV_CONFIG_FLAGS_RESET_ACTIVE_HIGH}, .vendor_config = ST7796_DEV_CONFIG_VENDOR_CONFIG}; - if (panel_dev_config.vendor_config) - log_d("Initialization with vendor config"); - + log_d("panel_dev_config: reset_gpio_num:%d, color_space:%d, bits_per_pixel:%d, flags.reset_active_high:%d, vendor_config: 0x%08x", panel_dev_config.reset_gpio_num, panel_dev_config.color_space, panel_dev_config.bits_per_pixel, panel_dev_config.flags.reset_active_high, panel_dev_config.vendor_config); esp_lcd_panel_handle_t panel_handle; ESP_ERROR_CHECK(esp_lcd_new_panel_st7796(io_handle, &panel_dev_config, &panel_handle));