Upgrade component versions

This commit is contained in:
Terrence
2025-05-07 15:09:43 +08:00
parent 7c6b9d8fa7
commit 696786ad4c
5 changed files with 25 additions and 14 deletions

View File

@@ -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) {
}

View File

@@ -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_

View File

@@ -111,10 +111,6 @@ private:
void InitializeButtons() {
/* Initialize ADC esp-box lite的前三个按钮采用是的adc按钮而非gpio */
button_config_t btn_config = {
.long_press_time = 2000,
.short_press_time = 50,
};
button_adc_config_t adc_cfg = {};
adc_cfg.adc_channel = ADC_CHANNEL_0; // ADC1 channel 0 is GPIO1
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
@@ -127,21 +123,18 @@ private:
adc_cfg.button_index = BSP_ADC_BUTTON_PREV;
adc_cfg.min = 2310; // middle is 2410mV
adc_cfg.max = 2510;
ESP_ERROR_CHECK(iot_button_new_adc_device(&btn_config, &adc_cfg, &adc_button_[0]));
adc_button_[0] = new Button(adc_button_[0]);
adc_button_[0] = new AdcButton(adc_cfg);
adc_cfg.button_index = BSP_ADC_BUTTON_ENTER;
adc_cfg.min = 1880; // middle is 1980mV
adc_cfg.max = 2080;
ESP_ERROR_CHECK(iot_button_new_adc_device(&btn_config, &adc_cfg, &adc_button_[1]));
adc_button_[1] = new Button(adc_button_[1]);
adc_button_[1] = new AdcButton(adc_cfg);
adc_cfg.button_index = BSP_ADC_BUTTON_NEXT;
adc_cfg.min = 720; // middle is 820mV
adc_cfg.max = 920;
ESP_ERROR_CHECK(iot_button_new_adc_device(&btn_config, &adc_cfg, &adc_button_[2]));
adc_button_[2] = new Button(adc_button_[2]);
adc_button_[2] = new AdcButton(adc_cfg);
auto volume_up_button = adc_button_[BSP_ADC_BUTTON_NEXT];
volume_up_button->OnClick([this]() {ChangeVol(10);});

View File

@@ -11,7 +11,7 @@ dependencies:
78/esp_lcd_nv3023: "~1.0.0"
78/esp-wifi-connect: "~2.4.2"
78/esp-opus-encoder: "~2.3.2"
78/esp-ml307: "~1.9.1"
78/esp-ml307: "~2.0.0"
78/xiaozhi-fonts: "~1.3.2"
espressif/led_strip: "^2.5.5"
espressif/esp_codec_dev: "~1.3.2"

View File

@@ -107,8 +107,6 @@ bool Ota::CheckVersion() {
return false;
}
ESP_LOGI(TAG, "OTA request success: %s", check_version_url_.c_str());
has_activation_code_ = false;
has_activation_challenge_ = false;
cJSON *activation = cJSON_GetObjectItem(root, "activation");