Various updates (#60)
- update lvgl to v9.2.0 - update esp_lvgl_port to v2.3.3 - various code correctness improvements
This commit is contained in:
committed by
GitHub
parent
5f8149c198
commit
a8a664703b
+104
-18
@@ -1,21 +1,24 @@
|
||||
# LVGL ESP Portation
|
||||
|
||||
[](https://components.espressif.com/components/espressif/esp_lvgl_port)
|
||||

|
||||
|
||||
This component helps with using LVGL with Espressif's LCD and touch drivers. It can be used with any project with LCD display.
|
||||
This component helps with using LVGL with Espressif's LCD and touch drivers. It can be used with any project with LCD display.
|
||||
|
||||
## Features
|
||||
* Initialization of the LVGL
|
||||
* Create task and timer
|
||||
* Handle rotating
|
||||
* Power saving
|
||||
* Add/remove display (using [`esp_lcd`](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/lcd.html))
|
||||
* Add/remove touch input (using [`esp_lcd_touch`](https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch))
|
||||
* Add/remove navigation buttons input (using [`button`](https://github.com/espressif/esp-iot-solution/tree/master/components/button))
|
||||
* Add/remove encoder input (using [`knob`](https://github.com/espressif/esp-iot-solution/tree/master/components/knob))
|
||||
* Add/remove USB HID mouse/keyboard input (using [`usb_host_hid`](https://components.espressif.com/components/espressif/usb_host_hid))
|
||||
|
||||
## LVGL Version
|
||||
|
||||
This component supports **LVGL8** and **LVGL9**. By default, it selects the latest LVGL version. If you want to use a specific version (e.g. latest LVGL8), you can easily put into `idf_component.yml` in your project like this:
|
||||
This component supports **LVGL8** and **LVGL9**. By default, it selects the latest LVGL version. If you want to use a specific version (e.g. latest LVGL8), you can easily define this requirement in `idf_component.yml` in your project like this:
|
||||
|
||||
```
|
||||
lvgl/lvgl:
|
||||
@@ -25,7 +28,7 @@ This component supports **LVGL8** and **LVGL9**. By default, it selects the l
|
||||
|
||||
### LVGL Version Compatibility
|
||||
|
||||
This component is fully compatible with LVGL version 9. All types and functions are used from LVGL9. Some LVGL9 types are not supported in LVGL8 and there are retyping in [`esp_lvgl_port_compatibility.h`](include/esp_lvgl_port_compatibility.h) header file. **Please, be aware, that some draw and object functions are not compatible between LVGL8 and LVGL9.**
|
||||
This component is fully compatible with LVGL version 9. All types and functions are used from LVGL9. Some LVGL9 types are not supported in LVGL8 and there are retyped in [`esp_lvgl_port_compatibility.h`](include/esp_lvgl_port_compatibility.h) header file. **Please, be aware, that some draw and object functions are not compatible between LVGL8 and LVGL9.**
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -37,16 +40,16 @@ This component is fully compatible with LVGL version 9. All types and functions
|
||||
|
||||
### Add screen
|
||||
|
||||
Add an LCD screen to the LVGL. It can be called multiple times for adding multiple LCD screens.
|
||||
Add an LCD screen to the LVGL. It can be called multiple times for adding multiple LCD screens.
|
||||
|
||||
``` c
|
||||
static lv_disp_t * disp_handle;
|
||||
|
||||
|
||||
/* LCD IO */
|
||||
esp_lcd_panel_io_handle_t io_handle = NULL;
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t) 1, &io_config, &io_handle));
|
||||
|
||||
/* LCD driver initialization */
|
||||
/* LCD driver initialization */
|
||||
esp_lcd_panel_handle_t lcd_panel_handle;
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &lcd_panel_handle));
|
||||
|
||||
@@ -59,7 +62,8 @@ Add an LCD screen to the LVGL. It can be called multiple times for adding multip
|
||||
.hres = DISP_WIDTH,
|
||||
.vres = DISP_HEIGHT,
|
||||
.monochrome = false,
|
||||
/* Rotation values must be same as used in esp_lcd for initial settings of the screen */
|
||||
.mipi_dsi = false,
|
||||
.color_format = LV_COLOR_FORMAT_RGB565,
|
||||
.rotation = {
|
||||
.swap_xy = false,
|
||||
.mirror_x = false,
|
||||
@@ -71,16 +75,20 @@ Add an LCD screen to the LVGL. It can be called multiple times for adding multip
|
||||
}
|
||||
};
|
||||
disp_handle = lvgl_port_add_disp(&disp_cfg);
|
||||
|
||||
|
||||
/* ... the rest of the initialization ... */
|
||||
|
||||
/* If deinitializing LVGL port, remember to delete all displays: */
|
||||
lvgl_port_remove_disp(disp_handle);
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> 1. For adding RGB or MIPI-DSI screen, use functions `lvgl_port_add_disp_rgb` or `lvgl_port_add_disp_dsi`.
|
||||
> 2. DMA buffer can be used only when you use color format `LV_COLOR_FORMAT_RGB565`.
|
||||
|
||||
### Add touch input
|
||||
|
||||
Add touch input to the LVGL. It can be called more times for adding more touch inputs.
|
||||
Add touch input to the LVGL. It can be called more times for adding more touch inputs.
|
||||
``` c
|
||||
/* Touch driver initialization */
|
||||
...
|
||||
@@ -93,7 +101,7 @@ Add touch input to the LVGL. It can be called more times for adding more touch i
|
||||
.handle = tp,
|
||||
};
|
||||
lv_indev_t* touch_handle = lvgl_port_add_touch(&touch_cfg);
|
||||
|
||||
|
||||
/* ... the rest of the initialization ... */
|
||||
|
||||
/* If deinitializing LVGL port, remember to delete all touches: */
|
||||
@@ -138,14 +146,14 @@ Add buttons input to the LVGL. It can be called more times for adding more butto
|
||||
|
||||
/* Add buttons input (for selected screen) */
|
||||
lv_indev_t* buttons_handle = lvgl_port_add_navigation_buttons(&btns);
|
||||
|
||||
|
||||
/* ... the rest of the initialization ... */
|
||||
|
||||
/* If deinitializing LVGL port, remember to delete all buttons: */
|
||||
lvgl_port_remove_navigation_buttons(buttons_handle);
|
||||
```
|
||||
|
||||
**Note:** When you use navigation buttons for control LVGL objects, these objects must be added to LVGL groups. See [LVGL documentation](https://docs.lvgl.io/master/overview/indev.html?highlight=lv_indev_get_act#keypad-and-encoder) for more info.
|
||||
> [!NOTE]
|
||||
> When you use navigation buttons for control LVGL objects, these objects must be added to LVGL groups. See [LVGL documentation](https://docs.lvgl.io/master/overview/indev.html?highlight=lv_indev_get_act#keypad-and-encoder) for more info.
|
||||
|
||||
### Add encoder input
|
||||
|
||||
@@ -173,14 +181,14 @@ Add encoder input to the LVGL. It can be called more times for adding more encod
|
||||
|
||||
/* Add encoder input (for selected screen) */
|
||||
lv_indev_t* encoder_handle = lvgl_port_add_encoder(&encoder);
|
||||
|
||||
|
||||
/* ... the rest of the initialization ... */
|
||||
|
||||
/* If deinitializing LVGL port, remember to delete all encoders: */
|
||||
lvgl_port_remove_encoder(encoder_handle);
|
||||
```
|
||||
|
||||
**Note:** When you use encoder for control LVGL objects, these objects must be added to LVGL groups. See [LVGL documentation](https://docs.lvgl.io/master/overview/indev.html?highlight=lv_indev_get_act#keypad-and-encoder) for more info.
|
||||
> [!NOTE]
|
||||
> When you use encoder for control LVGL objects, these objects must be added to LVGL groups. See [LVGL documentation](https://docs.lvgl.io/master/overview/indev.html?highlight=lv_indev_get_act#keypad-and-encoder) for more info.
|
||||
|
||||
### Add USB HID keyboard and mouse input
|
||||
|
||||
@@ -217,7 +225,8 @@ Keyboard special behavior (when objects are in group):
|
||||
- **ARROWS** or **HOME** or **END**: Move in text area
|
||||
- **DEL** or **Backspace**: Remove character in textarea
|
||||
|
||||
**Note:** When you use keyboard for control LVGL objects, these objects must be added to LVGL groups. See [LVGL documentation](https://docs.lvgl.io/master/overview/indev.html?highlight=lv_indev_get_act#keypad-and-encoder) for more info.
|
||||
> [!NOTE]
|
||||
> When you use keyboard for control LVGL objects, these objects must be added to LVGL groups. See [LVGL documentation](https://docs.lvgl.io/master/overview/indev.html?highlight=lv_indev_get_act#keypad-and-encoder) for more info.
|
||||
|
||||
### LVGL API usage
|
||||
|
||||
@@ -254,7 +263,11 @@ Display rotation can be changed at runtime.
|
||||
lv_disp_set_rotation(disp_handle, LV_DISP_ROT_90);
|
||||
```
|
||||
|
||||
**Note:** During the hardware rotating, the component call [`esp_lcd`](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/lcd.html) API. When using software rotation, you cannot use neither `direct_mode` nor `full_refresh` in the driver. See [LVGL documentation](https://docs.lvgl.io/8.3/porting/display.html?highlight=sw_rotate) for more info.
|
||||
> [!NOTE]
|
||||
> This feature consume more RAM.
|
||||
|
||||
> [!NOTE]
|
||||
> During the hardware rotating, the component call [`esp_lcd`](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/lcd.html) API. When using software rotation, you cannot use neither `direct_mode` nor `full_refresh` in the driver. See [LVGL documentation](https://docs.lvgl.io/8.3/porting/display.html?highlight=sw_rotate) for more info.
|
||||
|
||||
### Using PSRAM canvas
|
||||
|
||||
@@ -272,6 +285,79 @@ If the SRAM is insufficient, you can use the PSRAM as a canvas and use a small t
|
||||
}
|
||||
```
|
||||
|
||||
### Generating images (C Array)
|
||||
|
||||
Images can be generated during build by adding these lines to end of the main CMakeLists.txt:
|
||||
```
|
||||
# Generate C array for each image
|
||||
lvgl_port_create_c_image("images/logo.png" "images/" "ARGB8888" "NONE")
|
||||
lvgl_port_create_c_image("images/image.png" "images/" "ARGB8888" "NONE")
|
||||
# Add generated images to build
|
||||
lvgl_port_add_images(${COMPONENT_LIB} "images/")
|
||||
```
|
||||
|
||||
Usage of create C image function:
|
||||
```
|
||||
lvgl_port_create_c_image(input_image output_folder color_format compression)
|
||||
```
|
||||
|
||||
Available color formats:
|
||||
L8,I1,I2,I4,I8,A1,A2,A4,A8,ARGB8888,XRGB8888,RGB565,RGB565A8,RGB888,TRUECOLOR,TRUECOLOR_ALPHA,AUTO
|
||||
|
||||
Available compression:
|
||||
NONE,RLE,LZ4
|
||||
|
||||
> [!NOTE]
|
||||
> Parameters `color_format` and `compression` are used only in LVGL 9.
|
||||
|
||||
## Power Saving
|
||||
|
||||
The LVGL port can be optimized for power saving mode. There are two main features.
|
||||
|
||||
### LVGL task sleep
|
||||
|
||||
For optimization power saving, the LVGL task should sleep, when it does nothing. Set `task_max_sleep_ms` to big value, the LVGL task will wait for events only.
|
||||
|
||||
The LVGL task can sleep till these situations:
|
||||
* LVGL display invalidate
|
||||
* LVGL animation in process
|
||||
* Touch interrupt
|
||||
* Button interrupt
|
||||
* Knob interrupt
|
||||
* USB mouse/keyboard interrupt
|
||||
* Timeout (`task_max_sleep_ms` in configuration structure)
|
||||
* User wake (by function `lvgl_port_task_wake`)
|
||||
|
||||
> [!WARNING]
|
||||
> This feature is available from LVGL 9.
|
||||
|
||||
> [!NOTE]
|
||||
> Don't forget to set the interrupt pin in LCD touch when you set a big time for sleep in `task_max_sleep_ms`.
|
||||
|
||||
### Stopping the timer
|
||||
|
||||
Timers can still work during light-sleep mode. You can stop LVGL timer before use light-sleep by function:
|
||||
|
||||
```
|
||||
lvgl_port_stop();
|
||||
```
|
||||
|
||||
and resume LVGL timer after wake by function:
|
||||
|
||||
```
|
||||
lvgl_port_resume();
|
||||
```
|
||||
|
||||
## Performance
|
||||
|
||||
Key feature of every graphical application is performance. Recommended settings for improving LCD performance is described in a separate document [here](docs/performance.md).
|
||||
|
||||
### Performance monitor
|
||||
|
||||
For show performance monitor in LVGL9, please add these lines to sdkconfig.defaults and rebuild all.
|
||||
|
||||
```
|
||||
CONFIG_LV_USE_OBSERVER=y
|
||||
CONFIG_LV_USE_SYSMON=y
|
||||
CONFIG_LV_USE_PERF_MONITOR=y
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user