forked from xiaozhi/xiaozhi-esp32
Upgrade component versions
This commit is contained in:
@@ -5,6 +5,16 @@
|
||||
|
||||
#define TAG "Button"
|
||||
|
||||
#if CONFIG_SOC_ADC_SUPPORTED
|
||||
AdcButton::AdcButton(const button_adc_config_t& adc_config) : Button(nullptr) {
|
||||
button_config_t btn_config = {
|
||||
.long_press_time = 2000,
|
||||
.short_press_time = 50,
|
||||
};
|
||||
ESP_ERROR_CHECK(iot_button_new_adc_device(&btn_config, &adc_config, &button_handle_));
|
||||
}
|
||||
#endif
|
||||
|
||||
Button::Button(button_handle_t button_handle) : button_handle_(button_handle) {
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <driver/gpio.h>
|
||||
#include <iot_button.h>
|
||||
#include <button_types.h>
|
||||
#include <button_adc.h>
|
||||
#include <button_gpio.h>
|
||||
#include <functional>
|
||||
|
||||
class Button {
|
||||
@@ -18,7 +20,8 @@ public:
|
||||
void OnClick(std::function<void()> callback);
|
||||
void OnDoubleClick(std::function<void()> callback);
|
||||
void OnMultipleClick(std::function<void()> callback, uint8_t click_count = 3);
|
||||
private:
|
||||
|
||||
protected:
|
||||
gpio_num_t gpio_num_;
|
||||
button_handle_t button_handle_ = nullptr;
|
||||
|
||||
@@ -30,4 +33,11 @@ private:
|
||||
std::function<void()> on_multiple_click_;
|
||||
};
|
||||
|
||||
#if CONFIG_SOC_ADC_SUPPORTED
|
||||
class AdcButton : public Button {
|
||||
public:
|
||||
AdcButton(const button_adc_config_t& adc_config);
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // BUTTON_H_
|
||||
|
||||
Reference in New Issue
Block a user