From 3592ac0f20afc56c9e1dee5a9c267526732878f5 Mon Sep 17 00:00:00 2001 From: Vilem Zavodny Date: Mon, 3 Feb 2025 13:42:02 +0100 Subject: [PATCH] bsp: Update all BSPs for button v4 --- bsp/esp-box-3/README.md | 22 +-- bsp/esp-box-3/esp-box-3.c | 76 +++++---- bsp/esp-box-3/idf_component.yml | 2 +- bsp/esp32_azure_iot_kit/README.md | 34 ++-- bsp/esp32_azure_iot_kit/esp32_azure_iot_kit.c | 17 +- bsp/esp32_azure_iot_kit/idf_component.yml | 2 +- bsp/esp32_c3_lcdkit/esp32_c3_lcdkit.c | 17 +- bsp/esp32_c3_lcdkit/idf_component.yml | 4 +- bsp/esp32_lyrat/README.md | 2 +- bsp/esp32_lyrat/esp32_lyrat.c | 125 +++++++++------ bsp/esp32_lyrat/idf_component.yml | 2 +- bsp/esp32_s2_kaluga_kit/README.md | 26 ++-- bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit.c | 78 +++++----- bsp/esp32_s2_kaluga_kit/idf_component.yml | 4 +- .../include/bsp/esp32_s2_kaluga_kit.h | 1 + bsp/esp32_s3_eye/README.md | 24 +-- bsp/esp32_s3_eye/esp32_s3_eye.c | 94 ++++++++---- bsp/esp32_s3_eye/idf_component.yml | 2 +- bsp/esp32_s3_eye/include/bsp/esp32_s3_eye.h | 1 + bsp/esp32_s3_korvo_1/README.md | 2 +- bsp/esp32_s3_korvo_1/esp32_s3_korvo_1.c | 78 +++++----- bsp/esp32_s3_korvo_1/idf_component.yml | 2 +- .../include/bsp/esp32_s3_korvo_1.h | 1 + bsp/esp32_s3_korvo_2/README.md | 26 ++-- bsp/esp32_s3_korvo_2/esp32_s3_korvo_2.c | 145 ++++++++++-------- bsp/esp32_s3_korvo_2/idf_component.yml | 2 +- bsp/esp32_s3_lcd_ev_board/README.md | 22 +-- bsp/esp32_s3_lcd_ev_board/idf_component.yml | 4 +- .../src/esp32_s3_lcd_ev_board.c | 17 +- bsp/esp32_s3_usb_otg/README.md | 26 ++-- bsp/esp32_s3_usb_otg/esp32_s3_usb_otg.c | 37 ++--- bsp/esp32_s3_usb_otg/idf_component.yml | 2 +- .../include/bsp/esp32_s3_usb_otg.h | 1 + bsp/esp_wrover_kit/README.md | 26 ++-- bsp/esp_wrover_kit/esp_wrover_kit.c | 17 +- bsp/esp_wrover_kit/idf_component.yml | 2 +- bsp/m5dial/README.md | 24 +-- bsp/m5dial/idf_component.yml | 4 +- bsp/m5dial/m5dial.c | 17 +- bsp/m5stack_core/README.md | 2 +- bsp/m5stack_core/idf_component.yml | 5 +- bsp/m5stack_core/m5stack_core.c | 37 +++-- examples/audio/main/bsp_audio_example.c | 4 + .../sdkconfig.bsp.m5stack_core | 25 +++ .../display_sensors/main/sensors_example.c | 4 + 45 files changed, 596 insertions(+), 469 deletions(-) create mode 100644 examples/display_rotation/sdkconfig.bsp.m5stack_core diff --git a/bsp/esp-box-3/README.md b/bsp/esp-box-3/README.md index f185aeca1..946816265 100644 --- a/bsp/esp-box-3/README.md +++ b/bsp/esp-box-3/README.md @@ -16,15 +16,15 @@ ESP32-S3-BOX-3 also uses a Type-C USB connector that provides 5 V of power input ### 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) | ^2 | -| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_gt911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911)| ^1 | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0| -| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ~1.3.1 | -|AUDIO_SPEAKER|:heavy_check_mark:| | | -| AUDIO_MIC |:heavy_check_mark:| | | -| SDCARD |:heavy_check_mark:| idf | >=5.3 | -| IMU |:heavy_check_mark:| [espressif/icm42670](https://components.espressif.com/components/espressif/icm42670) | ^2.0.1 | +| 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) | ^2 | +| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_gt911](https://components.espressif.com/components/espressif/esp_lcd_touch_gt911)| ^1 | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | +| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ~1.3.1| +|AUDIO_SPEAKER|:heavy_check_mark:| | | +| AUDIO_MIC |:heavy_check_mark:| | | +| SDCARD |:heavy_check_mark:| idf | >=5.3 | +| IMU |:heavy_check_mark:| [espressif/icm42670](https://components.espressif.com/components/espressif/icm42670) | ^2.0.1| diff --git a/bsp/esp-box-3/esp-box-3.c b/bsp/esp-box-3/esp-box-3.c index 50c0ceaee..0f8b52d73 100644 --- a/bsp/esp-box-3/esp-box-3.c +++ b/bsp/esp-box-3/esp-box-3.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -17,6 +17,7 @@ #include "esp_vfs_fat.h" #include "iot_button.h" +#include "button_gpio.h" #include "bsp/esp-box-3.h" #include "bsp/display.h" #include "bsp/touch.h" @@ -71,27 +72,44 @@ static i2c_master_bus_handle_t i2c_handle = NULL; static bool i2c_initialized = false; // This is just a wrapper to get function signature for espressif/button API callback -static uint8_t bsp_get_main_button(void *param); -static esp_err_t bsp_init_main_button(void *param); - -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +static uint8_t bsp_get_main_button(button_driver_t *button_driver); + +typedef enum { + BSP_BUTTON_TYPE_GPIO, + BSP_BUTTON_TYPE_CUSTOM +} bsp_button_type_t; + +typedef struct { + bsp_button_type_t type; + union { + button_gpio_config_t gpio; + button_driver_t custom; + } cfg; +} bsp_button_config_t; + +static const bsp_button_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_BUTTON_CONFIG_IO, - .gpio_button_config.active_level = 0, + .type = BSP_BUTTON_TYPE_GPIO, + .cfg.gpio = { + .gpio_num = BSP_BUTTON_CONFIG_IO, + .active_level = 0, + } }, { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_BUTTON_MUTE_IO, - .gpio_button_config.active_level = 0, + .type = BSP_BUTTON_TYPE_GPIO, + .cfg.gpio = { + .gpio_num = BSP_BUTTON_MUTE_IO, + .active_level = 0, + } }, { - .type = BUTTON_TYPE_CUSTOM, - .custom_button_config.button_custom_init = bsp_init_main_button, - .custom_button_config.button_custom_get_key_value = bsp_get_main_button, - .custom_button_config.button_custom_deinit = NULL, - .custom_button_config.active_level = 1, - .custom_button_config.priv = (void *) BSP_BUTTON_MAIN, + .type = BSP_BUTTON_TYPE_CUSTOM, + .cfg.custom = { + .enable_power_save = false, + .get_key_level = bsp_get_main_button, + .enter_power_save = NULL, + .del = NULL + } } }; @@ -624,7 +642,7 @@ esp_err_t bsp_display_exit_sleep(void) return ESP_OK; } -static uint8_t bsp_get_main_button(void *param) +static uint8_t bsp_get_main_button(button_driver_t *button_driver) { assert(tp); #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) @@ -637,17 +655,10 @@ static uint8_t bsp_get_main_button(void *param) #endif } -static esp_err_t bsp_init_main_button(void *param) -{ - if (tp == NULL) { - BSP_ERROR_CHECK_RETURN_ERR(bsp_touch_new(NULL, &tp)); - } - return ESP_OK; -} - esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size) { esp_err_t ret = ESP_OK; + const button_config_t btn_config = {0}; if ((btn_array_size < BSP_BUTTON_NUM) || (btn_array == NULL)) { 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 *btn_cnt = 0; } for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); - if (btn_array[i] == NULL) { - ret = ESP_FAIL; - break; + if (bsp_button_config[i].type == BSP_BUTTON_TYPE_CUSTOM) { + if (tp == NULL) { + BSP_ERROR_CHECK_RETURN_ERR(bsp_touch_new(NULL, &tp)); + } + ret |= iot_button_create(&btn_config, &bsp_button_config[i].cfg.custom, &btn_array[i]); + } else if (bsp_button_config[i].type == BSP_BUTTON_TYPE_GPIO) { + ret |= iot_button_new_gpio_device(&btn_config, &bsp_button_config[i].cfg.gpio, &btn_array[i]); + } else { + ESP_LOGW(TAG, "Unsupported button type!"); } if (btn_cnt) { (*btn_cnt)++; diff --git a/bsp/esp-box-3/idf_component.yml b/bsp/esp-box-3/idf_component.yml index 909ef5ced..f382ae949 100644 --- a/bsp/esp-box-3/idf_component.yml +++ b/bsp/esp-box-3/idf_component.yml @@ -25,7 +25,7 @@ dependencies: public: true button: - version: ">=2.5,<4.0" + version: "^4" public: true icm42670: diff --git a/bsp/esp32_azure_iot_kit/README.md b/bsp/esp32_azure_iot_kit/README.md index 021136b19..b57da02f4 100644 --- a/bsp/esp32_azure_iot_kit/README.md +++ b/bsp/esp32_azure_iot_kit/README.md @@ -19,23 +19,23 @@ ESP32-Azure IoT Kit has integrated an ESP32-WROVER-B module, serial port-to-USB ### Capabilities and dependencies -| Capability | Available | Component | Version | -|------------------|------------------|----------------------------------------------------------------------------------------------|----------| -| DISPLAY |:heavy_check_mark:| idf | >=4.4.5 | -| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | -| TOUCH | :x: | | | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0| -| AUDIO | :x: | | | -| AUDIO_SPEAKER | :x: | | | -| AUDIO_MIC | :x: | | | -| LED |:heavy_check_mark:| idf | >=4.4.5 | -| SDCARD |:heavy_check_mark:| idf | >=4.4.5 | -| IMU |:heavy_check_mark:| [espressif/mpu6050](https://components.espressif.com/components/espressif/mpu6050) | ^1.0.0 | -|SENSOR_TEMPERATURE|:heavy_check_mark:| [espressif/hts221](https://components.espressif.com/components/espressif/hts221) | ^1.1.1 | -| SENSOR_HUMIDITY |:heavy_check_mark:| [espressif/hts221](https://components.espressif.com/components/espressif/hts221) | ^1.1.1 | -| SENSOR_PRESSURE |:heavy_check_mark:| [espressif/fbm320](https://components.espressif.com/components/espressif/fbm320) | ^1.0.0 | -| SENSOR_LIGHT |:heavy_check_mark:| [espressif/bh1750](https://components.espressif.com/components/espressif/bh1750) | ^1.0.0 | -| SENSOR_MAG |:heavy_check_mark:| [espressif/mag3110](https://components.espressif.com/components/espressif/mag3110) | ^1.0.0 | +| Capability | Available | Component |Version| +|------------------|------------------|----------------------------------------------------------------------------------------------|-------| +| DISPLAY |:heavy_check_mark:| idf |>=4.4.5| +| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | +| TOUCH | :x: | | | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | +| AUDIO | :x: | | | +| AUDIO_SPEAKER | :x: | | | +| AUDIO_MIC | :x: | | | +| LED |:heavy_check_mark:| idf |>=4.4.5| +| SDCARD |:heavy_check_mark:| idf |>=4.4.5| +| IMU |:heavy_check_mark:| [espressif/mpu6050](https://components.espressif.com/components/espressif/mpu6050) | ^1.0.0| +|SENSOR_TEMPERATURE|:heavy_check_mark:| [espressif/hts221](https://components.espressif.com/components/espressif/hts221) | ^1.1.1| +| SENSOR_HUMIDITY |:heavy_check_mark:| [espressif/hts221](https://components.espressif.com/components/espressif/hts221) | ^1.1.1| +| SENSOR_PRESSURE |:heavy_check_mark:| [espressif/fbm320](https://components.espressif.com/components/espressif/fbm320) | ^1.0.0| +| SENSOR_LIGHT |:heavy_check_mark:| [espressif/bh1750](https://components.espressif.com/components/espressif/bh1750) | ^1.0.0| +| SENSOR_MAG |:heavy_check_mark:| [espressif/mag3110](https://components.espressif.com/components/espressif/mag3110) | ^1.0.0| ### Capabilities and dependencies diff --git a/bsp/esp32_azure_iot_kit/esp32_azure_iot_kit.c b/bsp/esp32_azure_iot_kit/esp32_azure_iot_kit.c index df9a7207f..551c1bac3 100644 --- a/bsp/esp32_azure_iot_kit/esp32_azure_iot_kit.c +++ b/bsp/esp32_azure_iot_kit/esp32_azure_iot_kit.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,6 +16,7 @@ #include "bsp/display.h" #include "esp_lvgl_port.h" #include "bsp_err_check.h" +#include "button_gpio.h" static const char *TAG = "Azure-IoT"; @@ -23,11 +24,10 @@ static lv_display_t *disp; sdmmc_card_t *bsp_sdcard = NULL; // Global uSD card handler static bool i2c_initialized = false; -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +static const button_gpio_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_BUTTON_MAIN_IO, - .gpio_button_config.active_level = 0, + .gpio_num = BSP_BUTTON_MAIN_IO, + .active_level = 0, } }; @@ -382,6 +382,7 @@ bool bsp_button_get(void) esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size) { esp_err_t ret = ESP_OK; + const button_config_t btn_config = {0}; if ((btn_array_size < BSP_BUTTON_NUM) || (btn_array == NULL)) { 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 *btn_cnt = 0; } for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); - if (btn_array[i] == NULL) { - ret = ESP_FAIL; - break; - } + ret |= iot_button_new_gpio_device(&btn_config, &bsp_button_config[i], &btn_array[i]); if (btn_cnt) { (*btn_cnt)++; } diff --git a/bsp/esp32_azure_iot_kit/idf_component.yml b/bsp/esp32_azure_iot_kit/idf_component.yml index 2c70ff38c..1106014a7 100644 --- a/bsp/esp32_azure_iot_kit/idf_component.yml +++ b/bsp/esp32_azure_iot_kit/idf_component.yml @@ -17,7 +17,7 @@ dependencies: override_path: "../../components/esp_lvgl_port" button: - version: ">=2.5,<4.0" + version: "^4" public: true hts221: diff --git a/bsp/esp32_c3_lcdkit/esp32_c3_lcdkit.c b/bsp/esp32_c3_lcdkit/esp32_c3_lcdkit.c index bfa1fc2b6..e74b5ba39 100644 --- a/bsp/esp32_c3_lcdkit/esp32_c3_lcdkit.c +++ b/bsp/esp32_c3_lcdkit/esp32_c3_lcdkit.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -23,6 +23,7 @@ #include "bsp_err_check.h" #include "esp_lcd_gc9a01.h" #include "iot_knob.h" +#include "button_gpio.h" #include "esp_lvgl_port.h" #include "esp_codec_dev_defaults.h" @@ -78,10 +79,9 @@ static const led_strip_rmt_config_t bsp_rmt_config = { .flags.with_dma = false, }; -static const button_config_t bsp_encoder_btn_config = { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = false, - .gpio_button_config.gpio_num = BSP_BTN_PRESS, +static const button_gpio_config_t bsp_encoder_btn_config = { + .gpio_num = BSP_BTN_PRESS, + .active_level = 0, }; 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) static lv_indev_t *bsp_display_indev_init(lv_display_t *disp) { + + const button_config_t btn_cfg = {0}; + button_handle_t encoder_btn = NULL; + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_encoder_btn_config, &encoder_btn)); + const lvgl_port_encoder_cfg_t encoder = { .disp = disp, .encoder_a_b = &bsp_encoder_a_b_config, - .encoder_enter = &bsp_encoder_btn_config + .encoder_enter = encoder_btn }; return lvgl_port_add_encoder(&encoder); diff --git a/bsp/esp32_c3_lcdkit/idf_component.yml b/bsp/esp32_c3_lcdkit/idf_component.yml index a054411a3..fc2950bd5 100644 --- a/bsp/esp32_c3_lcdkit/idf_component.yml +++ b/bsp/esp32_c3_lcdkit/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.1.0~1" +version: "2.0.0" description: Board Support Package (BSP) for esp32_c3_lcdkit url: https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_c3_lcdkit @@ -26,7 +26,7 @@ dependencies: button: public: true - version: ">=2,<4.0" + version: "^4" knob: version: "^0.1.3" diff --git a/bsp/esp32_lyrat/README.md b/bsp/esp32_lyrat/README.md index a33f012e0..fa49b8d60 100644 --- a/bsp/esp32_lyrat/README.md +++ b/bsp/esp32_lyrat/README.md @@ -18,7 +18,7 @@ The ESP32-LyraT is a stereo audio board. If you are looking for a mono audio boa |-------------|------------------|----------------------------------------------------------------------------------------------|-----------| | DISPLAY | :x: | | | | TOUCH | :x: | | | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | >=2.5,<4.0| +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | | AUDIO |:heavy_check_mark:|[espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev)|^1.0.3,<1.2| |AUDIO_SPEAKER|:heavy_check_mark:| | | | AUDIO_MIC |:heavy_check_mark:| | | diff --git a/bsp/esp32_lyrat/esp32_lyrat.c b/bsp/esp32_lyrat/esp32_lyrat.c index b8fda53bc..b5ea0be11 100644 --- a/bsp/esp32_lyrat/esp32_lyrat.c +++ b/bsp/esp32_lyrat/esp32_lyrat.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,54 +13,88 @@ #include "esp_spiffs.h" #include "bsp_err_check.h" #include "esp_codec_dev_defaults.h" +#include "button_gpio.h" static const char *TAG = "LyraT"; sdmmc_card_t *bsp_sdcard = NULL; // Global uSD card handler -static esp_err_t bsp_touchpad_custom_init(void *param); -static esp_err_t bsp_touchpad_custom_deinit(void *param); -static uint8_t bsp_touchpad_custom_get_key_value(void *param); +static esp_err_t bsp_touchpad_custom_deinit(button_driver_t *button_driver); +static uint8_t bsp_touchpad_custom_get_key_value(button_driver_t *button_driver); static bool i2c_initialized = false; -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +typedef enum { + BSP_BUTTON_TYPE_GPIO, + BSP_BUTTON_TYPE_CUSTOM +} bsp_button_type_t; + +typedef struct { + button_driver_t base; + touch_pad_t key; +} bsp_button_type_custom_t; + +typedef struct { + bsp_button_type_t type; + union { + button_gpio_config_t gpio; + bsp_button_type_custom_t custom; + } cfg; +} bsp_button_config_t; + +static const bsp_button_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_BUTTON_REC_IO, - .gpio_button_config.active_level = 0, + .type = BSP_BUTTON_TYPE_GPIO, + .cfg.gpio = { + .gpio_num = BSP_BUTTON_REC_IO, + .active_level = 0, + } }, { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_BUTTON_MODE_IO, - .gpio_button_config.active_level = 0, + .type = BSP_BUTTON_TYPE_GPIO, + .cfg.gpio = { + .gpio_num = BSP_BUTTON_MODE_IO, + .active_level = 0, + } }, { - .type = BUTTON_TYPE_CUSTOM, - .custom_button_config.button_custom_init = bsp_touchpad_custom_init, - .custom_button_config.button_custom_get_key_value = bsp_touchpad_custom_get_key_value, - .custom_button_config.button_custom_deinit = bsp_touchpad_custom_deinit, - .custom_button_config.priv = (void *)BSP_BUTTON_PLAY_TOUCH, + .type = BSP_BUTTON_TYPE_CUSTOM, + .cfg.custom = { + .base = { + .get_key_level = bsp_touchpad_custom_get_key_value, + .del = bsp_touchpad_custom_deinit, + }, + .key = BSP_BUTTON_PLAY_TOUCH + } }, { - .type = BUTTON_TYPE_CUSTOM, - .custom_button_config.button_custom_init = bsp_touchpad_custom_init, - .custom_button_config.button_custom_get_key_value = bsp_touchpad_custom_get_key_value, - .custom_button_config.button_custom_deinit = bsp_touchpad_custom_deinit, - .custom_button_config.priv = (void *)BSP_BUTTON_SET_TOUCH, + .type = BSP_BUTTON_TYPE_CUSTOM, + .cfg.custom = { + .base = { + .get_key_level = bsp_touchpad_custom_get_key_value, + .del = bsp_touchpad_custom_deinit, + }, + .key = BSP_BUTTON_SET_TOUCH + } }, { - .type = BUTTON_TYPE_CUSTOM, - .custom_button_config.button_custom_init = bsp_touchpad_custom_init, - .custom_button_config.button_custom_get_key_value = bsp_touchpad_custom_get_key_value, - .custom_button_config.button_custom_deinit = bsp_touchpad_custom_deinit, - .custom_button_config.priv = (void *)BSP_BUTTON_VOLUP_TOUCH, + .type = BSP_BUTTON_TYPE_CUSTOM, + .cfg.custom = { + .base = { + .get_key_level = bsp_touchpad_custom_get_key_value, + .del = bsp_touchpad_custom_deinit, + }, + .key = BSP_BUTTON_VOLUP_TOUCH + } }, { - .type = BUTTON_TYPE_CUSTOM, - .custom_button_config.button_custom_init = bsp_touchpad_custom_init, - .custom_button_config.button_custom_get_key_value = bsp_touchpad_custom_get_key_value, - .custom_button_config.button_custom_deinit = bsp_touchpad_custom_deinit, - .custom_button_config.priv = (void *)BSP_BUTTON_VOLDOWN_TOUCH, + .type = BSP_BUTTON_TYPE_CUSTOM, + .cfg.custom = { + .base = { + .get_key_level = bsp_touchpad_custom_get_key_value, + .del = bsp_touchpad_custom_deinit, + }, + .key = BSP_BUTTON_VOLDOWN_TOUCH + } } }; @@ -217,10 +251,9 @@ esp_codec_dev_handle_t bsp_audio_codec_microphone_init(void) #define TOUCHPAD_FILTER_TOUCH_PERIOD (50) #define TOUCHPAD_THRESH (400) -static esp_err_t bsp_touchpad_custom_init(void *param) +static esp_err_t bsp_touchpad_custom_init(touch_pad_t key) { static bool touch_pad_initialized = false; - touch_pad_t btn = (touch_pad_t)param; if (!touch_pad_initialized) { /*!< Initialize touch pad peripheral, it will start a timer to run a filter */ @@ -235,26 +268,24 @@ static esp_err_t bsp_touchpad_custom_init(void *param) touch_pad_initialized = true; } - BSP_ERROR_CHECK_RETURN_ERR(touch_pad_config(btn, 0)); + BSP_ERROR_CHECK_RETURN_ERR(touch_pad_config(key, 0)); - ESP_LOGI(TAG, "Initialized touch button %d", btn); + ESP_LOGI(TAG, "Initialized touch button %d", key); return ESP_OK; } -static esp_err_t bsp_touchpad_custom_deinit(void *param) +static esp_err_t bsp_touchpad_custom_deinit(button_driver_t *button_driver) { - //touch_pad_t btn = (touch_pad_t)param; - return ESP_OK; } -static uint8_t bsp_touchpad_custom_get_key_value(void *param) +static uint8_t bsp_touchpad_custom_get_key_value(button_driver_t *button_driver) { - touch_pad_t btn = (touch_pad_t)param; + bsp_button_type_custom_t *custom_btn = __containerof(button_driver, bsp_button_type_custom_t, base); uint16_t touch_value; - touch_pad_read_raw_data(btn, &touch_value); + touch_pad_read_raw_data(custom_btn->key, &touch_value); return (touch_value > 0 && touch_value < TOUCHPAD_THRESH ? 0 : 1); } @@ -281,6 +312,7 @@ esp_err_t bsp_led_set(const bsp_led_t led_io, const bool on) esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size) { esp_err_t ret = ESP_OK; + const button_config_t btn_config = {0}; if ((btn_array_size < BSP_BUTTON_NUM) || (btn_array == NULL)) { return ESP_ERR_INVALID_ARG; @@ -290,10 +322,13 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b *btn_cnt = 0; } for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); - if (btn_array[i] == NULL) { - ret = ESP_FAIL; - break; + if (bsp_button_config[i].type == BSP_BUTTON_TYPE_CUSTOM) { + ret |= bsp_touchpad_custom_init(bsp_button_config[i].cfg.custom.key); + ret |= iot_button_create(&btn_config, &bsp_button_config[i].cfg.custom.base, &btn_array[i]); + } else if (bsp_button_config[i].type == BSP_BUTTON_TYPE_GPIO) { + ret |= iot_button_new_gpio_device(&btn_config, &bsp_button_config[i].cfg.gpio, &btn_array[i]); + } else { + ESP_LOGW(TAG, "Unsupported button type!"); } if (btn_cnt) { (*btn_cnt)++; diff --git a/bsp/esp32_lyrat/idf_component.yml b/bsp/esp32_lyrat/idf_component.yml index 08f8f3152..6c1f8fb00 100644 --- a/bsp/esp32_lyrat/idf_component.yml +++ b/bsp/esp32_lyrat/idf_component.yml @@ -12,7 +12,7 @@ dependencies: idf: ">=4.4" button: - version: ">=2.5,<4.0" + version: "^4" public: true esp_codec_dev: diff --git a/bsp/esp32_s2_kaluga_kit/README.md b/bsp/esp32_s2_kaluga_kit/README.md index f6994168b..28f3cc887 100644 --- a/bsp/esp32_s2_kaluga_kit/README.md +++ b/bsp/esp32_s2_kaluga_kit/README.md @@ -20,17 +20,17 @@ The ESP32-S2-Kaluga-1 kit v1.3 is a development kit by Espressif that is mainly ### Capabilities and dependencies -| Capability | Available | Component | Version | -|-------------|------------------|----------------------------------------------------------------------------------------------|----------| -| DISPLAY |:heavy_check_mark:| idf | >=5.4 | -| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | -| TOUCH | :x: | | | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0| -| AUDIO |:heavy_check_mark:|[espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev)| ~1.3.1 | -|AUDIO_SPEAKER|:heavy_check_mark:| | | -| AUDIO_MIC |:heavy_check_mark:| | | -| LED |:heavy_check_mark:| idf | >=5.4 | -| SDCARD | :x: | | | -| IMU | :x: | | | -| CAMERA |:heavy_check_mark:| [espressif/esp32-camera](https://components.espressif.com/components/espressif/esp32-camera) | ^2.0.14 | +| Capability | Available | Component |Version| +|-------------|------------------|----------------------------------------------------------------------------------------------|-------| +| DISPLAY |:heavy_check_mark:| idf | >=5.4 | +| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | +| TOUCH | :x: | | | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | +| AUDIO |:heavy_check_mark:|[espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev)| ~1.3.1| +|AUDIO_SPEAKER|:heavy_check_mark:| | | +| AUDIO_MIC |:heavy_check_mark:| | | +| LED |:heavy_check_mark:| idf | >=5.4 | +| SDCARD | :x: | | | +| IMU | :x: | | | +| CAMERA |:heavy_check_mark:| [espressif/esp32-camera](https://components.espressif.com/components/espressif/esp32-camera) |^2.0.14| diff --git a/bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit.c b/bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit.c index e113b3a20..dce5098a3 100644 --- a/bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit.c +++ b/bsp/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ #include "esp_lvgl_port.h" #include "esp_codec_dev_defaults.h" #include "bsp_err_check.h" +#include "button_adc.h" static const char *TAG = "Kaluga"; @@ -44,60 +45,55 @@ static const touch_pad_t bsp_touch_button[TOUCH_BUTTON_NUM] = { TOUCH_BUTTON_GUARD, /*!< Guard ring for waterproof design. If this pad is touched, other pads no response.*/ }; -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +static const button_adc_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 - .adc_button_config.button_index = BSP_BUTTON_REC, - .adc_button_config.min = 2310, // middle is 2410mV - .adc_button_config.max = 2510 + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 + .button_index = BSP_BUTTON_REC, + .min = 2310, // middle is 2410mV + .max = 2510 }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 - .adc_button_config.button_index = BSP_BUTTON_MODE, - .adc_button_config.min = 1880, // middle is 1980mV - .adc_button_config.max = 2080 + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 + .button_index = BSP_BUTTON_MODE, + .min = 1880, // middle is 1980mV + .max = 2080 }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 - .adc_button_config.button_index = BSP_BUTTON_PLAY, - .adc_button_config.min = 1550, // middle is 1650mV - .adc_button_config.max = 1750 + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 + .button_index = BSP_BUTTON_PLAY, + .min = 1550, // middle is 1650mV + .max = 1750 }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 - .adc_button_config.button_index = BSP_BUTTON_SET, - .adc_button_config.min = 1010, // middle is 1110mV - .adc_button_config.max = 1210 + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 + .button_index = BSP_BUTTON_SET, + .min = 1010, // middle is 1110mV + .max = 1210 }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 - .adc_button_config.button_index = BSP_BUTTON_VOLDOWN, - .adc_button_config.min = 720, // middle is 820mV - .adc_button_config.max = 920 + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 + .button_index = BSP_BUTTON_VOLDOWN, + .min = 720, // middle is 820mV + .max = 920 }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 - .adc_button_config.button_index = BSP_BUTTON_VOLUP, - .adc_button_config.min = 280, // middle is 380mV - .adc_button_config.max = 480 + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_5, // ADC1 channel 5 is GPIO6 + .button_index = BSP_BUTTON_VOLUP, + .min = 280, // middle is 380mV + .max = 480 } }; esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size) { esp_err_t ret = ESP_OK; + const button_config_t btn_config = {0}; if ((btn_array_size < BSP_BUTTON_NUM) || (btn_array == NULL)) { return ESP_ERR_INVALID_ARG; @@ -111,11 +107,7 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b *btn_cnt = 0; } for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); - if (btn_array[i] == NULL) { - ret = ESP_FAIL; - break; - } + ret |= iot_button_new_adc_device(&btn_config, &bsp_button_config[i], &btn_array[i]); if (btn_cnt) { (*btn_cnt)++; } diff --git a/bsp/esp32_s2_kaluga_kit/idf_component.yml b/bsp/esp32_s2_kaluga_kit/idf_component.yml index 0325d095b..d6b623719 100644 --- a/bsp/esp32_s2_kaluga_kit/idf_component.yml +++ b/bsp/esp32_s2_kaluga_kit/idf_component.yml @@ -1,4 +1,4 @@ -version: "4.0.0" +version: "5.0.0" description: Board Support Package (BSP) for ESP32-S2-Kaluga kit url: https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_s2_kaluga_kit @@ -17,7 +17,7 @@ dependencies: override_path: "../../components/esp_lvgl_port" button: - version: ">=2.5,<4.0" + version: "^4" public: true esp_codec_dev: diff --git a/bsp/esp32_s2_kaluga_kit/include/bsp/esp32_s2_kaluga_kit.h b/bsp/esp32_s2_kaluga_kit/include/bsp/esp32_s2_kaluga_kit.h index e2b4d2fd0..ec0f75124 100644 --- a/bsp/esp32_s2_kaluga_kit/include/bsp/esp32_s2_kaluga_kit.h +++ b/bsp/esp32_s2_kaluga_kit/include/bsp/esp32_s2_kaluga_kit.h @@ -20,6 +20,7 @@ #include "esp_lvgl_port.h" #include "esp_codec_dev.h" #include "bsp/display.h" +#include "esp_adc/adc_oneshot.h" /************************************************************************************************** * BSP Capabilities diff --git a/bsp/esp32_s3_eye/README.md b/bsp/esp32_s3_eye/README.md index 1e2837ab0..77370eb4f 100644 --- a/bsp/esp32_s3_eye/README.md +++ b/bsp/esp32_s3_eye/README.md @@ -20,16 +20,16 @@ The ESP32-S3-EYE board consists of two parts: the main board (ESP32-S3-EYE-MB) t ### Capabilities and dependencies -| Capability | Available | Component | Version | -|-------------|------------------|----------------------------------------------------------------------------------------------|----------| -| DISPLAY |:heavy_check_mark:| idf | >=5.4 | -| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | -| TOUCH | :x: | | | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0| -| AUDIO |:heavy_check_mark:|[espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev)| ~1.3.1 | -|AUDIO_SPEAKER| :x: | | | -| AUDIO_MIC |:heavy_check_mark:| | | -| SDCARD |:heavy_check_mark:| idf | >=5.4 | -| IMU |:heavy_check_mark:| [qma6100p](https://components.espressif.com/components/qma6100p) | ^2 | -| CAMERA |:heavy_check_mark:| [espressif/esp32-camera](https://components.espressif.com/components/espressif/esp32-camera) | ^2.0.13 | +| Capability | Available | Component |Version| +|-------------|------------------|----------------------------------------------------------------------------------------------|-------| +| DISPLAY |:heavy_check_mark:| idf | >=5.4 | +| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | +| TOUCH | :x: | | | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | +| AUDIO |:heavy_check_mark:|[espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev)| ~1.3.1| +|AUDIO_SPEAKER| :x: | | | +| AUDIO_MIC |:heavy_check_mark:| | | +| SDCARD |:heavy_check_mark:| idf | >=5.4 | +| IMU |:heavy_check_mark:| [qma6100p](https://components.espressif.com/components/qma6100p) | ^2 | +| CAMERA |:heavy_check_mark:| [espressif/esp32-camera](https://components.espressif.com/components/espressif/esp32-camera) |^2.0.13| diff --git a/bsp/esp32_s3_eye/esp32_s3_eye.c b/bsp/esp32_s3_eye/esp32_s3_eye.c index 4c03ab78c..ffd94c6b7 100644 --- a/bsp/esp32_s3_eye/esp32_s3_eye.c +++ b/bsp/esp32_s3_eye/esp32_s3_eye.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -24,6 +24,8 @@ #include "bsp/esp32_s3_eye.h" #include "bsp_err_check.h" #include "bsp/display.h" +#include "button_gpio.h" +#include "button_adc.h" static const char *TAG = "S3-EYE"; @@ -40,43 +42,66 @@ static bool i2c_initialized = false; static adc_oneshot_unit_handle_t bsp_adc_handle = NULL; sdmmc_card_t *bsp_sdcard = NULL; // Global uSD card handler -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +typedef enum { + BSP_BUTTON_TYPE_GPIO, + BSP_BUTTON_TYPE_ADC +} bsp_button_type_t; + +typedef struct { + bsp_button_type_t type; + union { + button_gpio_config_t gpio; + button_adc_config_t adc; + } cfg; +} bsp_button_config_t; + +static const bsp_button_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1 - .adc_button_config.button_index = BSP_BUTTON_MENU, - .adc_button_config.min = 2310, // middle is 2410mV - .adc_button_config.max = 2510 + .type = BSP_BUTTON_TYPE_ADC, + .cfg.adc = { + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1 + .button_index = BSP_BUTTON_MENU, + .min = 2310, // middle is 2410mV + .max = 2510 + } }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1 - .adc_button_config.button_index = BSP_BUTTON_PLAY, - .adc_button_config.min = 1880, // middle is 1980mV - .adc_button_config.max = 2080 + .type = BSP_BUTTON_TYPE_ADC, + .cfg.adc = { + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1 + .button_index = BSP_BUTTON_PLAY, + .min = 1880, // middle is 1980mV + .max = 2080 + } }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1 - .adc_button_config.button_index = BSP_BUTTON_DOWN, - .adc_button_config.min = 720, // middle is 820mV - .adc_button_config.max = 920 + .type = BSP_BUTTON_TYPE_ADC, + .cfg.adc = { + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1 + .button_index = BSP_BUTTON_DOWN, + .min = 720, // middle is 820mV + .max = 920 + } }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1 - .adc_button_config.button_index = BSP_BUTTON_UP, - .adc_button_config.min = 280, // middle is 380mV - .adc_button_config.max = 480 + .type = BSP_BUTTON_TYPE_ADC, + .cfg.adc = { + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1 + .button_index = BSP_BUTTON_UP, + .min = 280, // middle is 380mV + .max = 480 + } }, { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = 0, - .gpio_button_config.gpio_num = BSP_BUTTON_BOOT_IO + .type = BSP_BUTTON_TYPE_GPIO, + .cfg.gpio = { + .active_level = 0, + .gpio_num = BSP_BUTTON_BOOT_IO + } } }; @@ -440,6 +465,7 @@ esp_codec_dev_handle_t bsp_audio_codec_microphone_init(void) esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size) { esp_err_t ret = ESP_OK; + const button_config_t btn_config = {0}; if ((btn_array_size < BSP_BUTTON_NUM) || (btn_array == NULL)) { return ESP_ERR_INVALID_ARG; @@ -452,10 +478,12 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b *btn_cnt = 0; } for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); - if (btn_array[i] == NULL) { - ret = ESP_FAIL; - break; + if (bsp_button_config[i].type == BSP_BUTTON_TYPE_GPIO) { + ret |= iot_button_new_gpio_device(&btn_config, &bsp_button_config[i].cfg.gpio, &btn_array[i]); + } else if (bsp_button_config[i].type == BSP_BUTTON_TYPE_ADC) { + ret |= iot_button_new_adc_device(&btn_config, &bsp_button_config[i].cfg.adc, &btn_array[i]); + } else { + ESP_LOGW(TAG, "Unsupported button type!"); } if (btn_cnt) { (*btn_cnt)++; diff --git a/bsp/esp32_s3_eye/idf_component.yml b/bsp/esp32_s3_eye/idf_component.yml index 72c663a78..d1e6083fe 100644 --- a/bsp/esp32_s3_eye/idf_component.yml +++ b/bsp/esp32_s3_eye/idf_component.yml @@ -21,7 +21,7 @@ dependencies: public: true button: - version: ">=2.5,<4.0" + version: "^4" public: true esp_codec_dev: diff --git a/bsp/esp32_s3_eye/include/bsp/esp32_s3_eye.h b/bsp/esp32_s3_eye/include/bsp/esp32_s3_eye.h index 77f35856c..ca0c11320 100644 --- a/bsp/esp32_s3_eye/include/bsp/esp32_s3_eye.h +++ b/bsp/esp32_s3_eye/include/bsp/esp32_s3_eye.h @@ -20,6 +20,7 @@ #include "bsp/display.h" #include "driver/i2s_std.h" #include "driver/i2c_master.h" +#include "esp_adc/adc_oneshot.h" #if (BSP_CONFIG_NO_GRAPHIC_LIB == 0) #include "lvgl.h" diff --git a/bsp/esp32_s3_korvo_1/README.md b/bsp/esp32_s3_korvo_1/README.md index c29f4c8b6..76abf3e71 100644 --- a/bsp/esp32_s3_korvo_1/README.md +++ b/bsp/esp32_s3_korvo_1/README.md @@ -18,7 +18,7 @@ The ESP32-S3-Korvo-1 board consists of two parts: the main board (ESP32-S3-Korvo |-------------|------------------|----------------------------------------------------------------------------------------------|-----------| | DISPLAY | :x: | | | | TOUCH | :x: | | | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | >=2.5,<4.0| +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | | AUDIO |:heavy_check_mark:|[espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev)| ~1.1.0 | |AUDIO_SPEAKER|:heavy_check_mark:| | | | AUDIO_MIC |:heavy_check_mark:| | | diff --git a/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1.c b/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1.c index 96b27f2c6..84b134832 100644 --- a/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1.c +++ b/bsp/esp32_s3_korvo_1/esp32_s3_korvo_1.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,7 @@ #include "esp_codec_dev_defaults.h" #include "led_indicator.h" #include "esp_vfs_fat.h" +#include "button_adc.h" static const char *TAG = "S3-Korvo-1"; @@ -150,72 +151,67 @@ static adc_oneshot_unit_handle_t bsp_adc_handle = NULL; extern blink_step_t const *bsp_led_blink_defaults_lists[]; -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +static const button_adc_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 + .adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - .adc_button_config.adc_handle = &bsp_adc_handle, + .adc_handle = &bsp_adc_handle, #endif - .adc_button_config.button_index = BSP_BUTTON_REC, - .adc_button_config.min = 2310, // middle is 2410mV - .adc_button_config.max = 2510, + .button_index = BSP_BUTTON_REC, + .min = 2310, // middle is 2410mV + .max = 2510, }, { - .type = BUTTON_TYPE_ADC, #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - .adc_button_config.adc_handle = &bsp_adc_handle, + .adc_handle = &bsp_adc_handle, #endif - .adc_button_config.adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 - .adc_button_config.button_index = BSP_BUTTON_MODE, - .adc_button_config.min = 1880, // middle is 1980mV - .adc_button_config.max = 2080, + .adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 + .button_index = BSP_BUTTON_MODE, + .min = 1880, // middle is 1980mV + .max = 2080, }, { - .type = BUTTON_TYPE_ADC, #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - .adc_button_config.adc_handle = &bsp_adc_handle, + .adc_handle = &bsp_adc_handle, #endif - .adc_button_config.adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 - .adc_button_config.button_index = BSP_BUTTON_PLAY, - .adc_button_config.min = 1560, // middle is 1660mV - .adc_button_config.max = 1760, + .adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 + .button_index = BSP_BUTTON_PLAY, + .min = 1560, // middle is 1660mV + .max = 1760, }, { - .type = BUTTON_TYPE_ADC, #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - .adc_button_config.adc_handle = &bsp_adc_handle, + .adc_handle = &bsp_adc_handle, #endif - .adc_button_config.adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 - .adc_button_config.button_index = BSP_BUTTON_SET, - .adc_button_config.min = 1010, // middle is 1100mV - .adc_button_config.max = 1210, + .adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 + .button_index = BSP_BUTTON_SET, + .min = 1010, // middle is 1100mV + .max = 1210, }, { - .type = BUTTON_TYPE_ADC, #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - .adc_button_config.adc_handle = &bsp_adc_handle, + .adc_handle = &bsp_adc_handle, #endif - .adc_button_config.adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 - .adc_button_config.button_index = BSP_BUTTON_VOLDOWN, - .adc_button_config.min = 720, // middle is 820mV - .adc_button_config.max = 920, + .adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 + .button_index = BSP_BUTTON_VOLDOWN, + .min = 720, // middle is 820mV + .max = 920, }, { - .type = BUTTON_TYPE_ADC, #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - .adc_button_config.adc_handle = &bsp_adc_handle, + .adc_handle = &bsp_adc_handle, #endif - .adc_button_config.adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 - .adc_button_config.button_index = BSP_BUTTON_VOLUP, - .adc_button_config.min = 280, // middle is 380mV - .adc_button_config.max = 480, + .adc_channel = ADC_CHANNEL_7, // ADC1 channel 7 is GPIO8 + .button_index = BSP_BUTTON_VOLUP, + .min = 280, // middle is 380mV + .max = 480, } }; esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size) { esp_err_t ret = ESP_OK; + const button_config_t btn_config = {0}; if ((btn_array_size < BSP_BUTTON_NUM) || (btn_array == NULL)) { return ESP_ERR_INVALID_ARG; @@ -230,11 +226,7 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b *btn_cnt = 0; } for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); - if (btn_array[i] == NULL) { - ret = ESP_FAIL; - break; - } + ret |= iot_button_new_adc_device(&btn_config, &bsp_button_config[i], &btn_array[i]); if (btn_cnt) { (*btn_cnt)++; } diff --git a/bsp/esp32_s3_korvo_1/idf_component.yml b/bsp/esp32_s3_korvo_1/idf_component.yml index 7895a0c63..f8be09786 100644 --- a/bsp/esp32_s3_korvo_1/idf_component.yml +++ b/bsp/esp32_s3_korvo_1/idf_component.yml @@ -16,7 +16,7 @@ dependencies: public: true button: - version: ">=2.5,<4.0" + version: "^4" public: true esp_codec_dev: diff --git a/bsp/esp32_s3_korvo_1/include/bsp/esp32_s3_korvo_1.h b/bsp/esp32_s3_korvo_1/include/bsp/esp32_s3_korvo_1.h index ccc0749a7..029b497e2 100644 --- a/bsp/esp32_s3_korvo_1/include/bsp/esp32_s3_korvo_1.h +++ b/bsp/esp32_s3_korvo_1/include/bsp/esp32_s3_korvo_1.h @@ -22,6 +22,7 @@ #else #include "driver/i2s_std.h" #include "driver/i2s_tdm.h" +#include "esp_adc/adc_oneshot.h" #endif /************************************************************************************************** * BSP Capabilities diff --git a/bsp/esp32_s3_korvo_2/README.md b/bsp/esp32_s3_korvo_2/README.md index 3191ab41a..2a71c0254 100644 --- a/bsp/esp32_s3_korvo_2/README.md +++ b/bsp/esp32_s3_korvo_2/README.md @@ -12,17 +12,17 @@ The ESP32-S3-Korvo-2 is a multimedia development board based on the ESP32-S3 chi ### 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) | ^2 | -| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_tt21100](https://components.espressif.com/components/espressif/esp_lcd_touch_tt21100)| ^1 | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0| -| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ~1.3.1 | -|AUDIO_SPEAKER|:heavy_check_mark:| | | -| AUDIO_MIC |:heavy_check_mark:| | | -| LED |:heavy_check_mark:| idf | >=5.4 | -| SDCARD |:heavy_check_mark:| idf | >=5.4 | -| IMU | :x: | | | -| CAMERA |:heavy_check_mark:| [espressif/esp32-camera](https://components.espressif.com/components/espressif/esp32-camera) | ^2.0.13 | +| 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) | ^2 | +| TOUCH |:heavy_check_mark:|[espressif/esp_lcd_touch_tt21100](https://components.espressif.com/components/espressif/esp_lcd_touch_tt21100)| ^1 | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | +| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ~1.3.1| +|AUDIO_SPEAKER|:heavy_check_mark:| | | +| AUDIO_MIC |:heavy_check_mark:| | | +| LED |:heavy_check_mark:| idf | >=5.4 | +| SDCARD |:heavy_check_mark:| idf | >=5.4 | +| IMU | :x: | | | +| CAMERA |:heavy_check_mark:| [espressif/esp32-camera](https://components.espressif.com/components/espressif/esp32-camera) |^2.0.13| diff --git a/bsp/esp32_s3_korvo_2/esp32_s3_korvo_2.c b/bsp/esp32_s3_korvo_2/esp32_s3_korvo_2.c index e5aa2d59b..3863adaa1 100644 --- a/bsp/esp32_s3_korvo_2/esp32_s3_korvo_2.c +++ b/bsp/esp32_s3_korvo_2/esp32_s3_korvo_2.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -26,6 +26,8 @@ #include "esp_vfs_fat.h" #include "esp_codec_dev_defaults.h" #include "bsp_err_check.h" +#include "iot_button.h" +#include "button_adc.h" static const char *TAG = "S3-KORVO-2"; @@ -46,65 +48,90 @@ static lv_indev_t *disp_indev = NULL; static adc_oneshot_unit_handle_t bsp_adc_handle = NULL; // This is just a wrapper to get function signature for espressif/button API callback -static uint8_t bsp_get_main_button(void *param); -static esp_err_t bsp_init_main_button(void *param); - -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +static uint8_t bsp_get_main_button(button_driver_t *button_driver); + +typedef enum { + BSP_BUTTON_TYPE_ADC, + BSP_BUTTON_TYPE_CUSTOM +} bsp_button_type_t; + +typedef struct { + bsp_button_type_t type; + union { + button_adc_config_t adc; + button_driver_t custom; + } cfg; +} bsp_button_config_t; + +static const bsp_button_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 - .adc_button_config.button_index = BSP_BUTTON_REC, - .adc_button_config.min = 2310, // middle is 2410mV - .adc_button_config.max = 2510 + .type = BSP_BUTTON_TYPE_ADC, + .cfg.adc = { + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 + .button_index = BSP_BUTTON_REC, + .min = 2310, // middle is 2410mV + .max = 2510 + } }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 - .adc_button_config.button_index = BSP_BUTTON_MUTE, - .adc_button_config.min = 1880, // middle is 1980mV - .adc_button_config.max = 2080 + .type = BSP_BUTTON_TYPE_ADC, + .cfg.adc = { + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 + .button_index = BSP_BUTTON_MUTE, + .min = 1880, // middle is 1980mV + .max = 2080 + } }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 - .adc_button_config.button_index = BSP_BUTTON_PLAY, - .adc_button_config.min = 1550, // middle is 1650mV - .adc_button_config.max = 1750 + .type = BSP_BUTTON_TYPE_ADC, + .cfg.adc = { + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 + .button_index = BSP_BUTTON_PLAY, + .min = 1550, // middle is 1650mV + .max = 1750 + } }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 - .adc_button_config.button_index = BSP_BUTTON_SET, - .adc_button_config.min = 1010, // middle is 1110mV - .adc_button_config.max = 1210 + .type = BSP_BUTTON_TYPE_ADC, + .cfg.adc = { + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 + .button_index = BSP_BUTTON_SET, + .min = 1010, // middle is 1110mV + .max = 1210 + } }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 - .adc_button_config.button_index = BSP_BUTTON_VOLDOWN, - .adc_button_config.min = 720, // middle is 820mV - .adc_button_config.max = 920 + .type = BSP_BUTTON_TYPE_ADC, + .cfg.adc = { + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 + .button_index = BSP_BUTTON_VOLDOWN, + .min = 720, // middle is 820mV + .max = 920 + } }, { - .type = BUTTON_TYPE_ADC, - .adc_button_config.adc_handle = &bsp_adc_handle, - .adc_button_config.adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 - .adc_button_config.button_index = BSP_BUTTON_VOLUP, - .adc_button_config.min = 280, // middle is 380mV - .adc_button_config.max = 480 + .type = BSP_BUTTON_TYPE_ADC, + .cfg.adc = { + .adc_handle = &bsp_adc_handle, + .adc_channel = ADC_CHANNEL_4, // ADC1 channel 4 is GPIO5 + .button_index = BSP_BUTTON_VOLUP, + .min = 280, // middle is 380mV + .max = 480 + } }, { - .type = BUTTON_TYPE_CUSTOM, - .custom_button_config.button_custom_init = bsp_init_main_button, - .custom_button_config.button_custom_get_key_value = bsp_get_main_button, - .custom_button_config.button_custom_deinit = NULL, - .custom_button_config.active_level = 1, - .custom_button_config.priv = (void *) BSP_BUTTON_MAIN, + .type = BSP_BUTTON_TYPE_CUSTOM, + .cfg.custom = { + .enable_power_save = false, + .get_key_level = bsp_get_main_button, + .enter_power_save = NULL, + .del = NULL + } } }; @@ -547,7 +574,7 @@ bool bsp_button_get(const bsp_button_t btn) return false; } -static uint8_t bsp_get_main_button(void *param) +static uint8_t bsp_get_main_button(button_driver_t *button_driver) { assert(tp); ESP_ERROR_CHECK(esp_lcd_touch_read_data(tp)); @@ -561,17 +588,10 @@ static uint8_t bsp_get_main_button(void *param) #endif } -static esp_err_t bsp_init_main_button(void *param) -{ - if (tp == NULL) { - BSP_ERROR_CHECK_RETURN_ERR(bsp_touch_new(NULL, &tp)); - } - return ESP_OK; -} - esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size) { esp_err_t ret = ESP_OK; + const button_config_t btn_config = {0}; if ((btn_array_size < BSP_BUTTON_NUM) || (btn_array == NULL)) { return ESP_ERR_INVALID_ARG; @@ -584,10 +604,15 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b *btn_cnt = 0; } for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); - if (btn_array[i] == NULL) { - ret = ESP_FAIL; - break; + if (bsp_button_config[i].type == BSP_BUTTON_TYPE_CUSTOM) { + if (tp == NULL) { + BSP_ERROR_CHECK_RETURN_ERR(bsp_touch_new(NULL, &tp)); + } + ret |= iot_button_create(&btn_config, &bsp_button_config[i].cfg.custom, &btn_array[i]); + } else if (bsp_button_config[i].type == BSP_BUTTON_TYPE_ADC) { + ret |= iot_button_new_adc_device(&btn_config, &bsp_button_config[i].cfg.adc, &btn_array[i]); + } else { + ESP_LOGW(TAG, "Unsupported button type!"); } if (btn_cnt) { (*btn_cnt)++; diff --git a/bsp/esp32_s3_korvo_2/idf_component.yml b/bsp/esp32_s3_korvo_2/idf_component.yml index 6e83ce6c2..91cba904f 100644 --- a/bsp/esp32_s3_korvo_2/idf_component.yml +++ b/bsp/esp32_s3_korvo_2/idf_component.yml @@ -26,7 +26,7 @@ dependencies: public: true button: - version: ">=2.5,<4.0" + version: "^4" public: true espressif/esp_lvgl_port: diff --git a/bsp/esp32_s3_lcd_ev_board/README.md b/bsp/esp32_s3_lcd_ev_board/README.md index aecd88fbc..6bbd8a532 100644 --- a/bsp/esp32_s3_lcd_ev_board/README.md +++ b/bsp/esp32_s3_lcd_ev_board/README.md @@ -51,15 +51,15 @@ Based on the above configurations, there are three different anti-tearing modes ### Capabilities and dependencies -| Capability | Available | Component | Version | -|-------------|------------------|------------------------------------------------------------------------------------------------------------|----------| -| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_gc9503](https://components.espressif.com/components/espressif/esp_lcd_gc9503) | ^3 | -| 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_ft5x06](https://components.espressif.com/components/espressif/esp_lcd_touch_ft5x06)| ^1 | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0| -| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ~1.3.1 | -|AUDIO_SPEAKER|:heavy_check_mark:| | | -| AUDIO_MIC |:heavy_check_mark:| | | -| SDCARD | :x: | | | -| IMU | :x: | | | +| Capability | Available | Component |Version| +|-------------|------------------|------------------------------------------------------------------------------------------------------------|-------| +| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_gc9503](https://components.espressif.com/components/espressif/esp_lcd_gc9503) | ^3 | +| 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_ft5x06](https://components.espressif.com/components/espressif/esp_lcd_touch_ft5x06)| ^1 | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | +| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ~1.3.1| +|AUDIO_SPEAKER|:heavy_check_mark:| | | +| AUDIO_MIC |:heavy_check_mark:| | | +| SDCARD | :x: | | | +| IMU | :x: | | | diff --git a/bsp/esp32_s3_lcd_ev_board/idf_component.yml b/bsp/esp32_s3_lcd_ev_board/idf_component.yml index 86ffeb1e1..1a63a08d3 100644 --- a/bsp/esp32_s3_lcd_ev_board/idf_component.yml +++ b/bsp/esp32_s3_lcd_ev_board/idf_component.yml @@ -1,4 +1,4 @@ -version: "3.0.0" +version: "4.0.0" description: Board Support Package (BSP) for ESP32-S3-LCD-EV-Board url: https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_s3_lcd_ev_board @@ -27,7 +27,7 @@ dependencies: public: true button: - version: ">=2.5,<4.0" + version: "^4" public: true espressif/esp_lvgl_port: diff --git a/bsp/esp32_s3_lcd_ev_board/src/esp32_s3_lcd_ev_board.c b/bsp/esp32_s3_lcd_ev_board/src/esp32_s3_lcd_ev_board.c index 461bec2f6..d57a62598 100644 --- a/bsp/esp32_s3_lcd_ev_board/src/esp32_s3_lcd_ev_board.c +++ b/bsp/esp32_s3_lcd_ev_board/src/esp32_s3_lcd_ev_board.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -17,6 +17,7 @@ #include "esp_log.h" #include "esp_spiffs.h" #include "iot_button.h" +#include "button_gpio.h" #include "lvgl.h" #include "bsp/display.h" @@ -74,11 +75,10 @@ static lv_display_t *disp; static lv_indev_t *disp_indev = NULL; static esp_lcd_touch_handle_t tp; // LCD touch handle -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +static const button_gpio_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_BUTTON_BOOT_IO, - .gpio_button_config.active_level = 0, + .gpio_num = BSP_BUTTON_BOOT_IO, + .active_level = 0, }, }; /************************************************************************************************** @@ -506,6 +506,7 @@ bool bsp_button_get(const bsp_button_t btn) esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size) { esp_err_t ret = ESP_OK; + const button_config_t btn_config = {0}; if ((btn_array_size < BSP_BUTTON_NUM) || (btn_array == NULL)) { return ESP_ERR_INVALID_ARG; @@ -515,11 +516,7 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b *btn_cnt = 0; } for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); - if (btn_array[i] == NULL) { - ret = ESP_FAIL; - break; - } + ret |= iot_button_new_gpio_device(&btn_config, &bsp_button_config[i], &btn_array[i]); if (btn_cnt) { (*btn_cnt)++; } diff --git a/bsp/esp32_s3_usb_otg/README.md b/bsp/esp32_s3_usb_otg/README.md index 587a447ab..b9ea461b1 100644 --- a/bsp/esp32_s3_usb_otg/README.md +++ b/bsp/esp32_s3_usb_otg/README.md @@ -20,17 +20,17 @@ ESP32-S3-USB-OTG is a development board that focuses on USB-OTG function verific ### Capabilities and dependencies -| Capability | Available | Component | Version | -|-------------|------------------|----------------------------------------------------------------------------------------------|----------| -| DISPLAY |:heavy_check_mark:| idf | >=4.4 | -| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | -| TOUCH | :x: | | | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0| -| AUDIO | :x: | | | -|AUDIO_SPEAKER| :x: | | | -| AUDIO_MIC | :x: | | | -| SDCARD |:heavy_check_mark:| idf | >=4.4 | -| IMU | :x: | | | -| LED |:heavy_check_mark:| idf | >=4.4 | -| BAT |:heavy_check_mark:| idf | >=4.4 | +| Capability | Available | Component |Version| +|-------------|------------------|----------------------------------------------------------------------------------------------|-------| +| DISPLAY |:heavy_check_mark:| idf | >=4.4 | +| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | +| TOUCH | :x: | | | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | +| AUDIO | :x: | | | +|AUDIO_SPEAKER| :x: | | | +| AUDIO_MIC | :x: | | | +| SDCARD |:heavy_check_mark:| idf | >=4.4 | +| IMU | :x: | | | +| LED |:heavy_check_mark:| idf | >=4.4 | +| BAT |:heavy_check_mark:| idf | >=4.4 | diff --git a/bsp/esp32_s3_usb_otg/esp32_s3_usb_otg.c b/bsp/esp32_s3_usb_otg/esp32_s3_usb_otg.c index 822134373..fd9d98597 100644 --- a/bsp/esp32_s3_usb_otg/esp32_s3_usb_otg.c +++ b/bsp/esp32_s3_usb_otg/esp32_s3_usb_otg.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -25,37 +25,33 @@ #include "bsp/display.h" #include "esp_lvgl_port.h" #include "bsp_err_check.h" +#include "button_gpio.h" static const char *TAG = "USB-OTG"; static TaskHandle_t usb_host_task; // USB Host Library task sdmmc_card_t *bsp_sdcard = NULL; // Global uSD card handler -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +static const button_gpio_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_BUTTON_OK_IO, - .gpio_button_config.active_level = 0, + .gpio_num = BSP_BUTTON_OK_IO, + .active_level = 0, }, { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_BUTTON_DW_IO, - .gpio_button_config.active_level = 0, + .gpio_num = BSP_BUTTON_DW_IO, + .active_level = 0, }, { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_BUTTON_UP_IO, - .gpio_button_config.active_level = 0, + .gpio_num = BSP_BUTTON_UP_IO, + .active_level = 0, }, { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_BUTTON_MENU_IO, - .gpio_button_config.active_level = 0, + .gpio_num = BSP_BUTTON_MENU_IO, + .active_level = 0, }, { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_USB_OVERCURRENT_IO, - .gpio_button_config.active_level = 0, + .gpio_num = BSP_USB_OVERCURRENT_IO, + .active_level = 0, }, }; @@ -191,6 +187,7 @@ bool bsp_button_get(const bsp_button_t btn) esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size) { esp_err_t ret = ESP_OK; + const button_config_t btn_config = {0}; if ((btn_array_size < BSP_BUTTON_NUM) || (btn_array == NULL)) { return ESP_ERR_INVALID_ARG; @@ -200,11 +197,7 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b *btn_cnt = 0; } for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); - if (btn_array[i] == NULL) { - ret = ESP_FAIL; - break; - } + ret |= iot_button_new_gpio_device(&btn_config, &bsp_button_config[i], &btn_array[i]); if (btn_cnt) { (*btn_cnt)++; } diff --git a/bsp/esp32_s3_usb_otg/idf_component.yml b/bsp/esp32_s3_usb_otg/idf_component.yml index 2b408d840..1f977b49b 100644 --- a/bsp/esp32_s3_usb_otg/idf_component.yml +++ b/bsp/esp32_s3_usb_otg/idf_component.yml @@ -12,7 +12,7 @@ dependencies: idf: ">=4.4" button: - version: ">=2.5,<4.0" + version: "^4" public: true espressif/esp_lvgl_port: diff --git a/bsp/esp32_s3_usb_otg/include/bsp/esp32_s3_usb_otg.h b/bsp/esp32_s3_usb_otg/include/bsp/esp32_s3_usb_otg.h index 2cfd2a1d9..2bc2a264d 100644 --- a/bsp/esp32_s3_usb_otg/include/bsp/esp32_s3_usb_otg.h +++ b/bsp/esp32_s3_usb_otg/include/bsp/esp32_s3_usb_otg.h @@ -18,6 +18,7 @@ #include "lvgl.h" #include "esp_lvgl_port.h" #include "bsp/display.h" +#include "esp_adc/adc_oneshot.h" /************************************************************************************************** * BSP Capabilities diff --git a/bsp/esp_wrover_kit/README.md b/bsp/esp_wrover_kit/README.md index 8033ee796..031e87707 100644 --- a/bsp/esp_wrover_kit/README.md +++ b/bsp/esp_wrover_kit/README.md @@ -22,17 +22,17 @@ Most of the ESP32 I/O pins are broken out to the board’s pin headers for easy ### Capabilities and dependencies -| Capability | Available | Component | Version | -|-------------|------------------|----------------------------------------------------------------------------------------------|----------| -| DISPLAY |:heavy_check_mark:| idf | >=4.4.5 | -| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | -| TOUCH | :x: | | | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2.5,<4.0| -| AUDIO | :x: | | | -|AUDIO_SPEAKER| :x: | | | -| AUDIO_MIC | :x: | | | -| LED |:heavy_check_mark:| idf | >=4.4.5 | -| SDCARD |:heavy_check_mark:| idf | >=4.4.5 | -| IMU | :x: | | | -| CAMERA | :x: | | | +| Capability | Available | Component |Version| +|-------------|------------------|----------------------------------------------------------------------------------------------|-------| +| DISPLAY |:heavy_check_mark:| idf |>=4.4.5| +| LVGL_PORT |:heavy_check_mark:|[espressif/esp_lvgl_port](https://components.espressif.com/components/espressif/esp_lvgl_port)| ^2 | +| TOUCH | :x: | | | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | +| AUDIO | :x: | | | +|AUDIO_SPEAKER| :x: | | | +| AUDIO_MIC | :x: | | | +| LED |:heavy_check_mark:| idf |>=4.4.5| +| SDCARD |:heavy_check_mark:| idf |>=4.4.5| +| IMU | :x: | | | +| CAMERA | :x: | | | diff --git a/bsp/esp_wrover_kit/esp_wrover_kit.c b/bsp/esp_wrover_kit/esp_wrover_kit.c index aa04412ba..ecbb87232 100644 --- a/bsp/esp_wrover_kit/esp_wrover_kit.c +++ b/bsp/esp_wrover_kit/esp_wrover_kit.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,6 +16,7 @@ #include "driver/ledc.h" #include "iot_button.h" +#include "button_gpio.h" #include "bsp/esp_wrover_kit.h" #include "bsp/display.h" #include "bsp_err_check.h" @@ -24,11 +25,10 @@ static const char *TAG = "Wrover"; sdmmc_card_t *bsp_sdcard = NULL; // Global uSD card handler -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +static const button_gpio_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.gpio_num = BSP_BUTTON_BOOT_IO, - .gpio_button_config.active_level = 0, + .gpio_num = BSP_BUTTON_BOOT_IO, + .active_level = 0, } }; @@ -129,6 +129,7 @@ bool bsp_button_get(const bsp_button_t btn) esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size) { esp_err_t ret = ESP_OK; + const button_config_t btn_config = {0}; if ((btn_array_size < BSP_BUTTON_NUM) || (btn_array == NULL)) { return ESP_ERR_INVALID_ARG; @@ -138,11 +139,7 @@ esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int b *btn_cnt = 0; } for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); - if (btn_array[i] == NULL) { - ret = ESP_FAIL; - break; - } + ret |= iot_button_new_gpio_device(&btn_config, &bsp_button_config[i], &btn_array[i]); if (btn_cnt) { (*btn_cnt)++; } diff --git a/bsp/esp_wrover_kit/idf_component.yml b/bsp/esp_wrover_kit/idf_component.yml index 570ac1594..b0f4d981d 100644 --- a/bsp/esp_wrover_kit/idf_component.yml +++ b/bsp/esp_wrover_kit/idf_component.yml @@ -17,7 +17,7 @@ dependencies: override_path: "../../components/esp_lvgl_port" button: - version: ">=2.5,<4.0" + version: "^4" public: true examples: diff --git a/bsp/m5dial/README.md b/bsp/m5dial/README.md index 9037cb388..bf5a60958 100644 --- a/bsp/m5dial/README.md +++ b/bsp/m5dial/README.md @@ -20,16 +20,16 @@ M5Dial provides versatile power supply options to cater to various needs. It acc ### Capabilities and dependencies -| Capability | Available | Component | Version| -|-------------|------------------|------------------------------------------------------------------------------------------------------------|--------| -| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_gc9a01](https://components.espressif.com/components/espressif/esp_lcd_gc9a01) | ^1 | -| 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_ft5x06](https://components.espressif.com/components/espressif/esp_lcd_touch_ft5x06)| ^1 | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) |>=2,<4.0| -| KNOB |:heavy_check_mark:| [espressif/knob](https://components.espressif.com/components/espressif/knob) | ^0.1.3 | -| AUDIO | :x: | | | -|AUDIO_SPEAKER| :x: | | | -| AUDIO_MIC | :x: | | | -| SDCARD | :x: | | | -| IMU | :x: | | | +| Capability | Available | Component |Version| +|-------------|------------------|------------------------------------------------------------------------------------------------------------|-------| +| DISPLAY |:heavy_check_mark:| [espressif/esp_lcd_gc9a01](https://components.espressif.com/components/espressif/esp_lcd_gc9a01) | ^1 | +| 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_ft5x06](https://components.espressif.com/components/espressif/esp_lcd_touch_ft5x06)| ^1 | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | +| KNOB |:heavy_check_mark:| [espressif/knob](https://components.espressif.com/components/espressif/knob) | ^0.1.3| +| AUDIO | :x: | | | +|AUDIO_SPEAKER| :x: | | | +| AUDIO_MIC | :x: | | | +| SDCARD | :x: | | | +| IMU | :x: | | | diff --git a/bsp/m5dial/idf_component.yml b/bsp/m5dial/idf_component.yml index 81e01b493..8136f1e9b 100644 --- a/bsp/m5dial/idf_component.yml +++ b/bsp/m5dial/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.0" +version: "2.0.0" description: Board Support Package (BSP) for M5Dial url: https://github.com/espressif/esp-bsp/tree/master/bsp/m5dial @@ -20,7 +20,7 @@ dependencies: button: public: true - version: ">=2,<4.0" + version: "^4" knob: version: "^0.1.3" diff --git a/bsp/m5dial/m5dial.c b/bsp/m5dial/m5dial.c index fe4820ff5..4c878d17e 100644 --- a/bsp/m5dial/m5dial.c +++ b/bsp/m5dial/m5dial.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,6 +21,7 @@ #include "bsp/display.h" #include "bsp/touch.h" #include "iot_knob.h" +#include "button_gpio.h" #include "esp_lcd_gc9a01.h" #include "esp_lcd_touch_ft5x06.h" #include "esp_lvgl_port.h" @@ -37,10 +38,9 @@ static esp_lcd_touch_handle_t tp; // LCD touch handle static bool i2c_initialized = false; static bool spi_initialized = false; -static const button_config_t bsp_encoder_btn_config = { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = false, - .gpio_button_config.gpio_num = BSP_BTN_PRESS, +static const button_gpio_config_t bsp_encoder_btn_config = { + .gpio_num = BSP_BTN_PRESS, + .active_level = 0, }; 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) static lv_indev_t *bsp_display_indev_encoder_init(lv_display_t *disp) { + + const button_config_t btn_cfg = {0}; + button_handle_t encoder_btn = NULL; + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_encoder_btn_config, &encoder_btn)); + const lvgl_port_encoder_cfg_t encoder = { .disp = disp, .encoder_a_b = &bsp_encoder_a_b_config, - .encoder_enter = &bsp_encoder_btn_config + .encoder_enter = encoder_btn }; return lvgl_port_add_encoder(&encoder); diff --git a/bsp/m5stack_core/README.md b/bsp/m5stack_core/README.md index 7383ae40e..d456e67ed 100644 --- a/bsp/m5stack_core/README.md +++ b/bsp/m5stack_core/README.md @@ -35,7 +35,7 @@ M5Stack Core is a development board based on ESP32 microcontroller. It features: | 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) | ^2 | | TOUCH | :x: | | | -| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^2.4 | +| BUTTONS |:heavy_check_mark:| [espressif/button](https://components.espressif.com/components/espressif/button) | ^4 | | AUDIO | :x: | | | |AUDIO_SPEAKER|:heavy_check_mark:| | | | AUDIO_MIC | :x: | | | diff --git a/bsp/m5stack_core/idf_component.yml b/bsp/m5stack_core/idf_component.yml index d76f68411..b54102444 100644 --- a/bsp/m5stack_core/idf_component.yml +++ b/bsp/m5stack_core/idf_component.yml @@ -13,9 +13,10 @@ dependencies: esp_lcd_ili9341: "^1" button: - version: "^2.4" + version: "^4" public: true - + espressif/esp_lvgl_port: version: "^2" public: true + override_path: "../../components/esp_lvgl_port" diff --git a/bsp/m5stack_core/m5stack_core.c b/bsp/m5stack_core/m5stack_core.c index 3811e8f1a..d96d8db35 100644 --- a/bsp/m5stack_core/m5stack_core.c +++ b/bsp/m5stack_core/m5stack_core.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -25,6 +25,7 @@ #include "bsp/display.h" #include "esp_lcd_ili9341.h" #include "bsp_err_check.h" +#include "button_gpio.h" static const char *TAG = "M5Stack"; @@ -363,31 +364,36 @@ static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg) return lvgl_port_add_disp(&disp_cfg); } -static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = { +static const button_gpio_config_t bsp_button_config[BSP_BUTTON_NUM] = { { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = false, - .gpio_button_config.gpio_num = BSP_BUTTON_LEFT, + .gpio_num = BSP_BUTTON_LEFT, + .active_level = 0, }, { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = false, - .gpio_button_config.gpio_num = BSP_BUTTON_MIDDLE, + .gpio_num = BSP_BUTTON_MIDDLE, + .active_level = 0, }, { - .type = BUTTON_TYPE_GPIO, - .gpio_button_config.active_level = false, - .gpio_button_config.gpio_num = BSP_BUTTON_RIGHT, + .gpio_num = BSP_BUTTON_RIGHT, + .active_level = 0, }, }; static lv_indev_t *bsp_display_indev_init(lv_display_t *disp) { + const button_config_t btn_cfg = {0}; + button_handle_t prev_btn = NULL; + button_handle_t next_btn = NULL; + button_handle_t enter_btn = NULL; + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_PREV], &prev_btn)); + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_NEXT], &next_btn)); + BSP_ERROR_CHECK_RETURN_NULL(iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[BSP_BUTTON_ENTER], &enter_btn)); + const lvgl_port_nav_btns_cfg_t btns = { .disp = disp, - .button_prev = &bsp_button_config[BSP_BUTTON_PREV], - .button_next = &bsp_button_config[BSP_BUTTON_NEXT], - .button_enter = &bsp_button_config[BSP_BUTTON_ENTER] + .button_prev = prev_btn, + .button_next = next_btn, + .button_enter = enter_btn }; 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 if (btn_cnt) { *btn_cnt = 0; } + const button_config_t btn_cfg = {0}; for (int i = 0; i < BSP_BUTTON_NUM; i++) { - btn_array[i] = iot_button_create(&bsp_button_config[i]); + ret |= iot_button_new_gpio_device(&btn_cfg, &bsp_button_config[i], &btn_array[i]); if (btn_array[i] == NULL) { ret = ESP_FAIL; break; diff --git a/examples/audio/main/bsp_audio_example.c b/examples/audio/main/bsp_audio_example.c index f3b63f5e7..29bfaf8b0 100644 --- a/examples/audio/main/bsp_audio_example.c +++ b/examples/audio/main/bsp_audio_example.c @@ -201,6 +201,10 @@ void app_main(void) button_handle_t btns[BSP_BUTTON_NUM]; ESP_ERROR_CHECK(bsp_iot_button_create(btns, NULL, BSP_BUTTON_NUM)); for (int i = 0; i < BSP_BUTTON_NUM; i++) { +#if BUTTON_VER_MAJOR >= 4 + ESP_ERROR_CHECK(iot_button_register_cb(btns[i], BUTTON_PRESS_DOWN, NULL, btn_handler, (void *) i)); +#else ESP_ERROR_CHECK(iot_button_register_cb(btns[i], BUTTON_PRESS_DOWN, btn_handler, (void *) i)); +#endif } } diff --git a/examples/display_rotation/sdkconfig.bsp.m5stack_core b/examples/display_rotation/sdkconfig.bsp.m5stack_core new file mode 100644 index 000000000..636599d69 --- /dev/null +++ b/examples/display_rotation/sdkconfig.bsp.m5stack_core @@ -0,0 +1,25 @@ +# This file was generated using idf.py save-defconfig. It can be edited manually. +# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration +# +CONFIG_IDF_TARGET="esp32" +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESP_DEFAULT_CPU_FREQ_240=y + +## LVGL8 ## +CONFIG_LV_USE_PERF_MONITOR=y +CONFIG_LV_COLOR_16_SWAP=y +CONFIG_LV_MEM_CUSTOM=y +CONFIG_LV_MEMCPY_MEMSET_STD=y + +## LVGL9 ## +CONFIG_LV_CONF_SKIP=y + +#CLIB default +CONFIG_LV_USE_CLIB_MALLOC=y +CONFIG_LV_USE_CLIB_SPRINTF=y +CONFIG_LV_USE_CLIB_STRING=y + +# Performance monitor +CONFIG_LV_USE_OBSERVER=y +CONFIG_LV_USE_SYSMON=y +CONFIG_LV_USE_PERF_MONITOR=y diff --git a/examples/display_sensors/main/sensors_example.c b/examples/display_sensors/main/sensors_example.c index ba6a8bcbe..4ee7ab180 100644 --- a/examples/display_sensors/main/sensors_example.c +++ b/examples/display_sensors/main/sensors_example.c @@ -286,6 +286,10 @@ void app_main(void) button_handle_t btns[BSP_BUTTON_NUM]; ESP_ERROR_CHECK(bsp_iot_button_create(btns, NULL, BSP_BUTTON_NUM)); for (int i = 0; i < BSP_BUTTON_NUM; i++) { +#if BUTTON_VER_MAJOR >= 4 + ESP_ERROR_CHECK(iot_button_register_cb(btns[i], BUTTON_PRESS_DOWN, NULL, btn_handler, (void *) i)); +#else ESP_ERROR_CHECK(iot_button_register_cb(btns[i], BUTTON_PRESS_DOWN, btn_handler, (void *) i)); +#endif } }