diff --git a/bsp/esp32_p4_function_ev_board/Kconfig b/bsp/esp32_p4_function_ev_board/Kconfig index ecf3cdd9..2dd6cc4f 100644 --- a/bsp/esp32_p4_function_ev_board/Kconfig +++ b/bsp/esp32_p4_function_ev_board/Kconfig @@ -75,6 +75,31 @@ menu "Board Support Package(ESP32-P4)" help LEDC channel is used to generate PWM signal that controls display brightness. Set LEDC index that should be used. + + choice BSP_LCD_COLOR_FORMAT + prompt "Select LCD color format" + default BSP_LCD_COLOR_FORMAT_RGB565 + help + Select the LCD color format RGB565/RGB888. + + config BSP_LCD_COLOR_FORMAT_RGB565 + bool "RGB565" + config BSP_LCD_COLOR_FORMAT_RGB888 + bool "RGB888" + endchoice + + choice BSP_LCD_TYPE + prompt "Select LCD type" + default BSP_LCD_TYPE_1024_600 + help + Select the LCD. + + config BSP_LCD_TYPE_1024_600 + bool "LCD 7-inch 1024x600 - ek79007" + config BSP_LCD_TYPE_1280_800 + bool "LCD 1280x800 - ili9881c" + endchoice + endmenu endmenu diff --git a/bsp/esp32_p4_function_ev_board/README.md b/bsp/esp32_p4_function_ev_board/README.md index 529c645e..a54d3d59 100644 --- a/bsp/esp32_p4_function_ev_board/README.md +++ b/bsp/esp32_p4_function_ev_board/README.md @@ -8,11 +8,26 @@ ESP32-P4 Function EV Board is internal Espressif board for testing features on E | :--------: | :---------: | | V1.0 | ^1 | | V1.2 | ^2 | +| V1.4 | ^3 | + +## Configuration + +Configuration in `menuconfig`. + +Selection LCD display `Board Support Package(ESP32-P4) --> Display --> Select LCD type` +- LCD 7-inch 1024x600 - ili9881c (default) +- LCD 1280x800 - ek79007 + +Selection color format `Board Support Package(ESP32-P4) --> Display --> Select LCD color format` +- RGB565 (default) +- RGB888 + + ### Capabilities and dependencies | Capability | Available | Component |Version| |-------------|------------------|----------------------------------------------------------------------------------------------------------|-------| -| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_ili9881c](https://components.espressif.com/components/espressif/esp_lcd_ili9881c) |>=0.2.0| +| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_ek79007](https://components.espressif.com/components/espressif/esp_lcd_ek79007) |>=0.1.0| | LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 | | TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_gt911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911)| ^1 | | BUTTONS | :x: | | | diff --git a/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c b/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c index b736089e..a1f931b6 100644 --- a/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c +++ b/bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include "sdkconfig.h" #include "driver/gpio.h" #include "driver/ledc.h" #include "esp_err.h" @@ -13,10 +14,16 @@ #include "esp_lcd_panel_ops.h" #include "esp_lcd_mipi_dsi.h" #include "esp_ldo_regulator.h" -#include "esp_lcd_ili9881c.h" #include "esp_vfs_fat.h" #include "usb/usb_host.h" + +#if CONFIG_BSP_LCD_TYPE_1024_600 +#include "esp_lcd_ek79007.h" +#else +#include "esp_lcd_ili9881c.h" +#endif + #include "bsp/esp32_p4_function_ev_board.h" #include "bsp/display.h" #include "bsp/touch.h" @@ -30,7 +37,6 @@ static lv_indev_t *disp_indev = NULL; #endif // (BSP_CONFIG_NO_GRAPHIC_LIB == 0) sdmmc_card_t *bsp_sdcard = NULL; // Global uSD card handler -static esp_lcd_touch_handle_t tp; // LCD touch handle static bool i2c_initialized = false; static TaskHandle_t usb_host_task; // USB Host Library task @@ -245,29 +251,69 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l }; ESP_GOTO_ON_ERROR(esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &io), err, TAG, "New panel IO failed"); + esp_lcd_panel_handle_t ctrl_panel = NULL; + esp_lcd_panel_handle_t disp_panel = NULL; +#if CONFIG_BSP_LCD_TYPE_1024_600 + // create EK79007 control panel + ESP_LOGI(TAG, "Install EK79007 LCD control panel"); + +#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888 + const esp_lcd_dpi_panel_config_t dpi_config = EK79007_1024_600_PANEL_60HZ_CONFIG(LCD_COLOR_PIXEL_FORMAT_RGB888); +#else + const esp_lcd_dpi_panel_config_t dpi_config = EK79007_1024_600_PANEL_60HZ_CONFIG(LCD_COLOR_PIXEL_FORMAT_RGB565); +#endif + ek79007_vendor_config_t vendor_config = { + .flags = { + .use_mipi_interface = 1, + }, + .mipi_config = { + .dsi_bus = mipi_dsi_bus, + .dpi_config = &dpi_config, + }, + }; + esp_lcd_panel_dev_config_t lcd_dev_config = { + .bits_per_pixel = 16, + .rgb_ele_order = BSP_LCD_COLOR_SPACE, + .reset_gpio_num = BSP_LCD_RST, + .vendor_config = &vendor_config, + }; + ESP_GOTO_ON_ERROR(esp_lcd_new_panel_ek79007(io, &lcd_dev_config, &disp_panel), err, TAG, "New LCD panel EK79007 failed"); + ESP_GOTO_ON_ERROR(esp_lcd_panel_reset(disp_panel), err, TAG, "LCD panel reset failed"); + ESP_GOTO_ON_ERROR(esp_lcd_panel_init(disp_panel), err, TAG, "LCD panel init failed"); + + /* Return all handles */ + ret_handles->io = io; + ret_handles->mipi_dsi_bus = mipi_dsi_bus; + ret_handles->panel = disp_panel; + ret_handles->control = NULL; + +#else // create ILI9881C control panel - esp_lcd_panel_handle_t ili9881c_ctrl_panel; + ESP_LOGI(TAG, "Install ILI9881C LCD control panel"); esp_lcd_panel_dev_config_t lcd_dev_config = { .bits_per_pixel = 16, .rgb_ele_order = BSP_LCD_COLOR_SPACE, .reset_gpio_num = -1, }; - ESP_GOTO_ON_ERROR(esp_lcd_new_panel_ili9881c(io, &lcd_dev_config, &ili9881c_ctrl_panel), err, TAG, "New LCD panel ILI9881C failed"); - ESP_GOTO_ON_ERROR(esp_lcd_panel_reset(ili9881c_ctrl_panel), err, TAG, "LCD panel reset failed"); - ESP_GOTO_ON_ERROR(esp_lcd_panel_init(ili9881c_ctrl_panel), err, TAG, "LCD panel init failed"); - ESP_GOTO_ON_ERROR(esp_lcd_panel_disp_on_off(ili9881c_ctrl_panel, true), err, TAG, "LCD panel ON failed"); - esp_lcd_panel_mirror(ili9881c_ctrl_panel, true, true); + ESP_GOTO_ON_ERROR(esp_lcd_new_panel_ili9881c(io, &lcd_dev_config, &ctrl_panel), err, TAG, "New LCD panel ILI9881C failed"); + ESP_GOTO_ON_ERROR(esp_lcd_panel_reset(ctrl_panel), err, TAG, "LCD panel reset failed"); + ESP_GOTO_ON_ERROR(esp_lcd_panel_init(ctrl_panel), err, TAG, "LCD panel init failed"); + ESP_GOTO_ON_ERROR(esp_lcd_panel_disp_on_off(ctrl_panel, true), err, TAG, "LCD panel ON failed"); + esp_lcd_panel_mirror(ctrl_panel, true, true); ESP_LOGI(TAG, "Install MIPI DSI LCD data panel"); - esp_lcd_panel_handle_t ili9881c_panel; esp_lcd_dpi_panel_config_t dpi_config = { .virtual_channel = 0, .dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT, .dpi_clock_freq_mhz = BSP_LCD_PIXEL_CLOCK_MHZ, +#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888 + .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB888, +#else .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB565, +#endif .video_timing = { - .h_size = BSP_LCD_V_RES, - .v_size = BSP_LCD_H_RES, + .h_size = BSP_LCD_H_RES, + .v_size = BSP_LCD_V_RES, .hsync_back_porch = BSP_LCD_MIPI_DSI_LCD_HBP, .hsync_pulse_width = BSP_LCD_MIPI_DSI_LCD_HSYNC, .hsync_front_porch = BSP_LCD_MIPI_DSI_LCD_HFP, @@ -277,25 +323,26 @@ esp_err_t bsp_display_new_with_handles(const bsp_display_config_t *config, bsp_l }, .flags.use_dma2d = true, }; - ESP_GOTO_ON_ERROR(esp_lcd_new_panel_dpi(mipi_dsi_bus, &dpi_config, &ili9881c_panel), err, TAG, "New panel DPI failed"); - ESP_GOTO_ON_ERROR(esp_lcd_panel_init(ili9881c_panel), err, TAG, "New panel DPI init failed"); + ESP_GOTO_ON_ERROR(esp_lcd_new_panel_dpi(mipi_dsi_bus, &dpi_config, &disp_panel), err, TAG, "New panel DPI failed"); + ESP_GOTO_ON_ERROR(esp_lcd_panel_init(disp_panel), err, TAG, "New panel DPI init failed"); /* Return all handles */ ret_handles->io = io; ret_handles->mipi_dsi_bus = mipi_dsi_bus; - ret_handles->panel = ili9881c_panel; - ret_handles->control = ili9881c_ctrl_panel; + ret_handles->panel = disp_panel; + ret_handles->control = ctrl_panel; +#endif ESP_LOGI(TAG, "Display initialized"); return ret; err: - if (ili9881c_panel) { - esp_lcd_panel_del(ili9881c_panel); + if (disp_panel) { + esp_lcd_panel_del(disp_panel); } - if (ili9881c_ctrl_panel) { - esp_lcd_panel_del(ili9881c_ctrl_panel); + if (ctrl_panel) { + esp_lcd_panel_del(ctrl_panel); } if (io) { esp_lcd_panel_io_del(io); @@ -315,7 +362,7 @@ esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t const esp_lcd_touch_config_t tp_cfg = { .x_max = BSP_LCD_H_RES, .y_max = BSP_LCD_V_RES, - .rst_gpio_num = GPIO_NUM_NC, // Shared with LCD reset + .rst_gpio_num = BSP_LCD_TOUCH_RST, // Shared with LCD reset .int_gpio_num = BSP_LCD_TOUCH_INT, .levels = { .reset = 0, @@ -323,8 +370,13 @@ esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t }, .flags = { .swap_xy = 0, +#if CONFIG_BSP_LCD_TYPE_1024_600 + .mirror_x = 1, + .mirror_y = 1, +#else .mirror_x = 0, .mirror_y = 0, +#endif }, }; esp_lcd_panel_io_handle_t tp_io_handle = NULL; @@ -348,8 +400,8 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg) .control_handle = lcd_panels.control, .buffer_size = cfg->buffer_size, .double_buffer = cfg->double_buffer, - .hres = BSP_LCD_V_RES, - .vres = BSP_LCD_H_RES, + .hres = BSP_LCD_H_RES, + .vres = BSP_LCD_V_RES, .monochrome = false, /* Rotation values must be same as used in esp_lcd for initial settings of the screen */ .rotation = { @@ -357,6 +409,13 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg) .mirror_x = true, .mirror_y = true, }, +#if LVGL_VERSION_MAJOR >= 9 +#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888 + .color_format = LV_COLOR_FORMAT_RGB888, +#else + .color_format = LV_COLOR_FORMAT_RGB565, +#endif +#endif .flags = { .buff_dma = cfg->flags.buff_dma, .buff_spiram = cfg->flags.buff_spiram, @@ -374,6 +433,7 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg) static lv_indev_t *bsp_display_indev_init(lv_display_t *disp) { + esp_lcd_touch_handle_t tp; BSP_ERROR_CHECK_RETURN_NULL(bsp_touch_new(NULL, &tp)); assert(tp); @@ -393,7 +453,11 @@ lv_display_t *bsp_display_start(void) .buffer_size = BSP_LCD_DRAW_BUFF_SIZE, .double_buffer = BSP_LCD_DRAW_BUFF_DOUBLE, .flags = { +#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888 + .buff_dma = false, +#else .buff_dma = true, +#endif .buff_spiram = false, } }; diff --git a/bsp/esp32_p4_function_ev_board/idf_component.yml b/bsp/esp32_p4_function_ev_board/idf_component.yml index c73025da..135e823e 100644 --- a/bsp/esp32_p4_function_ev_board/idf_component.yml +++ b/bsp/esp32_p4_function_ev_board/idf_component.yml @@ -1,4 +1,4 @@ -version: "2.0.0" +version: "3.0.0" description: Board Support Package (BSP) for ESP32-P4 Function EV Board (preview) url: https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_p4_function_ev_board @@ -11,6 +11,7 @@ tags: dependencies: idf: ">=5.3" esp_lcd_ili9881c: ">=0.2.0" + esp_lcd_ek79007: ">=0.1.0" esp_lcd_touch_gt911: "^1" lvgl/lvgl: ">=8,<10" diff --git a/bsp/esp32_p4_function_ev_board/include/bsp/display.h b/bsp/esp32_p4_function_ev_board/include/bsp/display.h index 90046c40..68b9d0c2 100644 --- a/bsp/esp32_p4_function_ev_board/include/bsp/display.h +++ b/bsp/esp32_p4_function_ev_board/include/bsp/display.h @@ -17,22 +17,40 @@ #pragma once #include "esp_lcd_types.h" #include "esp_lcd_mipi_dsi.h" +#include "sdkconfig.h" /* LCD color formats */ #define ESP_LCD_COLOR_FORMAT_RGB565 (1) #define ESP_LCD_COLOR_FORMAT_RGB888 (2) /* LCD display color format */ +#if CONFIG_BSP_LCD_COLOR_FORMAT_RGB888 +#define BSP_LCD_COLOR_FORMAT (ESP_LCD_COLOR_FORMAT_RGB888) +#else #define BSP_LCD_COLOR_FORMAT (ESP_LCD_COLOR_FORMAT_RGB565) +#endif /* LCD display color bytes endianess */ #define BSP_LCD_BIGENDIAN (0) /* LCD display color bits */ #define BSP_LCD_BITS_PER_PIXEL (16) /* LCD display color space */ #define BSP_LCD_COLOR_SPACE (ESP_LCD_COLOR_SPACE_RGB) -/* LCD display definition */ -#define BSP_LCD_H_RES (1280) -#define BSP_LCD_V_RES (800) + +#if CONFIG_BSP_LCD_TYPE_1024_600 +/* LCD display definition 1024x600 */ +#define BSP_LCD_H_RES (1024) +#define BSP_LCD_V_RES (600) + +#define BSP_LCD_MIPI_DSI_LCD_HSYNC (1344) +#define BSP_LCD_MIPI_DSI_LCD_HBP (160) +#define BSP_LCD_MIPI_DSI_LCD_HFP (160) +#define BSP_LCD_MIPI_DSI_LCD_VSYNC (635) +#define BSP_LCD_MIPI_DSI_LCD_VBP (23) +#define BSP_LCD_MIPI_DSI_LCD_VFP (12) +#else +/* LCD display definition 1280x800 */ +#define BSP_LCD_H_RES (800) +#define BSP_LCD_V_RES (1280) #define BSP_LCD_MIPI_DSI_LCD_HSYNC (40) #define BSP_LCD_MIPI_DSI_LCD_HBP (140) @@ -40,6 +58,7 @@ #define BSP_LCD_MIPI_DSI_LCD_VSYNC (4) #define BSP_LCD_MIPI_DSI_LCD_VBP (16) #define BSP_LCD_MIPI_DSI_LCD_VFP (16) +#endif #define BSP_LCD_MIPI_DSI_LANE_NUM (2) // 2 data lanes #define BSP_LCD_MIPI_DSI_LANE_BITRATE_MBPS (1000) // 1Gbps diff --git a/bsp/esp32_p4_function_ev_board/include/bsp/esp32_p4_function_ev_board.h b/bsp/esp32_p4_function_ev_board/include/bsp/esp32_p4_function_ev_board.h index 238f4870..be115fcb 100644 --- a/bsp/esp32_p4_function_ev_board/include/bsp/esp32_p4_function_ev_board.h +++ b/bsp/esp32_p4_function_ev_board/include/bsp/esp32_p4_function_ev_board.h @@ -17,6 +17,7 @@ #include "driver/sdmmc_host.h" #include "bsp/config.h" #include "bsp/display.h" +#include "sdkconfig.h" #if (BSP_CONFIG_NO_GRAPHIC_LIB == 0) #include "lvgl.h" @@ -44,8 +45,17 @@ #define BSP_I2C_SDA (GPIO_NUM_7) /* Display */ +#if CONFIG_BSP_LCD_TYPE_1024_600 +#define BSP_LCD_BACKLIGHT (GPIO_NUM_26) +#define BSP_LCD_RST (GPIO_NUM_27) +#define BSP_LCD_TOUCH_RST (GPIO_NUM_NC) +#define BSP_LCD_TOUCH_INT (GPIO_NUM_NC) +#else #define BSP_LCD_BACKLIGHT (GPIO_NUM_23) +#define BSP_LCD_RST (GPIO_NUM_NC) +#define BSP_LCD_TOUCH_RST (GPIO_NUM_NC) #define BSP_LCD_TOUCH_INT (GPIO_NUM_NC) +#endif /* uSD card */ #define BSP_SD_D0 (GPIO_NUM_39)