Skip to content

Commit ba26669

Browse files
committed
bsp: Update all BSPs for button v4
1 parent bc1db2f commit ba26669

38 files changed

+503
-421
lines changed

bsp/esp-box-3/README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ ESP32-S3-BOX-3 also uses a Type-C USB connector that provides 5 V of power input
1616

1717
<!-- Autogenerated start: Dependencies -->
1818
### Capabilities and dependencies
19-
| Capability | Available | Component | Version |
20-
|-------------|------------------|----------------------------------------------------------------------------------------------------------|----------|
21-
| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_ili9341](https://components.espressif.com/components/espressif/esp_lcd_ili9341) | ^1 |
22-
| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 |
23-
| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_gt911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911)| ^1 |
24-
| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0|
25-
| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ~1.3.1 |
26-
|AUDIO_SPEAKER|:heavy_check_mark:| | |
27-
| AUDIO_MIC |:heavy_check_mark:| | |
28-
| SDCARD |:heavy_check_mark:| idf | >=5.3 |
29-
| IMU |:heavy_check_mark:| [espressif/icm42670](https://components.espressif.com/components/espressif/icm42670) | ^2.0.1 |
19+
| Capability | Available | Component |Version|
20+
|-------------|------------------|----------------------------------------------------------------------------------------------------------|-------|
21+
| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_ili9341](https://components.espressif.com/components/espressif/esp_lcd_ili9341) | ^1 |
22+
| LVGL_PORT |:heavy_check_mark:| [espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port) | ^2 |
23+
| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_gt911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911)| ^1 |
24+
| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 |
25+
| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ~1.3.1|
26+
|AUDIO_SPEAKER|:heavy_check_mark:| | |
27+
| AUDIO_MIC |:heavy_check_mark:| | |
28+
| SDCARD |:heavy_check_mark:| idf | >=5.3 |
29+
| IMU |:heavy_check_mark:| [espressif/icm42670](https://components.espressif.com/components/espressif/icm42670) | ^2.0.1|
3030
<!-- Autogenerated end: Dependencies -->

bsp/esp-box-3/esp-box-3.c

+46-30
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -17,6 +17,7 @@
1717
#include "esp_vfs_fat.h"
1818

1919
#include "iot_button.h"
20+
#include "button_gpio.h"
2021
#include "bsp/esp-box-3.h"
2122
#include "bsp/display.h"
2223
#include "bsp/touch.h"
@@ -71,27 +72,44 @@ static i2c_master_bus_handle_t i2c_handle = NULL;
7172
static bool i2c_initialized = false;
7273

7374
// This is just a wrapper to get function signature for espressif/button API callback
74-
static uint8_t bsp_get_main_button(void *param);
75-
static esp_err_t bsp_init_main_button(void *param);
76-
77-
static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = {
75+
static uint8_t bsp_get_main_button(button_driver_t *button_driver);
76+
77+
typedef enum {
78+
BSP_BUTTON_TYPE_GPIO,
79+
BSP_BUTTON_TYPE_CUSTOM
80+
} bsp_button_type_t;
81+
82+
typedef struct {
83+
bsp_button_type_t type;
84+
union {
85+
button_gpio_config_t gpio;
86+
button_driver_t custom;
87+
} cfg;
88+
} bsp_button_config_t;
89+
90+
static const bsp_button_config_t bsp_button_config[BSP_BUTTON_NUM] = {
7891
{
79-
.type = BUTTON_TYPE_GPIO,
80-
.gpio_button_config.gpio_num = BSP_BUTTON_CONFIG_IO,
81-
.gpio_button_config.active_level = 0,
92+
.type = BSP_BUTTON_TYPE_GPIO,
93+
.cfg.gpio = {
94+
.gpio_num = BSP_BUTTON_CONFIG_IO,
95+
.active_level = 0,
96+
}
8297
},
8398
{
84-
.type = BUTTON_TYPE_GPIO,
85-
.gpio_button_config.gpio_num = BSP_BUTTON_MUTE_IO,
86-
.gpio_button_config.active_level = 0,
99+
.type = BSP_BUTTON_TYPE_GPIO,
100+
.cfg.gpio = {
101+
.gpio_num = BSP_BUTTON_MUTE_IO,
102+
.active_level = 0,
103+
}
87104
},
88105
{
89-
.type = BUTTON_TYPE_CUSTOM,
90-
.custom_button_config.button_custom_init = bsp_init_main_button,
91-
.custom_button_config.button_custom_get_key_value = bsp_get_main_button,
92-
.custom_button_config.button_custom_deinit = NULL,
93-
.custom_button_config.active_level = 1,
94-
.custom_button_config.priv = (void *) BSP_BUTTON_MAIN,
106+
.type = BSP_BUTTON_TYPE_CUSTOM,
107+
.cfg.custom = {
108+
.enable_power_save = false,
109+
.get_key_level = bsp_get_main_button,
110+
.enter_power_save = NULL,
111+
.del = NULL
112+
}
95113
}
96114
};
97115

@@ -624,7 +642,7 @@ esp_err_t bsp_display_exit_sleep(void)
624642
return ESP_OK;
625643
}
626644

627-
static uint8_t bsp_get_main_button(void *param)
645+
static uint8_t bsp_get_main_button(button_driver_t *button_driver)
628646
{
629647
assert(tp);
630648
#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0)
@@ -637,17 +655,10 @@ static uint8_t bsp_get_main_button(void *param)
637655
#endif
638656
}
639657

640-
static esp_err_t bsp_init_main_button(void *param)
641-
{
642-
if (tp == NULL) {
643-
BSP_ERROR_CHECK_RETURN_ERR(bsp_touch_new(NULL, &tp));
644-
}
645-
return ESP_OK;
646-
}
647-
648658
esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size)
649659
{
650660
esp_err_t ret = ESP_OK;
661+
const button_config_t btn_config = {0};
651662
if ((btn_array_size < BSP_BUTTON_NUM) ||
652663
(btn_array == NULL)) {
653664
return ESP_ERR_INVALID_ARG;
@@ -657,10 +668,15 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b
657668
*btn_cnt = 0;
658669
}
659670
for (int i = 0; i < BSP_BUTTON_NUM; i++) {
660-
btn_array[i] = iot_button_create(&bsp_button_config[i]);
661-
if (btn_array[i] == NULL) {
662-
ret = ESP_FAIL;
663-
break;
671+
if (bsp_button_config[i].type == BSP_BUTTON_TYPE_CUSTOM) {
672+
if (tp == NULL) {
673+
BSP_ERROR_CHECK_RETURN_ERR(bsp_touch_new(NULL, &tp));
674+
}
675+
ret |= iot_button_create(&btn_config, &bsp_button_config[i].cfg.custom, &btn_array[i]);
676+
} else if (bsp_button_config[i].type == BSP_BUTTON_TYPE_GPIO) {
677+
ret |= iot_button_new_gpio_device(&btn_config, &bsp_button_config[i].cfg.gpio, &btn_array[i]);
678+
} else {
679+
ESP_LOGW(TAG, "Unsupported button type!");
664680
}
665681
if (btn_cnt) {
666682
(*btn_cnt)++;

bsp/esp-box-3/idf_component.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies:
2525
public: true
2626

2727
button:
28-
version: ">=2.5,<4.0"
28+
version: "^4"
2929
public: true
3030

3131
icm42670:

bsp/esp32_azure_iot_kit/README.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ ESP32-Azure IoT Kit has integrated an ESP32-WROVER-B module, serial port-to-USB
1919

2020
<!-- Autogenerated start: Dependencies -->
2121
### Capabilities and dependencies
22-
| Capability | Available | Component | Version |
23-
|------------------|------------------|----------------------------------------------------------------------------------------------|----------|
24-
| DISPLAY |:heavy_check_mark:| idf | >=4.4.5 |
25-
| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 |
26-
| TOUCH | :x: | | |
27-
| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0|
28-
| AUDIO | :x: | | |
29-
| AUDIO_SPEAKER | :x: | | |
30-
| AUDIO_MIC | :x: | | |
31-
| LED |:heavy_check_mark:| idf | >=4.4.5 |
32-
| SDCARD |:heavy_check_mark:| idf | >=4.4.5 |
33-
| IMU |:heavy_check_mark:| [espressif/mpu6050](https://components.espressif.com/components/espressif/mpu6050) | ^1.0.0 |
34-
|SENSOR_TEMPERATURE|:heavy_check_mark:| [espressif/hts221](https://components.espressif.com/components/espressif/hts221) | ^1.1.1 |
35-
| SENSOR_HUMIDITY |:heavy_check_mark:| [espressif/hts221](https://components.espressif.com/components/espressif/hts221) | ^1.1.1 |
36-
| SENSOR_PRESSURE |:heavy_check_mark:| [espressif/fbm320](https://components.espressif.com/components/espressif/fbm320) | ^1.0.0 |
37-
| SENSOR_LIGHT |:heavy_check_mark:| [espressif/bh1750](https://components.espressif.com/components/espressif/bh1750) | ^1.0.0 |
38-
| SENSOR_MAG |:heavy_check_mark:| [espressif/mag3110](https://components.espressif.com/components/espressif/mag3110) | ^1.0.0 |
22+
| Capability | Available | Component |Version|
23+
|------------------|------------------|----------------------------------------------------------------------------------------------|-------|
24+
| DISPLAY |:heavy_check_mark:| idf |>=4.4.5|
25+
| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 |
26+
| TOUCH | :x: | | |
27+
| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 |
28+
| AUDIO | :x: | | |
29+
| AUDIO_SPEAKER | :x: | | |
30+
| AUDIO_MIC | :x: | | |
31+
| LED |:heavy_check_mark:| idf |>=4.4.5|
32+
| SDCARD |:heavy_check_mark:| idf |>=4.4.5|
33+
| IMU |:heavy_check_mark:| [espressif/mpu6050](https://components.espressif.com/components/espressif/mpu6050) | ^1.0.0|
34+
|SENSOR_TEMPERATURE|:heavy_check_mark:| [espressif/hts221](https://components.espressif.com/components/espressif/hts221) | ^1.1.1|
35+
| SENSOR_HUMIDITY |:heavy_check_mark:| [espressif/hts221](https://components.espressif.com/components/espressif/hts221) | ^1.1.1|
36+
| SENSOR_PRESSURE |:heavy_check_mark:| [espressif/fbm320](https://components.espressif.com/components/espressif/fbm320) | ^1.0.0|
37+
| SENSOR_LIGHT |:heavy_check_mark:| [espressif/bh1750](https://components.espressif.com/components/espressif/bh1750) | ^1.0.0|
38+
| SENSOR_MAG |:heavy_check_mark:| [espressif/mag3110](https://components.espressif.com/components/espressif/mag3110) | ^1.0.0|
3939
<!-- Autogenerated end: Dependencies -->
4040
<!-- Autogenerated start: Dependencies -->
4141
### Capabilities and dependencies

bsp/esp32_azure_iot_kit/esp32_azure_iot_kit.c

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -16,18 +16,18 @@
1616
#include "bsp/display.h"
1717
#include "esp_lvgl_port.h"
1818
#include "bsp_err_check.h"
19+
#include "button_gpio.h"
1920

2021
static const char *TAG = "Azure-IoT";
2122

2223
static lv_display_t *disp;
2324
sdmmc_card_t *bsp_sdcard = NULL; // Global uSD card handler
2425
static bool i2c_initialized = false;
2526

26-
static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = {
27+
static const button_gpio_config_t bsp_button_config[BSP_BUTTON_NUM] = {
2728
{
28-
.type = BUTTON_TYPE_GPIO,
29-
.gpio_button_config.gpio_num = BSP_BUTTON_MAIN_IO,
30-
.gpio_button_config.active_level = 0,
29+
.gpio_num = BSP_BUTTON_MAIN_IO,
30+
.active_level = 0,
3131
}
3232
};
3333

@@ -382,6 +382,7 @@ bool bsp_button_get(void)
382382
esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size)
383383
{
384384
esp_err_t ret = ESP_OK;
385+
const button_config_t btn_config = {0};
385386
if ((btn_array_size < BSP_BUTTON_NUM) ||
386387
(btn_array == NULL)) {
387388
return ESP_ERR_INVALID_ARG;
@@ -391,11 +392,7 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b
391392
*btn_cnt = 0;
392393
}
393394
for (int i = 0; i < BSP_BUTTON_NUM; i++) {
394-
btn_array[i] = iot_button_create(&bsp_button_config[i]);
395-
if (btn_array[i] == NULL) {
396-
ret = ESP_FAIL;
397-
break;
398-
}
395+
ret |= iot_button_new_gpio_device(&btn_config, &bsp_button_config[i], &btn_array[i]);
399396
if (btn_cnt) {
400397
(*btn_cnt)++;
401398
}

bsp/esp32_azure_iot_kit/idf_component.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717
override_path: "../../components/esp_lvgl_port"
1818

1919
button:
20-
version: ">=2.5,<4.0"
20+
version: "^4"
2121
public: true
2222

2323
hts221:

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"
3030

3131
knob:
3232
version: "^0.1.3"

0 commit comments

Comments
 (0)