Initial public release of the 2024A software.
This commit is contained in:
parent
7b9ad3edfd
commit
303e9e1dad
361 changed files with 60083 additions and 2 deletions
76
managed_components/espressif__button/include/button_adc.h
Normal file
76
managed_components/espressif__button/include/button_adc.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_idf_version.h"
|
||||
#include "driver/gpio.h"
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
#include "esp_adc/adc_oneshot.h"
|
||||
#else
|
||||
#include "driver/adc.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ADC_BUTTON_COMBINE(channel, index) ((channel)<<8 | (index))
|
||||
#define ADC_BUTTON_SPLIT_INDEX(data) ((uint32_t)(data)&0xff)
|
||||
#define ADC_BUTTON_SPLIT_CHANNEL(data) (((uint32_t)(data) >> 8) & 0xff)
|
||||
|
||||
/**
|
||||
* @brief adc button configuration
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t adc_channel; /**< Channel of ADC */
|
||||
uint8_t button_index; /**< button index on the channel */
|
||||
uint16_t min; /**< min voltage in mv corresponding to the button */
|
||||
uint16_t max; /**< max voltage in mv corresponding to the button */
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
adc_oneshot_unit_handle_t *adc_handle; /**< handle of adc unit, if NULL will create new one internal, else will use the handle */
|
||||
#endif
|
||||
} button_adc_config_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize gpio button
|
||||
*
|
||||
* @param config pointer of configuration struct
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG Arguments is NULL.
|
||||
* - ESP_ERR_NOT_SUPPORTED Arguments out of range.
|
||||
* - ESP_ERR_INVALID_STATE State is error.
|
||||
*/
|
||||
esp_err_t button_adc_init(const button_adc_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize gpio button
|
||||
*
|
||||
* @param channel ADC channel
|
||||
* @param button_index Button index on the channel
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG Arguments is invalid.
|
||||
*/
|
||||
esp_err_t button_adc_deinit(uint8_t channel, int button_index);
|
||||
|
||||
/**
|
||||
* @brief Get the adc button level
|
||||
*
|
||||
* @param button_index It is compressed by ADC channel and button index, use the macro ADC_BUTTON_COMBINE to generate. It will be treated as a uint32_t variable.
|
||||
*
|
||||
* @return
|
||||
* - 0 Not pressed
|
||||
* - 1 Pressed
|
||||
*/
|
||||
uint8_t button_adc_get_key_level(void *button_index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
92
managed_components/espressif__button/include/button_gpio.h
Normal file
92
managed_components/espressif__button/include/button_gpio.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "driver/gpio.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief gpio button configuration
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
int32_t gpio_num; /**< num of gpio */
|
||||
uint8_t active_level; /**< gpio level when press down */
|
||||
#if CONFIG_GPIO_BUTTON_SUPPORT_POWER_SAVE
|
||||
bool enable_power_save; /**< enable power save mode */
|
||||
#endif
|
||||
bool disable_pull; /**< disable internal pull or not */
|
||||
} button_gpio_config_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize gpio button
|
||||
*
|
||||
* @param config pointer of configuration struct
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG Arguments is NULL.
|
||||
*/
|
||||
esp_err_t button_gpio_init(const button_gpio_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize gpio button
|
||||
*
|
||||
* @param gpio_num gpio number of button
|
||||
*
|
||||
* @return Always return ESP_OK
|
||||
*/
|
||||
esp_err_t button_gpio_deinit(int gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Get current level on button gpio
|
||||
*
|
||||
* @param gpio_num gpio number of button, it will be treated as a uint32_t variable.
|
||||
*
|
||||
* @return Level on gpio
|
||||
*/
|
||||
uint8_t button_gpio_get_key_level(void *gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Sets up interrupt for GPIO button.
|
||||
*
|
||||
* @param gpio_num gpio number of button
|
||||
* @param intr_type The type of GPIO interrupt.
|
||||
* @param isr_handler The ISR (Interrupt Service Routine) handler function.
|
||||
* @param args Arguments to be passed to the ISR handler function.
|
||||
* @return Always return ESP_OK
|
||||
*/
|
||||
esp_err_t button_gpio_set_intr(int gpio_num, gpio_int_type_t intr_type, gpio_isr_t isr_handler, void *args);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable interrupt for GPIO button.
|
||||
*
|
||||
* @param gpio_num gpio number of button
|
||||
* @param enable enable or disable
|
||||
* @return Always return ESP_OK
|
||||
*/
|
||||
esp_err_t button_gpio_intr_control(int gpio_num, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable GPIO wakeup functionality.
|
||||
*
|
||||
* This function allows enabling or disabling GPIO wakeup feature.
|
||||
*
|
||||
* @param gpio_num GPIO number for wakeup functionality.
|
||||
* @param active_level Active level of the GPIO when triggered.
|
||||
* @param enable Enable or disable the GPIO wakeup.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if trigger was not active or in conflict.
|
||||
*/
|
||||
esp_err_t button_gpio_enable_gpio_wakeup(uint32_t gpio_num, uint8_t active_level, bool enable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
80
managed_components/espressif__button/include/button_matrix.h
Normal file
80
managed_components/espressif__button/include/button_matrix.h
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MATRIX_BUTTON_COMBINE(row_gpio, col_gpio) ((row_gpio)<<8 | (col_gpio))
|
||||
#define MATRIX_BUTTON_SPLIT_COL(data) ((uint32_t)(data)&0xff)
|
||||
#define MATRIX_BUTTON_SPLIT_ROW(data) (((uint32_t)(data) >> 8) & 0xff)
|
||||
|
||||
/**
|
||||
* @brief Button matrix key configuration.
|
||||
* Just need to configure the GPIO associated with this GPIO in the matrix keyboard.
|
||||
*
|
||||
* Matrix Keyboard Layout (3x3):
|
||||
* ----------------------------------------
|
||||
* | Button 1 | Button 2 | Button 3 |
|
||||
* | (R1-C1) | (R1-C2) | (R1-C3) |
|
||||
* |--------------------------------------|
|
||||
* | Button 4 | Button 5 | Button 6 |
|
||||
* | (R2-C1) | (R2-C2) | (R2-C3) |
|
||||
* |--------------------------------------|
|
||||
* | Button 7 | Button 8 | Button 9 |
|
||||
* | (R3-C1) | (R3-C2) | (R3-C3) |
|
||||
* ----------------------------------------
|
||||
*
|
||||
* - Button matrix key is driven using row scanning.
|
||||
* - Buttons within the same column cannot be detected simultaneously,
|
||||
* but buttons within the same row can be detected without conflicts.
|
||||
*/
|
||||
typedef struct {
|
||||
int32_t row_gpio_num; /**< GPIO number associated with the row */
|
||||
int32_t col_gpio_num; /**< GPIO number associated with the column */
|
||||
} button_matrix_config_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize a button matrix keyboard.
|
||||
*
|
||||
* @param config Pointer to the button matrix key configuration.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the argument is NULL.
|
||||
*
|
||||
* @note When initializing the button matrix keyboard, the row GPIO pins will be set as outputs,
|
||||
* and the column GPIO pins will be set as inputs, both with pull-down resistors enabled.
|
||||
*/
|
||||
esp_err_t button_matrix_init(const button_matrix_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize a button in the matrix keyboard.
|
||||
*
|
||||
* @param row_gpio_num GPIO number of the row where the button is located.
|
||||
* @param col_gpio_num GPIO number of the column where the button is located.
|
||||
* @return
|
||||
* - ESP_OK if the button is successfully deinitialized
|
||||
*
|
||||
* @note When deinitializing a button, please exercise caution and avoid deinitializing a button individually, as it may affect the proper functioning of other buttons in the same row or column.
|
||||
*/
|
||||
esp_err_t button_matrix_deinit(int row_gpio_num, int col_gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Get the key level from the button matrix hardware.
|
||||
*
|
||||
* @param hardware_data Pointer to hardware-specific data containing information about row GPIO and column GPIO.
|
||||
* @return uint8_t[out] The key level read from the hardware.
|
||||
*
|
||||
* @note This function retrieves the key level from the button matrix hardware.
|
||||
* The `hardware_data` parameter should contain information about the row and column GPIO pins,
|
||||
* and you can access this information using the `MATRIX_BUTTON_SPLIT_COL` and `MATRIX_BUTTON_SPLIT_ROW` macros.
|
||||
*/
|
||||
uint8_t button_matrix_get_key_level(void *hardware_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
363
managed_components/espressif__button/include/iot_button.h
Normal file
363
managed_components/espressif__button/include/iot_button.h
Normal file
|
@ -0,0 +1,363 @@
|
|||
/* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#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"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief Structs to store power save callback info
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
button_power_save_cb_t enter_power_save_cb;
|
||||
void *usr_data;
|
||||
} button_power_save_config_t;
|
||||
#endif
|
||||
|
||||
typedef void *button_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Button events
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
BUTTON_PRESS_DOWN = 0,
|
||||
BUTTON_PRESS_UP,
|
||||
BUTTON_PRESS_REPEAT,
|
||||
BUTTON_PRESS_REPEAT_DONE,
|
||||
BUTTON_SINGLE_CLICK,
|
||||
BUTTON_DOUBLE_CLICK,
|
||||
BUTTON_MULTIPLE_CLICK,
|
||||
BUTTON_LONG_PRESS_START,
|
||||
BUTTON_LONG_PRESS_HOLD,
|
||||
BUTTON_LONG_PRESS_UP,
|
||||
BUTTON_PRESS_END,
|
||||
BUTTON_EVENT_MAX,
|
||||
BUTTON_NONE_PRESS,
|
||||
} button_event_t;
|
||||
|
||||
/**
|
||||
* @brief Button events data
|
||||
*
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* @brief Long press time event data
|
||||
*
|
||||
*/
|
||||
struct long_press_t {
|
||||
uint16_t press_time; /**< press time(ms) for the corresponding callback to trigger */
|
||||
} long_press; /**< long press struct, for event BUTTON_LONG_PRESS_START and BUTTON_LONG_PRESS_UP */
|
||||
|
||||
/**
|
||||
* @brief Multiple clicks event data
|
||||
*
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* @brief Button parameter
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
BUTTON_LONG_PRESS_TIME_MS = 0,
|
||||
BUTTON_SHORT_PRESS_TIME_MS,
|
||||
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
|
||||
*
|
||||
* @param btn_handle A button handle to delete
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Failure
|
||||
*/
|
||||
esp_err_t iot_button_delete(button_handle_t btn_handle);
|
||||
|
||||
/**
|
||||
* @brief Register the button event callback function.
|
||||
*
|
||||
* @param btn_handle A button handle to register
|
||||
* @param event Button event
|
||||
* @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_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);
|
||||
|
||||
/**
|
||||
* @brief Unregister all the callbacks associated with the event.
|
||||
*
|
||||
* @param btn_handle A button handle to unregister
|
||||
* @param event Button event
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief counts total callbacks registered
|
||||
*
|
||||
* @param btn_handle A button handle to the button
|
||||
*
|
||||
* @return
|
||||
* - 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_cb(button_handle_t btn_handle);
|
||||
|
||||
/**
|
||||
* @brief how many callbacks are registered for the event
|
||||
*
|
||||
* @param btn_handle A button handle to the button
|
||||
*
|
||||
* @param event Button event
|
||||
*
|
||||
* @return
|
||||
* - 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);
|
||||
|
||||
/**
|
||||
* @brief Get button event
|
||||
*
|
||||
* @param btn_handle Button handle
|
||||
*
|
||||
* @return Current button event. See button_event_t
|
||||
*/
|
||||
button_event_t iot_button_get_event(button_handle_t btn_handle);
|
||||
|
||||
/**
|
||||
* @brief Get the string representation of a button event.
|
||||
*
|
||||
* This function returns the corresponding string for a given button event.
|
||||
* If the event value is outside the valid range, the function returns error string "event value is invalid".
|
||||
*
|
||||
* @param[in] event The button event to be converted to a string.
|
||||
*
|
||||
* @return
|
||||
* - Pointer to the event string if the event is valid.
|
||||
* - "invalid event" if the event value is invalid.
|
||||
*/
|
||||
const char *iot_button_get_event_str(button_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Log the current button event as a string.
|
||||
*
|
||||
* This function prints the string representation of the current event associated with the button.
|
||||
*
|
||||
* @param[in] btn_handle Handle to the button object.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successfully logged the event string.
|
||||
* - ESP_FAIL: Invalid button handle.
|
||||
*/
|
||||
esp_err_t iot_button_print_event(button_handle_t btn_handle);
|
||||
|
||||
/**
|
||||
* @brief Get button repeat times
|
||||
*
|
||||
* @param btn_handle Button handle
|
||||
*
|
||||
* @return button pressed times. For example, double-click return 2, triple-click return 3, etc.
|
||||
*/
|
||||
uint8_t iot_button_get_repeat(button_handle_t btn_handle);
|
||||
|
||||
/**
|
||||
* @brief Get button ticks time
|
||||
*
|
||||
* @param btn_handle Button handle
|
||||
*
|
||||
* @return Actual time from press down to up (ms).
|
||||
*/
|
||||
uint32_t iot_button_get_ticks_time(button_handle_t btn_handle);
|
||||
|
||||
/**
|
||||
* @brief Get button long press hold count
|
||||
*
|
||||
* @param btn_handle Button handle
|
||||
*
|
||||
* @return Count of trigger cb(BUTTON_LONG_PRESS_HOLD)
|
||||
*/
|
||||
uint16_t iot_button_get_long_press_hold_cnt(button_handle_t btn_handle);
|
||||
|
||||
/**
|
||||
* @brief Dynamically change the parameters of the iot button
|
||||
*
|
||||
* @param btn_handle Button handle
|
||||
* @param param Button parameter
|
||||
* @param value new value
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG Arguments is invalid.
|
||||
*/
|
||||
esp_err_t iot_button_set_param(button_handle_t btn_handle, button_param_t param, void *value);
|
||||
|
||||
/**
|
||||
* @brief Get button key level
|
||||
*
|
||||
* @param btn_handle Button handle
|
||||
* @return
|
||||
* - 1 if key is pressed
|
||||
* - 0 if key is released or invalid button handle
|
||||
*/
|
||||
uint8_t iot_button_get_key_level(button_handle_t btn_handle);
|
||||
|
||||
/**
|
||||
* @brief resume button timer, if button timer is stopped. Make sure iot_button_create() is called before calling this API.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE timer state is invalid.
|
||||
*/
|
||||
esp_err_t iot_button_resume(void);
|
||||
|
||||
/**
|
||||
* @brief stop button timer, if button timer is running. Make sure iot_button_create() is called before calling this API.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE timer state is invalid
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param config Button power save config
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE No button registered
|
||||
* - ESP_ERR_INVALID_ARG Arguments is invalid
|
||||
* - 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
|
||||
}
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue