examples/peripherals/lcd/rgb_panel/README.md
| Supported Targets | ESP32-P4 | ESP32-S3 |
|---|
esp_lcd supports RGB interfaced LCD panel, with multiple buffer modes. This example shows the general process of installing an RGB panel driver, and displays a scatter chart on the screen based on the LVGL library.
This example uses the esp_timer to generate the ticks needed by LVGL and uses a dedicated task to run the lv_timer_handler(). Since the LVGL APIs are not thread-safe, this example uses a mutex which be invoked before the call of lv_timer_handler() and released after it. The same mutex needs to be used in other tasks and threads around every LVGL (lv_...) related function call and code. For more porting guides, please refer to LVGL Display porting reference.
This example uses 3 kinds of buffering mode:
| Driver Buffers | LVGL draw buffers | Pros and Cons |
|---|---|---|
| 1 Frame Buffer | Two partial buffers | fewest memory footprint, performance affected by memory copy |
| 2 Frame Buffers | Direct refresh mode | no extra memory copy between draw buffer and frame buffer, large memory cost |
| 1 Frame Buffer + </br> 2 Bounce Buffers | Two partial buffers | Fast DMA read, high CPU usage, more internal memory cost |
The connection between ESP Board and the LCD is as follows:
ESP Board RGB Panel
+-----------------------+ +-------------------+
| GND +--------------+GND |
| | | |
| 3V3 +--------------+VCC |
| | | |
| PCLK+--------------+PCLK |
| | | |
| DATA[N:0]+--------------+DATA[N:0] |
| | | |
| HSYNC+--------------+HSYNC |
| | | |
| VSYNC+--------------+VSYNC |
| | | |
| DE+--------------+DE |
| | | |
| BK_LIGHT+--------------+BLK |
+-----------------------+ | |
3V3-----+DISP_EN |
| |
+-------------------+
Run idf.py menuconfig and go to Example Configuration:
Use single frame buffer: The RGB LCD driver allocates one frame buffer and mount it to the DMA. The example also allocates one draw buffer for the LVGL library. The draw buffer contents are copied to the frame buffer by the CPU.Use double frame buffer: The RGB LCD driver allocates two frame buffers and mount them to the DMA. The LVGL library draws directly to the offline frame buffer while the online frame buffer is displayed by the RGB LCD controller.Use bounce buffer: The RGB LCD driver allocates one frame buffer and two bounce buffers. The bounce buffers are mounted to the DMA. The frame buffer contents are copied to the bounce buffers by the CPU. The example also allocates one draw buffer for the LVGL library. The draw buffer contents are copied to the frame buffer by the CPU.RGB LCD Data LinesGPIO assignment, e.g. the synchronization signals (HSYNC, VSYNC, DE) and the data linesRun idf.py -p PORT build flash monitor to build, flash and monitor the project. A scatter chart will show up on the LCD as expected.
The first time you run idf.py for the example will cost extra time as the build system needs to address the component dependencies and downloads the missing components from the ESP Component Registry into managed_components folder.
(To exit the serial monitor, type Ctrl-].)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
...
I (872) main_task: Started on CPU0
I (882) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (882) main_task: Calling app_main()
I (892) example: Turn off LCD backlight
I (892) example: Install RGB LCD panel driver
I (922) example: Initialize RGB LCD panel
I (922) example: Turn on LCD backlight
I (922) example: Initialize LVGL library
I (932) example: Allocate LVGL draw buffers
I (932) example: Register event callbacks
I (932) example: Install LVGL tick timer
I (942) example: Create LVGL task
I (942) example: Starting LVGL task
I (992) example: Display LVGL UI
I (1102) main_task: Returned from app_main()
...
EXAMPLE_LCD_BK_LIGHT_ON_LEVEL in lvgl_example_main.c.pclk_active_neg), sync porches like VBP (by vsync_back_porch) according to your LCD specCONFIG_SPIRAM_XIP_FROM_PSRAM, which can saves some bandwidth of SPI0 from being consumed by ICache.CONFIG_EXAMPLE_USE_BOUNCE_BUFFER, which will make the LCD controller fetch data from internal SRAM (instead of the PSRAM), but at the cost of increasing CPU usage.CONFIG_SPIRAM_XIP_FROM_PSRAM can also help if the you're not using the bounce buffer mode. These two configurations can save some SPI0 bandwidth from being consumed by ICache.For any technical queries, please open an issue on GitHub. We will get back to you soon.