This document provides steps, how to set up your LCD and LVGL port for the best performance and comparison of different settings. All settings and measurements are valid for Espressif's chips. Examples in ESP-BSP are ready to use with the best performance.
In this document we will use following metrics for performance evaluation:
- Measure time needed for refreshing the whole screen.
- Use LVGL's lv_demo_benchmark() -test suite- to measure Frames per second (weighted FPS).
- Use LVGL's lv_demo_music() -demo application- to measure Frames per second (average FPS).
Following options and settings have impact on LCD performance (FPS). Some options yield only small difference in FPS (e.g. ~1 FPS), and some of them are more significant. Usually it depends on complexity of the graphical application (number of widgets...), resources (CPU time, RAM available...) and size of screen (definition and color depth).
Another set of key parametes are hardware related (graphical IO, frame buffer location), which are not yet covered in this document.
This is by far the most significant setting. Users are encouraged to focus on correct frame buffer configuration before moving ahead with other optimizations.
On the other hand, the frame buffer(s) will consume significant portion of your RAM. In the graph below, you can see different frame buffer settings and resulting FPS:
Main takeaways from the graph are:
- The size of LVGL buffer and double buffering feature has big impact on performance.
- Frame buffer size >25% of the screen does not bring relevant performance boost
- Frame buffer size <10% will have severe negative effect on performance
Note: The measurements are valid for frame buffer in internal SRAM. Placing the frame buffer into external PSRAM will yield worse results.
Recommended level is "Performance" for good results. The "Performance" setting causes the compiled code to be larger and faster.
CONFIG_COMPILER_OPTIMIZATION_PERF=y
The CPU frequency has a big impact on LCD performance. The recommended value is maximum -> 240 MHz.
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
The flash clock frequency and mode (bus width) has a big impact on LCD performance. Your choices will be limited by your hardware flash configuration. The higher the frequency and bus width, the better.
CONFIG_ESPTOOLPY_FLASHFREQ_120M=y
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
orCONFIG_ESPTOOLPY_OCT_FLASH
on supported chips
More information about SPI Flash configuration can be found in ESP-IDF Programming Guide.
This option puts the most frequently used LVGL functions into IRAM for execution speed up.
CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y
The main LVGL task can be processed on the second core of the CPU. It can increase performance. (It is available only on dual-core chips)
CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1=y
Native esp-idf implementation are a little (~1-3 FPS) faster (only for LVGL8).
CONFIG_LV_MEMCPY_MEMSET_STD=y
This setting can improve subjective performance during screen transitions (scrolling, etc.).
LVGL8
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
LVGL9
CONFIG_LV_DEF_REFR_PERIOD=10
The LVGL9 benchmark demo uses a different algorithm for measuring FPS. In this case, we used the same algorithm for measurement in LVGL8 for comparison.
Default settings:
- BSP example
display_lvgl_demos
- LCD: 4.3" 800x480
- Interface: RGB
- LVGL buffer size: 800 x 480
- LVGL buffer mode: Direct (avoid-tearing)
- LVGL double buffer: NO
- Optimization: Debug
- CPU frequency: 160 MHz
- Flash frequency: 80 MHz
- PSRAM frequency: 80 MHz
- Flash mode: DIO
- LVGL display refresh period: 30 ms
Average FPS (LVGL8) | Average FPS (LVGL 9.2) | Changed settings |
---|---|---|
12 | 9 | Default |
13 | 9 | + Optimization: Performance (CONFIG_COMPILER_OPTIMIZATION_PERF=y ) |
14 | 11 | + CPU frequency: 240 MHz (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y ) |
14 | 11 | + Flash mode: QIO (CONFIG_ESPTOOLPY_FLASHMODE_QIO=y ) |
15 | 11 | + LVGL fast memory enabled (CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y ) |
16 | 11 | + (CONFIG_LV_DISP_DEF_REFR_PERIOD=10 / CONFIG_LV_DEF_REFR_PERIOD=10 ) |
Default settings:
- BSP example
display_lvgl_demos
withws_7inch
component - LCD: 7" 800x480
- Intarface: 16bit parallel Intel 8080
- LCD IO clock: 20 MHz
- LVGL buffer size: 800 x 50
- LVGL double buffer: YES
- Optimization: Debug
- CPU frequency: 160 MHz
- Flash frequency: 80 MHz
- Flash mode: DIO
- LVGL display refresh period: 30 ms
Average FPS | Weighted FPS | Changed settings |
---|---|---|
17 | 32 | Default |
18 | 36 | + Optimization: Performance (CONFIG_COMPILER_OPTIMIZATION_PERF=y ) |
21 | 46 | + CPU frequency: 240 MHz (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y ) |
26 | 56 | + Flash frequency: 120 MHz, Flash mode: QIO (CONFIG_ESPTOOLPY_FLASHFREQ_120M=y + CONFIG_ESPTOOLPY_FLASHMODE_QIO=y ) |
28 | 60 | + LVGL fast memory enabled (CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y ) |
41 | 55 | + (CONFIG_LV_DISP_DEF_REFR_PERIOD=10 ) |
Default changes:
- LCD IO clock: 2 MHz
- PSRAM frequency: 80 MHz
Average FPS | Weighted FPS | Changed settings |
---|---|---|
11 | 7 | Default |
11 | 7 | + Optimization: Performance (CONFIG_COMPILER_OPTIMIZATION_PERF=y ) |
12 | 8 | + CPU frequency: 240 MHz (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y ) |
12 | 9 | + Flash frequency: 120 MHz, PSRAM frequency: 120 MHz, Flash mode: QIO (CONFIG_ESPTOOLPY_FLASHFREQ_120M=y + CONFIG_SPIRAM_SPEED_120M=y + CONFIG_ESPTOOLPY_FLASHMODE_QIO=y ) |
12 | 9 | + LVGL fast memory enabled (CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y ) |
12 | 8 | + LVGL buffer size: 800 x 480 |
26 | 8 | + (CONFIG_LV_DISP_DEF_REFR_PERIOD=10 ) |
31 | 23 | + LCD clock: 10 MHz 1 |
The graphical performance depends on a lot of things and settings, many of which affect the whole system (Compiler, Flash, CPU, PSRAM configuration...). The user should primarily focus on trade-off between frame-buffer(s) size and RAM consumption of the buffer, before optimizing the design further.
Other configuration options not covered in this document are:
- Hardware interfaces, color depth, screen definition (size), clocks, LCD controller and more.
- Complexity of the graphical application (number of LVGL objects and their styles).
Footnotes
-
This is not working in default and sometimes in fast changes on screen is not working properly. ↩