Skip to content

Commit 3d1f29f

Browse files
committed
feat(lvgl_port): Update LVGL port for using button v4 (breaking change!)
1 parent e2c22a4 commit 3d1f29f

18 files changed

+197
-86
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

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 2.5.0
4+
5+
### Features (Breaking change)
6+
- 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)
7+
8+
### Fixes
9+
- Fixed buffer size by selected color format
10+
311
## 2.4.4
412

513
### Features

components/esp_lvgl_port/README.md

+27-24
Original file line numberDiff line numberDiff line change
@@ -113,35 +113,35 @@ Add touch input to the LVGL. It can be called more times for adding more touch i
113113
Add buttons input to the LVGL. It can be called more times for adding more buttons inputs for different displays. This feature is available only when the component `espressif/button` was added into the project.
114114
``` c
115115
/* Buttons configuration structure */
116-
const button_config_t bsp_button_config[] = {
116+
const button_gpio_config_t bsp_button_config[] = {
117117
{
118-
.type = BUTTON_TYPE_ADC,
119-
.adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1
120-
.adc_button_config.button_index = 0,
121-
.adc_button_config.min = 2310, // middle is 2410mV
122-
.adc_button_config.max = 2510
118+
.gpio_num = GPIO_NUM_37,
119+
.active_level = 0,
123120
},
124121
{
125-
.type = BUTTON_TYPE_ADC,
126-
.adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1
127-
.adc_button_config.button_index = 1,
128-
.adc_button_config.min = 1880, // middle is 1980mV
129-
.adc_button_config.max = 2080
122+
.gpio_num = GPIO_NUM_38,
123+
.active_level = 0,
130124
},
131125
{
132-
.type = BUTTON_TYPE_ADC,
133-
.adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1
134-
.adc_button_config.button_index = 2,
135-
.adc_button_config.min = 720, // middle is 820mV
136-
.adc_button_config.max = 920
126+
.gpio_num = GPIO_NUM_39,
127+
.active_level = 0,
137128
},
138129
};
139130

131+
132+
const button_config_t btn_cfg = {0};
133+
button_handle_t prev_btn_handle = NULL;
134+
button_handle_t next_btn_handle = NULL;
135+
button_handle_t enter_btn_handle = NULL;
136+
iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[0], &prev_btn_handle);
137+
iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[1], &next_btn_handle);
138+
iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[2], &enter_btn_handle);
139+
140140
const lvgl_port_nav_btns_cfg_t btns = {
141141
.disp = disp_handle,
142-
.button_prev = &bsp_button_config[0],
143-
.button_next = &bsp_button_config[1],
144-
.button_enter = &bsp_button_config[2]
142+
.button_prev = prev_btn_handle,
143+
.button_next = next_btn_handle,
144+
.button_enter = enter_btn_handle
145145
};
146146

147147
/* Add buttons input (for selected screen) */
@@ -160,10 +160,9 @@ Add buttons input to the LVGL. It can be called more times for adding more butto
160160
Add encoder input to the LVGL. It can be called more times for adding more encoder inputs for different displays. This feature is available only when the component `espressif/knob` was added into the project.
161161
``` c
162162
163-
const button_config_t encoder_btn_config = {
164-
.type = BUTTON_TYPE_GPIO,
165-
.gpio_button_config.active_level = false,
166-
.gpio_button_config.gpio_num = GPIO_BTN_PRESS,
163+
static const button_gpio_config_t encoder_btn_config = {
164+
.gpio_num = GPIO_BTN_PRESS,
165+
.active_level = 0,
167166
};
168167
169168
const knob_config_t encoder_a_b_config = {
@@ -172,11 +171,15 @@ Add encoder input to the LVGL. It can be called more times for adding more encod
172171
.gpio_encoder_b = GPIO_ENCODER_B,
173172
};
174173
174+
const button_config_t btn_cfg = {0};
175+
button_handle_t encoder_btn_handle = NULL;
176+
BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &encoder_btn_config, &encoder_btn_handle));
177+
175178
/* Encoder configuration structure */
176179
const lvgl_port_encoder_cfg_t encoder = {
177180
.disp = disp_handle,
178181
.encoder_a_b = &encoder_a_b_config,
179-
.encoder_enter = &encoder_btn_config
182+
.encoder_enter = encoder_btn_handle
180183
};
181184
182185
/* Add encoder input (for selected screen) */

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:

components/esp_lvgl_port/include/esp_lvgl_port_button.h

+8-2
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
*/
@@ -32,10 +32,16 @@ extern "C" {
3232
* @brief Configuration of the navigation buttons structure
3333
*/
3434
typedef struct {
35-
lv_display_t *disp; /*!< LVGL display handle (returned from lvgl_port_add_disp) */
35+
lv_display_t *disp; /*!< LVGL display handle (returned from lvgl_port_add_disp) */
36+
#if BUTTON_VER_MAJOR < 4
3637
const button_config_t *button_prev; /*!< Navigation button for previous */
3738
const button_config_t *button_next; /*!< Navigation button for next */
3839
const button_config_t *button_enter; /*!< Navigation button for enter */
40+
#else
41+
button_handle_t button_prev; /*!< Handle for navigation button for previous */
42+
button_handle_t button_next; /*!< Handle for navigation button for next */
43+
button_handle_t button_enter; /*!< Handle for navigation button for enter */
44+
#endif
3945
} lvgl_port_nav_btns_cfg_t;
4046

4147
/**

0 commit comments

Comments
 (0)