Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lvgl port updates #320

Merged
merged 8 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions bsp/esp32_p4_function_ev_board/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,17 @@ ESP32-P4 Function EV Board is internal Espressif board for testing features on E
| SDCARD |:heavy_check_mark:| idf | >=5.3 |
| IMU | :x: | | |
<!-- Autogenerated end: Dependencies -->
<!-- Autogenerated start: Dependencies -->
### 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|
| 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: | | |
| AUDIO | :x: | | |
|AUDIO_SPEAKER| :x: | | |
| AUDIO_MIC | :x: | | |
| SDCARD |:heavy_check_mark:| idf | >=5.3 |
| IMU | :x: | | |
<!-- Autogenerated end: Dependencies -->
3 changes: 0 additions & 3 deletions bsp/esp32_p4_function_ev_board/esp32_p4_function_ev_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ 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,
.trans_size = (cfg->flags.sw_rotate ? BSP_LCD_H_RES * 50 : 0),
.hres = BSP_LCD_V_RES,
.vres = BSP_LCD_H_RES,
.monochrome = false,
Expand All @@ -363,7 +362,6 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg)
.buff_dma = cfg->flags.buff_dma,
.buff_spiram = cfg->flags.buff_spiram,
.swap_bytes = (BSP_LCD_BIGENDIAN ? true : false),
.sw_rotate = cfg->flags.sw_rotate, /* Only SW rotation is supported for 90° and 270° */
}
};

Expand Down Expand Up @@ -393,7 +391,6 @@ lv_display_t *bsp_display_start(void)
.flags = {
.buff_dma = true,
.buff_spiram = false,
.sw_rotate = false, /* When SPIRAM used for buffer, only SW rotation is supported; For 90° and 270° is not supported HW rotation in this driver. */
}
};
return bsp_display_start_with_config(&cfg);
Expand Down
4 changes: 2 additions & 2 deletions bsp/esp32_p4_function_ev_board/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.1.0"
version: "1.1.1"
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

Expand All @@ -12,7 +12,7 @@ dependencies:
idf: ">=5.3"
esp_lcd_ili9881c: ">=0.2.0"
esp_lcd_touch_gt911: "^1"
lvgl/lvgl: "^8"
lvgl/lvgl: ">=8,<10"

espressif/esp_lvgl_port:
version: "^2"
Expand Down
14 changes: 14 additions & 0 deletions bsp/m5stack_core_s3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,17 @@ Sound output on CoreS3 is optimized with the high-fidelity 16-bit I2S power ampl
| SDCARD |:heavy_check_mark:| idf | >=5.0 |
| IMU | :x: | | |
<!-- Autogenerated end: Dependencies -->
<!-- Autogenerated start: Dependencies -->
### Capabilities and dependencies
| Capability | Available | Component |Version|
|-------------|------------------|------------------------------------------------------------------------------------------------------------|-------|
| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_ili9341](https://components.espressif.com/components/espressif/esp_lcd_ili9341) | ^1 |
| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^1.3 |
| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_ft5x06](https://components.espressif.com/components/espressif/esp_lcd_touch_ft5x06)| ^1 |
| BUTTONS | :x: | | |
| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ^1.1 |
|AUDIO_SPEAKER|:heavy_check_mark:| | |
| AUDIO_MIC |:heavy_check_mark:| | |
| SDCARD |:heavy_check_mark:| idf | >=5.0 |
| IMU | :x: | | |
<!-- Autogenerated end: Dependencies -->
2 changes: 1 addition & 1 deletion bsp/m5stack_core_s3/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.0.0"
version: "1.0.1"
description: Board Support Package (BSP) for M5Stack CoreS3
url: https://github.com/espressif/esp-bsp/tree/master/bsp/m5stack_core_s3

Expand Down
9 changes: 4 additions & 5 deletions bsp/m5stack_core_s3/m5stack_core_s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_hand

esp_lcd_panel_reset(*ret_panel);
esp_lcd_panel_init(*ret_panel);
esp_lcd_panel_mirror(*ret_panel, true, true);
esp_lcd_panel_invert_color(*ret_panel, true);
return ret;

Expand Down Expand Up @@ -409,8 +408,8 @@ esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t
},
.flags = {
.swap_xy = 0,
.mirror_x = 1,
.mirror_y = 1,
.mirror_x = 0,
.mirror_y = 0,
},
};
esp_lcd_panel_io_handle_t tp_io_handle = NULL;
Expand Down Expand Up @@ -445,8 +444,8 @@ static lv_disp_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg)
/* Rotation values must be same as used in esp_lcd for initial settings of the screen */
.rotation = {
.swap_xy = false,
.mirror_x = true,
.mirror_y = true,
.mirror_x = false,
.mirror_y = false,
},
.flags = {
.buff_dma = cfg->flags.buff_dma,
Expand Down
12 changes: 12 additions & 0 deletions components/esp_lvgl_port/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 2.1.0

### Features
- Added LVGL sleep feature: The esp_lvgl_port handling can sleep if the display and touch are inactive (only with LVGL9)
- Added support for different display color modes (only with LVGL9)
- Added script for generating C array images during build (depends on LVGL version)

### Fixes
- Applied initial display rotation from configuration https://github.com/espressif/esp-bsp/pull/278
- Added blocking wait for LVGL task stop during esp_lvgl_port de-initialization https://github.com/espressif/esp-bsp/issues/277
- Added missing esp_idf_version.h include

## 2.0.0

### Features
Expand Down
64 changes: 63 additions & 1 deletion components/esp_lvgl_port/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This component helps with using LVGL with Espressif's LCD and touch drivers. It
* 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))
Expand Down Expand Up @@ -64,7 +65,7 @@ Add an LCD screen to the LVGL. It can be called multiple times for adding multip
.vres = DISP_HEIGHT,
.monochrome = false,
.mipi_dsi = false,
/* Rotation values must be same as used in esp_lcd for initial settings of the screen */
.color_format = LV_COLOR_FORMAT_RGB565,
.rotation = {
.swap_xy = false,
.mirror_x = false,
Expand All @@ -83,6 +84,8 @@ Add an LCD screen to the LVGL. It can be called multiple times for adding multip
lvgl_port_remove_disp(disp_handle);
```

**Note:** 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.
Expand Down Expand Up @@ -277,6 +280,65 @@ 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)
tore-espressif marked this conversation as resolved.
Show resolved Hide resolved
* 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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void app_main(void)
#endif
};
#if CONFIG_EXAMPLE_LCD_CONTROLLER_SSD1306
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0))
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,3,0))
esp_lcd_panel_ssd1306_config_t ssd1306_config = {
.height = EXAMPLE_LCD_V_RES,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
idf_component_register(SRCS "main.c"
INCLUDE_DIRS ".")

lvgl_port_create_c_image("images/esp_logo.png" "images/" "ARGB8888" "NONE")
lvgl_port_add_images(${COMPONENT_LIB} "images/")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.c
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 15 additions & 3 deletions components/esp_lvgl_port/examples/touchscreen/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@

static const char *TAG = "EXAMPLE";

// LVGL image declare
LV_IMG_DECLARE(esp_logo)

/* LCD IO and panel */
static esp_lcd_panel_io_handle_t lcd_io = NULL;
static esp_lcd_panel_handle_t lcd_panel = NULL;
Expand Down Expand Up @@ -177,20 +180,24 @@ static esp_err_t app_lvgl_init(void)
const lvgl_port_display_cfg_t disp_cfg = {
.io_handle = lcd_io,
.panel_handle = lcd_panel,
.buffer_size = EXAMPLE_LCD_H_RES * EXAMPLE_LCD_DRAW_BUFF_HEIGHT * sizeof(uint16_t),
.buffer_size = EXAMPLE_LCD_H_RES * EXAMPLE_LCD_DRAW_BUFF_HEIGHT,
.double_buffer = EXAMPLE_LCD_DRAW_BUFF_DOUBLE,
.hres = EXAMPLE_LCD_H_RES,
.vres = EXAMPLE_LCD_V_RES,
.monochrome = false,
/* Rotation values must be same as used in esp_lcd for initial settings of the screen */
#if LVGL_VERSION_MAJOR >= 9
.color_format = LV_COLOR_FORMAT_RGB565,
#endif
.rotation = {
.swap_xy = false,
.mirror_x = true,
.mirror_y = true,
},
.flags = {
.buff_dma = true,
#if LVGL_VERSION_MAJOR >= 9
.swap_bytes = true,
#endif
}
};
lvgl_disp = lvgl_port_add_disp(&disp_cfg);
Expand Down Expand Up @@ -226,6 +233,11 @@ static void app_main_display(void)

/* Your LVGL objects code here .... */

/* Create image */
lv_obj_t *img_logo = lv_img_create(scr);
lv_img_set_src(img_logo, &esp_logo);
lv_obj_align(img_logo, LV_ALIGN_TOP_MID, 0, 20);

/* Label */
lv_obj_t *label = lv_label_create(scr);
lv_obj_set_width(label, EXAMPLE_LCD_H_RES);
Expand All @@ -236,7 +248,7 @@ static void app_main_display(void)
#else
lv_label_set_text(label, LV_SYMBOL_BELL" Hello world Espressif and LVGL "LV_SYMBOL_BELL"\n "LV_SYMBOL_WARNING" For simplier initialization, use BSP "LV_SYMBOL_WARNING);
#endif
lv_obj_align(label, LV_ALIGN_CENTER, 0, -30);
lv_obj_align(label, LV_ALIGN_CENTER, 0, 20);

/* Button */
lv_obj_t *btn = lv_btn_create(scr);
Expand Down
2 changes: 1 addition & 1 deletion components/esp_lvgl_port/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "2.0.0"
version: "2.1.0"
description: ESP LVGL port
url: https://github.com/espressif/esp-bsp/tree/master/components/esp_lvgl_port
dependencies:
Expand Down
36 changes: 34 additions & 2 deletions components/esp_lvgl_port/include/esp_lvgl_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@
extern "C" {
#endif

/**
* @brief LVGL Port task event type
*/
typedef enum {
LVGL_PORT_EVENT_DISPLAY = 1,
LVGL_PORT_EVENT_TOUCH = 2,
LVGL_PORT_EVENT_USER = 99,
} lvgl_port_event_type_t;

/**
* @brief LVGL Port task events
*/
typedef struct {
lvgl_port_event_type_t type;
void *param;
} lvgl_port_event_t;

/**
* @brief Init configuration structure
*/
Expand Down Expand Up @@ -72,6 +89,7 @@ esp_err_t lvgl_port_init(const lvgl_port_cfg_t *cfg);
*
* @return
* - ESP_OK on success
* - ESP_ERR_TIMEOUT when stopping the LVGL task times out
*/
esp_err_t lvgl_port_deinit(void);

Expand Down Expand Up @@ -101,7 +119,7 @@ void lvgl_port_unlock(void);
void lvgl_port_flush_ready(lv_display_t *disp);

/**
* @brief Stop lvgl task
* @brief Stop lvgl timer
*
*
* @return
Expand All @@ -111,7 +129,7 @@ void lvgl_port_flush_ready(lv_display_t *disp);
esp_err_t lvgl_port_stop(void);

/**
* @brief Resume lvgl task
* @brief Resume lvgl timer
*
*
* @return
Expand All @@ -120,6 +138,20 @@ esp_err_t lvgl_port_stop(void);
*/
esp_err_t lvgl_port_resume(void);

/**
* @brief Notify LVGL task, that display need reload
*
* @note It is called from LVGL events and touch interrupts
*
* @param event event type
* @param param user param
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_SUPPORTED if it is not implemented
* - ESP_ERR_INVALID_STATE if queue is not initialized (can be returned after LVGL deinit)
*/
esp_err_t lvgl_port_task_wake(lvgl_port_event_type_t event, void *param);

#ifdef __cplusplus
}
#endif
12 changes: 9 additions & 3 deletions components/esp_lvgl_port/include/esp_lvgl_port_disp.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,19 @@ typedef struct {
bool monochrome; /*!< True, if display is monochrome and using 1bit for 1px */
bool mipi_dsi; /*!< True, if display is MIPI-DSI */

lvgl_port_rotation_cfg_t rotation; /*!< Default values of the screen rotation */

lvgl_port_rotation_cfg_t rotation; /*!< Default values of the screen rotation */
#if LVGL_VERSION_MAJOR >= 9
lv_color_format_t color_format; /*!< The color format of the display */
#endif
struct {
unsigned int buff_dma: 1; /*!< Allocated LVGL buffer will be DMA capable */
unsigned int buff_spiram: 1; /*!< Allocated LVGL buffer will be in PSRAM */
#if LVGL_VERSION_MAJOR == 8
unsigned int sw_rotate: 1; /*!< Use software rotation (slower) */
unsigned int swap_bytes: 1; /*!< Swap bytes in RGB656 (16-bit) before send to LCD driver */
#endif
#if LVGL_VERSION_MAJOR >= 9
unsigned int swap_bytes: 1; /*!< Swap bytes in RGB656 (16-bit) color format before send to LCD driver */
#endif
} flags;
} lvgl_port_display_cfg_t;

Expand Down
Loading
Loading