Updated libraries (button and audio player) (#16)

This PR updates two dependency libraries to their latest versions:

## espressif/button: v3.5.0 to v4.1.5

[Version 4](https://components.espressif.com/components/espressif/button/versions/4.1.5/changelog?language=en) changed the API.  This code makes use of the new API, with no change to the existing behavior.

## chmorgan/esp-audio-player: v1.0.7 to v1.1.0

[Version 1.1.0](https://github.com/chmorgan/esp-audio-player/releases/tag/v1.1.0) introduces the possibility of multiple simultaneous audio streams.  This feature is as yet unused by KTag.

Co-authored-by: Joe Kearney <joe@clubk.club>
Reviewed-on: #16
This commit is contained in:
Joe Kearney 2026-02-07 22:30:37 +00:00
parent d86c494d45
commit 89166c8a02
101 changed files with 5845 additions and 2391 deletions

View file

@ -1,4 +1,4 @@
/* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
/* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -6,12 +6,8 @@
#pragma once
#include "sdkconfig.h"
#if CONFIG_SOC_ADC_SUPPORTED
#include "button_adc.h"
#endif
#include "button_gpio.h"
#include "button_matrix.h"
#include "esp_err.h"
#include "button_types.h"
#ifdef __cplusplus
extern "C" {
@ -19,7 +15,6 @@ extern "C" {
typedef void (* button_cb_t)(void *button_handle, void *usr_data);
#if CONFIG_GPIO_BUTTON_SUPPORT_POWER_SAVE
typedef void (* button_power_save_cb_t)(void *usr_data);
/**
@ -27,12 +22,9 @@ typedef void (* button_power_save_cb_t)(void *usr_data);
*
*/
typedef struct {
button_power_save_cb_t enter_power_save_cb;
void *usr_data;
button_power_save_cb_t enter_power_save_cb; /**< Callback function when entering power save mode */
void *usr_data; /**< User data for the callback */
} button_power_save_config_t;
#endif
typedef void *button_handle_t;
/**
* @brief Button events
@ -55,7 +47,7 @@ typedef enum {
} button_event_t;
/**
* @brief Button events data
* @brief Button events arg
*
*/
typedef union {
@ -74,27 +66,7 @@ typedef union {
struct multiple_clicks_t {
uint16_t clicks; /**< number of clicks, to trigger the callback */
} multiple_clicks; /**< multiple clicks struct, for event BUTTON_MULTIPLE_CLICK */
} button_event_data_t;
/**
* @brief Button events configuration
*
*/
typedef struct {
button_event_t event; /**< button event type */
button_event_data_t event_data; /**< event data corresponding to the event */
} button_event_config_t;
/**
* @brief Supported button type
*
*/
typedef enum {
BUTTON_TYPE_GPIO,
BUTTON_TYPE_ADC,
BUTTON_TYPE_MATRIX,
BUTTON_TYPE_CUSTOM
} button_type_t;
} button_event_args_t;
/**
* @brief Button parameter
@ -106,45 +78,6 @@ typedef enum {
BUTTON_PARAM_MAX,
} button_param_t;
/**
* @brief custom button configuration
*
*/
typedef struct {
uint8_t active_level; /**< active level when press down */
esp_err_t (*button_custom_init)(void *param); /**< user defined button init */
uint8_t (*button_custom_get_key_value)(void *param); /**< user defined button get key value */
esp_err_t (*button_custom_deinit)(void *param); /**< user defined button deinit */
void *priv; /**< private data used for custom button, MUST be allocated dynamically and will be auto freed in iot_button_delete*/
} button_custom_config_t;
/**
* @brief Button configuration
*
*/
typedef struct {
button_type_t type; /**< button type, The corresponding button configuration must be filled */
uint16_t long_press_time; /**< Trigger time(ms) for long press, if 0 default to BUTTON_LONG_PRESS_TIME_MS */
uint16_t short_press_time; /**< Trigger time(ms) for short press, if 0 default to BUTTON_SHORT_PRESS_TIME_MS */
union {
button_gpio_config_t gpio_button_config; /**< gpio button configuration */
#if CONFIG_SOC_ADC_SUPPORTED
button_adc_config_t adc_button_config; /**< adc button configuration */
#endif
button_matrix_config_t matrix_button_config; /**< matrix key button configuration */
button_custom_config_t custom_button_config; /**< custom button configuration */
}; /**< button configuration */
} button_config_t;
/**
* @brief Create a button
*
* @param config pointer of button configuration, must corresponding the button type
*
* @return A handle to the created button, or NULL in case of error.
*/
button_handle_t iot_button_create(const button_config_t *config);
/**
* @brief Delete a button
*
@ -161,6 +94,7 @@ esp_err_t iot_button_delete(button_handle_t btn_handle);
*
* @param btn_handle A button handle to register
* @param event Button event
* @param event_args Button event arguments
* @param cb Callback function.
* @param usr_data user data
*
@ -170,51 +104,21 @@ esp_err_t iot_button_delete(button_handle_t btn_handle);
* - ESP_ERR_INVALID_STATE The Callback is already registered. No free Space for another Callback.
* - ESP_ERR_NO_MEM No more memory allocation for the event
*/
esp_err_t iot_button_register_cb(button_handle_t btn_handle, button_event_t event, button_cb_t cb, void *usr_data);
/**
* @brief Register the button event callback function.
*
* @param btn_handle A button handle to register
* @param event_cfg Button event configuration
* @param cb Callback function.
* @param usr_data user data
*
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG Arguments is invalid.
* - ESP_ERR_INVALID_STATE The Callback is already registered. No free Space for another Callback.
* - ESP_ERR_NO_MEM No more memory allocation for the event
*/
esp_err_t iot_button_register_event_cb(button_handle_t btn_handle, button_event_config_t event_cfg, button_cb_t cb, void *usr_data);
/**
* @brief Unregister the button event callback function.
* In case event_data is also passed it will unregister function for that particular event_data only.
*
* @param btn_handle A button handle to unregister
* @param event_cfg Button event
* @param cb callback to unregister
*
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG Arguments is invalid.
* - ESP_ERR_INVALID_STATE The Callback was never registered with the event
*/
esp_err_t iot_button_unregister_event(button_handle_t btn_handle, button_event_config_t event_cfg, button_cb_t cb);
esp_err_t iot_button_register_cb(button_handle_t btn_handle, button_event_t event, button_event_args_t *event_args, button_cb_t cb, void *usr_data);
/**
* @brief Unregister all the callbacks associated with the event.
*
* @param btn_handle A button handle to unregister
* @param event Button event
* @param event_args Used for unregistering a specific callback.
*
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG Arguments is invalid.
* - ESP_ERR_INVALID_STATE No callbacks registered for the event
*/
esp_err_t iot_button_unregister_cb(button_handle_t btn_handle, button_event_t event);
esp_err_t iot_button_unregister_cb(button_handle_t btn_handle, button_event_t event, button_event_args_t *event_args);
/**
* @brief counts total callbacks registered
@ -238,7 +142,7 @@ size_t iot_button_count_cb(button_handle_t btn_handle);
* - 0 if no callbacks registered, or 1 .. (BUTTON_EVENT_MAX-1) for the number of Registered Buttons.
* - ESP_ERR_INVALID_ARG if btn_handle is invalid
*/
size_t iot_button_count_event(button_handle_t btn_handle, button_event_t event);
size_t iot_button_count_event_cb(button_handle_t btn_handle, button_event_t event);
/**
* @brief Get button event
@ -286,12 +190,25 @@ esp_err_t iot_button_print_event(button_handle_t btn_handle);
uint8_t iot_button_get_repeat(button_handle_t btn_handle);
/**
* @brief Get button ticks time
* @brief Get button pressed time
*
* @param btn_handle Button handle
*
* @return Actual time from press down to up (ms).
*/
uint32_t iot_button_get_pressed_time(button_handle_t btn_handle);
/**
* @brief Get button ticks time
*
* @deprecated This function is deprecated and will be removed in a future release.
* Please use iot_button_get_pressed_time() instead.
*
* @param btn_handle Button handle
*
* @return Actual time from press down to up (ms).
*/
__attribute__((deprecated("Use iot_button_get_pressed_time() instead")))
uint32_t iot_button_get_ticks_time(button_handle_t btn_handle);
/**
@ -343,7 +260,6 @@ esp_err_t iot_button_resume(void);
*/
esp_err_t iot_button_stop(void);
#if CONFIG_GPIO_BUTTON_SUPPORT_POWER_SAVE
/**
* @brief Register a callback function for power saving.
* The config->enter_power_save_cb function will be called when all keys stop working.
@ -356,7 +272,6 @@ esp_err_t iot_button_stop(void);
* - ESP_ERR_NO_MEM Not enough memory
*/
esp_err_t iot_button_register_power_save_cb(const button_power_save_config_t *config);
#endif
#ifdef __cplusplus
}