Merge branch 'feat/add_ek79007_mipi_dsi' into 'master'

feat(lcd): adapt the mipi_dsi example for the EK79007 LCD IC

See merge request espressif/esp-idf!32499
This commit is contained in:
morris 2024-09-02 17:42:42 +08:00
commit a82b8565b7
4 changed files with 69 additions and 20 deletions

View File

@ -3,7 +3,7 @@
# MIPI DSI LCD Panel Example
[esp_lcd](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/lcd.html) supports MIPI DSI interfaced LCD panel, with frame buffer(s) managed by the driver itself.
[esp_lcd](https://docs.espressif.com/projects/esp-idf/en/latest/esp32p4/api-reference/peripherals/lcd/dsi_lcd.html) supports MIPI DSI interfaced LCD panel, with frame buffer(s) managed by the driver itself.
This example shows the general process of installing a MIPI DSI LCD driver, and displays a LVGL widget on the screen.
@ -12,7 +12,7 @@ This example shows the general process of installing a MIPI DSI LCD driver, and
### Hardware Required
* An ESP development board, which with MIPI DSI peripheral supported
* A general MIPI DSI LCD panel, with 2 data lanes and 1 clock lane, this example will use the [ILI9881C](https://components.espressif.com/components/espressif/esp_lcd_ili9881c) for demonstration
* A general MIPI DSI LCD panel, with 2 data lanes and 1 clock lane, this example support [ILI9881C](https://components.espressif.com/components/espressif/esp_lcd_ili9881c) and [EK79007](https://components.espressif.com/components/espressif/esp_lcd_ek79007)
* An USB cable for power supply and programming
### Hardware Connection
@ -49,6 +49,7 @@ Before testing your LCD, you also need to read your LCD spec carefully, and then
Run `idf.py menuconfig` and go to `Example Configuration`:
* Choose the LCD model in `Select MIPI LCD model` according to your board.
* Choose whether to `Use DMA2D to copy draw buffer to frame buffer` asynchronously. If you choose `No`, the draw buffer will be copied to the frame buffer synchronously by CPU.
* Choose if you want to `Monitor FPS by GPIO`. If you choose `Yes`, then you can attach an oscilloscope or logic analyzer to the GPIO pin to monitor the FPS of the display.
Please note, the actual FPS should be **double** the square wave frequency.

View File

@ -12,4 +12,16 @@ menu "Example Configuration"
help
Enable this option, you can visualize the FPS by attaching a logic analyzer to a specific GPIO.
The GPIO will output a square wave with the frequency of FPS/2.
choice
prompt "Select MIPI LCD model"
default EXAMPLE_LCD_EK79007_SUPPORT
help
Select LCD controller model.
config EXAMPLE_LCD_USE_EK79007
bool "EK79007"
config EXAMPLE_LCD_USE_ILI9881C
bool "ILI9881C"
endchoice
endmenu

View File

@ -1,3 +1,4 @@
dependencies:
lvgl/lvgl: "^9.0.0"
esp_lcd_ili9881c: "~0.2.0"
esp_lcd_ili9881c: "^1.0.0"
esp_lcd_ek79007: "^1.0.0"

View File

@ -12,12 +12,13 @@
#include "esp_timer.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_mipi_dsi.h"
#include "esp_lcd_ili9881c.h"
#include "esp_ldo_regulator.h"
#include "driver/gpio.h"
#include "esp_err.h"
#include "esp_log.h"
#include "lvgl.h"
#include "esp_lcd_ili9881c.h"
#include "esp_lcd_ek79007.h"
static const char *TAG = "example";
@ -25,6 +26,7 @@ static const char *TAG = "example";
//////////////////// Please update the following configuration according to your LCD Spec //////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#if CONFIG_EXAMPLE_LCD_USE_ILI9881C
// FPS = 80000000/(40+140+40+800)/(4+16+16+1280) = 60Hz
#define EXAMPLE_MIPI_DSI_DPI_CLK_MHZ 80
#define EXAMPLE_MIPI_DSI_LCD_H_RES 800
@ -35,6 +37,18 @@ static const char *TAG = "example";
#define EXAMPLE_MIPI_DSI_LCD_VSYNC 4
#define EXAMPLE_MIPI_DSI_LCD_VBP 16
#define EXAMPLE_MIPI_DSI_LCD_VFP 16
#elif CONFIG_EXAMPLE_LCD_USE_EK79007
// FPS = 48000000/(10+120+120+1024)/(1+20+10+600) = 60Hz
#define EXAMPLE_MIPI_DSI_DPI_CLK_MHZ 48
#define EXAMPLE_MIPI_DSI_LCD_H_RES 1024
#define EXAMPLE_MIPI_DSI_LCD_V_RES 600
#define EXAMPLE_MIPI_DSI_LCD_HSYNC 10
#define EXAMPLE_MIPI_DSI_LCD_HBP 120
#define EXAMPLE_MIPI_DSI_LCD_HFP 120
#define EXAMPLE_MIPI_DSI_LCD_VSYNC 1
#define EXAMPLE_MIPI_DSI_LCD_VBP 20
#define EXAMPLE_MIPI_DSI_LCD_VFP 10
#endif
#define EXAMPLE_MIPI_DSI_LANE_NUM 2 // 2 data lanes
#define EXAMPLE_MIPI_DSI_LANE_BITRATE_MBPS 1000 // 1Gbps
@ -201,29 +215,18 @@ void app_main(void)
};
ESP_ERROR_CHECK(esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus));
ESP_LOGI(TAG, "Install MIPI DSI LCD control panel");
ESP_LOGI(TAG, "Install MIPI DSI LCD control IO");
esp_lcd_panel_io_handle_t mipi_dbi_io;
// we use DBI interface to send LCD commands and parameters
esp_lcd_dbi_io_config_t dbi_config = {
.virtual_channel = 0,
.lcd_cmd_bits = 8, // according to the LCD ILI9881C spec
.lcd_param_bits = 8, // according to the LCD ILI9881C spec
.lcd_cmd_bits = 8, // according to the LCD spec
.lcd_param_bits = 8, // according to the LCD spec
};
ESP_ERROR_CHECK(esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &mipi_dbi_io));
// create ILI9881C control panel
esp_lcd_panel_handle_t ili9881c_ctrl_panel;
esp_lcd_panel_dev_config_t lcd_dev_config = {
.bits_per_pixel = 24,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST,
};
ESP_ERROR_CHECK(esp_lcd_new_panel_ili9881c(mipi_dbi_io, &lcd_dev_config, &ili9881c_ctrl_panel));
ESP_ERROR_CHECK(esp_lcd_panel_reset(ili9881c_ctrl_panel));
ESP_ERROR_CHECK(esp_lcd_panel_init(ili9881c_ctrl_panel));
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(ili9881c_ctrl_panel, true));
ESP_LOGI(TAG, "Install MIPI DSI LCD data panel");
esp_lcd_panel_handle_t mipi_dpi_panel;
esp_lcd_panel_handle_t mipi_dpi_panel = NULL;
esp_lcd_dpi_panel_config_t dpi_config = {
.virtual_channel = 0,
.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT,
@ -243,7 +246,39 @@ void app_main(void)
.flags.use_dma2d = true,
#endif
};
ESP_ERROR_CHECK(esp_lcd_new_panel_dpi(mipi_dsi_bus, &dpi_config, &mipi_dpi_panel));
#if CONFIG_EXAMPLE_LCD_USE_ILI9881C
ili9881c_vendor_config_t vendor_config = {
.mipi_config = {
.dsi_bus = mipi_dsi_bus,
.dpi_config = &dpi_config,
.lane_num = EXAMPLE_MIPI_DSI_LANE_NUM,
},
};
esp_lcd_panel_dev_config_t lcd_dev_config = {
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
.bits_per_pixel = 24,
.vendor_config = &vendor_config,
};
ESP_ERROR_CHECK(esp_lcd_new_panel_ili9881c(mipi_dbi_io, &lcd_dev_config, &mipi_dpi_panel));
#elif CONFIG_EXAMPLE_LCD_USE_EK79007
ek79007_vendor_config_t vendor_config = {
.mipi_config = {
.dsi_bus = mipi_dsi_bus,
.dpi_config = &dpi_config,
},
};
esp_lcd_panel_dev_config_t lcd_dev_config = {
.reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
.bits_per_pixel = 24,
.vendor_config = &vendor_config,
};
ESP_ERROR_CHECK(esp_lcd_new_panel_ek79007(mipi_dbi_io, &lcd_dev_config, &mipi_dpi_panel));
#endif
ESP_ERROR_CHECK(esp_lcd_panel_reset(mipi_dpi_panel));
ESP_ERROR_CHECK(esp_lcd_panel_init(mipi_dpi_panel));
// turn on backlight
example_bsp_set_lcd_backlight(EXAMPLE_LCD_BK_LIGHT_ON_LEVEL);