forked from xiaozhi/xiaozhi-esp32
Default press time to 0
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
AdcButton::AdcButton(const button_adc_config_t& adc_config) : Button(nullptr) {
|
AdcButton::AdcButton(const button_adc_config_t& adc_config) : Button(nullptr) {
|
||||||
button_config_t btn_config = {
|
button_config_t btn_config = {
|
||||||
.long_press_time = 2000,
|
.long_press_time = 2000,
|
||||||
.short_press_time = 50,
|
.short_press_time = 0,
|
||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(iot_button_new_adc_device(&btn_config, &adc_config, &button_handle_));
|
ESP_ERROR_CHECK(iot_button_new_adc_device(&btn_config, &adc_config, &button_handle_));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
class Button {
|
class Button {
|
||||||
public:
|
public:
|
||||||
Button(button_handle_t button_handle);
|
Button(button_handle_t button_handle);
|
||||||
Button(gpio_num_t gpio_num, bool active_high = false, uint16_t long_press_time = 1000, uint16_t short_press_time = 50);
|
Button(gpio_num_t gpio_num, bool active_high = false, uint16_t long_press_time = 0, uint16_t short_press_time = 0);
|
||||||
~Button();
|
~Button();
|
||||||
|
|
||||||
void OnPressDown(std::function<void()> callback);
|
void OnPressDown(std::function<void()> callback);
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ private:
|
|||||||
// Button A
|
// Button A
|
||||||
button_config_t btn_a_config = {
|
button_config_t btn_a_config = {
|
||||||
.long_press_time = 1000,
|
.long_press_time = 1000,
|
||||||
.short_press_time = 50
|
.short_press_time = 0
|
||||||
};
|
};
|
||||||
button_driver_t btn_a_driver = {
|
button_driver_t btn_a_driver = {
|
||||||
.enable_power_save = false,
|
.enable_power_save = false,
|
||||||
@@ -140,7 +140,7 @@ private:
|
|||||||
// Button B
|
// Button B
|
||||||
button_config_t btn_b_config = {
|
button_config_t btn_b_config = {
|
||||||
.long_press_time = 1000,
|
.long_press_time = 1000,
|
||||||
.short_press_time = 50
|
.short_press_time = 0
|
||||||
};
|
};
|
||||||
button_driver_t btn_b_driver = {
|
button_driver_t btn_b_driver = {
|
||||||
.enable_power_save = false,
|
.enable_power_save = false,
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ private:
|
|||||||
// Boot Button
|
// Boot Button
|
||||||
button_config_t boot_btn_config = {
|
button_config_t boot_btn_config = {
|
||||||
.long_press_time = 2000,
|
.long_press_time = 2000,
|
||||||
.short_press_time = 50
|
.short_press_time = 0
|
||||||
};
|
};
|
||||||
button_driver_t boot_btn_driver = {
|
button_driver_t boot_btn_driver = {
|
||||||
.enable_power_save = false,
|
.enable_power_save = false,
|
||||||
@@ -195,7 +195,7 @@ private:
|
|||||||
// Power Button
|
// Power Button
|
||||||
button_config_t pwr_btn_config = {
|
button_config_t pwr_btn_config = {
|
||||||
.long_press_time = 5000,
|
.long_press_time = 5000,
|
||||||
.short_press_time = 50
|
.short_press_time = 0
|
||||||
};
|
};
|
||||||
button_driver_t pwr_btn_driver = {
|
button_driver_t pwr_btn_driver = {
|
||||||
.enable_power_save = false,
|
.enable_power_save = false,
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ private:
|
|||||||
// Boot Button
|
// Boot Button
|
||||||
button_config_t boot_btn_config = {
|
button_config_t boot_btn_config = {
|
||||||
.long_press_time = 2000,
|
.long_press_time = 2000,
|
||||||
.short_press_time = 50
|
.short_press_time = 0
|
||||||
};
|
};
|
||||||
button_driver_t boot_btn_driver = {
|
button_driver_t boot_btn_driver = {
|
||||||
.enable_power_save = false,
|
.enable_power_save = false,
|
||||||
@@ -408,7 +408,7 @@ private:
|
|||||||
// Power Button
|
// Power Button
|
||||||
button_config_t pwr_btn_config = {
|
button_config_t pwr_btn_config = {
|
||||||
.long_press_time = 5000,
|
.long_press_time = 5000,
|
||||||
.short_press_time = 50
|
.short_press_time = 0
|
||||||
};
|
};
|
||||||
button_driver_t pwr_btn_driver = {
|
button_driver_t pwr_btn_driver = {
|
||||||
.enable_power_save = false,
|
.enable_power_save = false,
|
||||||
|
|||||||
@@ -242,12 +242,12 @@ private:
|
|||||||
// watcher 是通过长按滚轮进行开机的, 需要等待滚轮释放, 否则用户开机松手时可能会误触成单击
|
// watcher 是通过长按滚轮进行开机的, 需要等待滚轮释放, 否则用户开机松手时可能会误触成单击
|
||||||
ESP_LOGI(TAG, "waiting for knob button release");
|
ESP_LOGI(TAG, "waiting for knob button release");
|
||||||
while(IoExpanderGetLevel(BSP_KNOB_BTN) == 0) {
|
while(IoExpanderGetLevel(BSP_KNOB_BTN) == 0) {
|
||||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
vTaskDelay(pdMS_TO_TICKS(50));
|
||||||
}
|
}
|
||||||
|
|
||||||
button_config_t btn_config = {
|
button_config_t btn_config = {
|
||||||
.long_press_time = 2000,
|
.long_press_time = 2000,
|
||||||
.short_press_time = 50
|
.short_press_time = 0
|
||||||
};
|
};
|
||||||
button_driver_t btn_driver = {
|
button_driver_t btn_driver = {
|
||||||
.enable_power_save = false,
|
.enable_power_save = false,
|
||||||
|
|||||||
Reference in New Issue
Block a user