Skip to content

Commit 96e5b85

Browse files
committed
feat(lvgl_port): Update LVGL port for using button v4 (breaking change!)
1 parent 56792df commit 96e5b85

File tree

11 files changed

+92
-47
lines changed

11 files changed

+92
-47
lines changed

bsp/esp32_c3_lcdkit/esp32_c3_lcdkit.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -23,6 +23,7 @@
2323
#include "bsp_err_check.h"
2424
#include "esp_lcd_gc9a01.h"
2525
#include "iot_knob.h"
26+
#include "button_gpio.h"
2627
#include "esp_lvgl_port.h"
2728
#include "esp_codec_dev_defaults.h"
2829

@@ -78,10 +79,9 @@ static const led_strip_rmt_config_t bsp_rmt_config = {
7879
.flags.with_dma = false,
7980
};
8081

81-
static const button_config_t bsp_encoder_btn_config = {
82-
.type = BUTTON_TYPE_GPIO,
83-
.gpio_button_config.active_level = false,
84-
.gpio_button_config.gpio_num = BSP_BTN_PRESS,
82+
static const button_gpio_config_t bsp_encoder_btn_config = {
83+
.gpio_num = BSP_BTN_PRESS,
84+
.active_level = 0,
8585
};
8686

8787
static const knob_config_t bsp_encoder_a_b_config = {
@@ -241,10 +241,15 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg)
241241

242242
static lv_indev_t *bsp_display_indev_init(lv_display_t *disp)
243243
{
244+
245+
const button_config_t btn_cfg = {0};
246+
button_handle_t encoder_btn = NULL;
247+
BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_encoder_btn_config, &encoder_btn));
248+
244249
const lvgl_port_encoder_cfg_t encoder = {
245250
.disp = disp,
246251
.encoder_a_b = &bsp_encoder_a_b_config,
247-
.encoder_enter = &bsp_encoder_btn_config
252+
.encoder_enter = encoder_btn
248253
};
249254

250255
return lvgl_port_add_encoder(&encoder);

bsp/esp32_c3_lcdkit/idf_component.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.1.0~1"
1+
version: "1.2.0"
22
description: Board Support Package (BSP) for esp32_c3_lcdkit
33
url: https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_c3_lcdkit
44

@@ -26,7 +26,7 @@ dependencies:
2626

2727
button:
2828
public: true
29-
version: ">=2,<4.0"
29+
version: ">=4,<5.0"
3030

3131
knob:
3232
version: "^0.1.3"

bsp/m5dial/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ M5Dial provides versatile power supply options to cater to various needs. It acc
2525
| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_gc9a01](https://components.espressif.com/components/espressif/esp_lcd_gc9a01) | ^1 |
2626
| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 |
2727
| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_ft5x06](https://components.espressif.com/components/espressif/esp_lcd_touch_ft5x06)| ^1 |
28-
| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2,<4.0|
28+
| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=4,<5.0|
2929
| KNOB |:heavy_check_mark:| [espressif/knob](https://components.espressif.com/components/espressif/knob) | ^0.1.3 |
3030
| AUDIO | :x: | | |
3131
|AUDIO_SPEAKER| :x: | | |

bsp/m5dial/idf_component.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.0.0"
1+
version: "1.1.0"
22
description: Board Support Package (BSP) for M5Dial
33
url: https://github.com/espressif/esp-bsp/tree/master/bsp/m5dial
44

@@ -16,10 +16,11 @@ dependencies:
1616
espressif/esp_lvgl_port:
1717
version: "^2"
1818
public: true
19+
override_path: "../../components/esp_lvgl_port"
1920

2021
button:
2122
public: true
22-
version: ">=2,<4.0"
23+
version: ">=4,<5.0"
2324

2425
knob:
2526
version: "^0.1.3"

bsp/m5dial/m5dial.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -21,6 +21,7 @@
2121
#include "bsp/display.h"
2222
#include "bsp/touch.h"
2323
#include "iot_knob.h"
24+
#include "button_gpio.h"
2425
#include "esp_lcd_gc9a01.h"
2526
#include "esp_lcd_touch_ft5x06.h"
2627
#include "esp_lvgl_port.h"
@@ -37,10 +38,9 @@ static esp_lcd_touch_handle_t tp; // LCD touch handle
3738
static bool i2c_initialized = false;
3839
static bool spi_initialized = false;
3940

40-
static const button_config_t bsp_encoder_btn_config = {
41-
.type = BUTTON_TYPE_GPIO,
42-
.gpio_button_config.active_level = false,
43-
.gpio_button_config.gpio_num = BSP_BTN_PRESS,
41+
static const button_gpio_config_t bsp_encoder_btn_config = {
42+
.gpio_num = BSP_BTN_PRESS,
43+
.active_level = 0,
4444
};
4545

4646
static const knob_config_t bsp_encoder_a_b_config = {
@@ -307,10 +307,15 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg)
307307

308308
static lv_indev_t *bsp_display_indev_encoder_init(lv_display_t *disp)
309309
{
310+
311+
const button_config_t btn_cfg = {0};
312+
button_handle_t encoder_btn = NULL;
313+
BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_encoder_btn_config, &encoder_btn));
314+
310315
const lvgl_port_encoder_cfg_t encoder = {
311316
.disp = disp,
312317
.encoder_a_b = &bsp_encoder_a_b_config,
313-
.encoder_enter = &bsp_encoder_btn_config
318+
.encoder_enter = encoder_btn
314319
};
315320

316321
return lvgl_port_add_encoder(&encoder);

bsp/m5stack_core/README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ M5Stack Core is a development board based on ESP32 microcontroller. It features:
3030

3131
<!-- Autogenerated start: Dependencies -->
3232
### Capabilities and dependencies
33-
| Capability | Available | Component |Version|
34-
|-------------|------------------|--------------------------------------------------------------------------------------------------|-------|
35-
| DISPLAY |:heavy_check_mark:|[espressif/esp_lcd_ili9341](https://components.espressif.com/components/espressif/esp_lcd_ili9341)| ^1 |
36-
| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 |
37-
| TOUCH | :x: | | |
38-
| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^2.4 |
39-
| AUDIO | :x: | | |
40-
|AUDIO_SPEAKER|:heavy_check_mark:| | |
41-
| AUDIO_MIC | :x: | | |
42-
| SDCARD |:heavy_check_mark:| idf | >=5.2 |
43-
| IMU | :x: | | |
33+
| Capability | Available | Component | Version|
34+
|-------------|------------------|--------------------------------------------------------------------------------------------------|--------|
35+
| DISPLAY |:heavy_check_mark:|[espressif/esp_lcd_ili9341](https://components.espressif.com/components/espressif/esp_lcd_ili9341)| ^1 |
36+
| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 |
37+
| TOUCH | :x: | | |
38+
| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=4,<5.0|
39+
| AUDIO | :x: | | |
40+
|AUDIO_SPEAKER|:heavy_check_mark:| | |
41+
| AUDIO_MIC | :x: | | |
42+
| SDCARD |:heavy_check_mark:| idf | >=5.2 |
43+
| IMU | :x: | | |
4444
<!-- Autogenerated end: Dependencies -->

bsp/m5stack_core/idf_component.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.0.0"
1+
version: "1.1.0"
22
description: Board Support Package (BSP) for M5Stack Core
33
url: https://github.com/espressif/esp-bsp/tree/master/bsp/m5stack_core
44

@@ -13,9 +13,10 @@ dependencies:
1313
esp_lcd_ili9341: "^1"
1414

1515
button:
16-
version: "^2.4"
16+
version: ">=4,<5.0"
1717
public: true
18-
18+
1919
espressif/esp_lvgl_port:
2020
version: "^2"
2121
public: true
22+
override_path: "../../components/esp_lvgl_port"

bsp/m5stack_core/m5stack_core.c

+22-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -25,6 +25,7 @@
2525
#include "bsp/display.h"
2626
#include "esp_lcd_ili9341.h"
2727
#include "bsp_err_check.h"
28+
#include "button_gpio.h"
2829

2930
static const char *TAG = "M5Stack";
3031

@@ -363,31 +364,36 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg)
363364
return lvgl_port_add_disp(&disp_cfg);
364365
}
365366

366-
static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = {
367+
static const button_gpio_config_t bsp_button_config[BSP_BUTTON_NUM] = {
367368
{
368-
.type = BUTTON_TYPE_GPIO,
369-
.gpio_button_config.active_level = false,
370-
.gpio_button_config.gpio_num = BSP_BUTTON_LEFT,
369+
.gpio_num = BSP_BUTTON_LEFT,
370+
.active_level = 0,
371371
},
372372
{
373-
.type = BUTTON_TYPE_GPIO,
374-
.gpio_button_config.active_level = false,
375-
.gpio_button_config.gpio_num = BSP_BUTTON_MIDDLE,
373+
.gpio_num = BSP_BUTTON_MIDDLE,
374+
.active_level = 0,
376375
},
377376
{
378-
.type = BUTTON_TYPE_GPIO,
379-
.gpio_button_config.active_level = false,
380-
.gpio_button_config.gpio_num = BSP_BUTTON_RIGHT,
377+
.gpio_num = BSP_BUTTON_RIGHT,
378+
.active_level = 0,
381379
},
382380
};
383381

384382
static lv_indev_t *bsp_display_indev_init(lv_display_t *disp)
385383
{
384+
const button_config_t btn_cfg = {0};
385+
button_handle_t prev_btn = NULL;
386+
button_handle_t next_btn = NULL;
387+
button_handle_t enter_btn = NULL;
388+
BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_PREV], &prev_btn));
389+
BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_NEXT], &next_btn));
390+
BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_ENTER], &enter_btn));
391+
386392
const lvgl_port_nav_btns_cfg_t btns = {
387393
.disp = disp,
388-
.button_prev = &bsp_button_config[BSP_BUTTON_PREV],
389-
.button_next = &bsp_button_config[BSP_BUTTON_NEXT],
390-
.button_enter = &bsp_button_config[BSP_BUTTON_ENTER]
394+
.button_prev = prev_btn,
395+
.button_next = next_btn,
396+
.button_enter = enter_btn
391397
};
392398

393399
return lvgl_port_add_navigation_buttons(&btns);
@@ -455,8 +461,9 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b
455461
if (btn_cnt) {
456462
*btn_cnt = 0;
457463
}
464+
const button_config_t btn_cfg = {0};
458465
for (int i = 0; i < BSP_BUTTON_NUM; i++) {
459-
btn_array[i] = iot_button_create(&bsp_button_config[i]);
466+
ret |= iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[i], &btn_array[i]);
460467
if (btn_array[i] == NULL) {
461468
ret = ESP_FAIL;
462469
break;

components/esp_lvgl_port/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 2.5.0
44

55
### Features (Functional change for button v4 users)
6+
>>>>>>> d3e75e7 (feat(lvgl_port): Update LVGL port for using button v4 (breaking change!))
67
- Updated LVGL port for using IoT button component v4 (LVGL port not anymore creating button, need to be created in app and included handle to LVGL port)
78

89
### Fixes

components/esp_lvgl_port/idf_component.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "2.4.4"
1+
version: "2.5.0"
22
description: ESP LVGL port
33
url: https://github.com/espressif/esp-bsp/tree/master/components/esp_lvgl_port
44
dependencies:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This file was generated using idf.py save-defconfig. It can be edited manually.
2+
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
3+
#
4+
CONFIG_IDF_TARGET="esp32"
5+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
6+
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
7+
8+
## LVGL8 ##
9+
CONFIG_LV_USE_PERF_MONITOR=y
10+
CONFIG_LV_COLOR_16_SWAP=y
11+
CONFIG_LV_MEM_CUSTOM=y
12+
CONFIG_LV_MEMCPY_MEMSET_STD=y
13+
14+
## LVGL9 ##
15+
CONFIG_LV_CONF_SKIP=y
16+
17+
#CLIB default
18+
CONFIG_LV_USE_CLIB_MALLOC=y
19+
CONFIG_LV_USE_CLIB_SPRINTF=y
20+
CONFIG_LV_USE_CLIB_STRING=y
21+
22+
# Performance monitor
23+
CONFIG_LV_USE_OBSERVER=y
24+
CONFIG_LV_USE_SYSMON=y
25+
CONFIG_LV_USE_PERF_MONITOR=y

0 commit comments

Comments
 (0)