From 4692b5656968c4c0a4387cba0d78561e4734e41e Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 24 Aug 2022 08:52:31 +0200 Subject: [PATCH] Fix button delay regression from #15867 Fix #16319 --- tasmota/tasmota_support/support_button.ino | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/tasmota/tasmota_support/support_button.ino b/tasmota/tasmota_support/support_button.ino index 0a1beafe8..783ad475d 100644 --- a/tasmota/tasmota_support/support_button.ino +++ b/tasmota/tasmota_support/support_button.ino @@ -43,9 +43,7 @@ struct BUTTON { uint16_t hold_timer[MAX_KEYS] = { 0 }; // Timer for button hold uint16_t dual_code = 0; // Sonoff dual received code - uint8_t debounce_phase = 0; // 0 = regular iteration; 1 = read data for debouncing only uint8_t last_state[MAX_KEYS]; // Last button states - uint8_t last_state_between[MAX_KEYS]; // Last button states at the half time read uint8_t window_timer[MAX_KEYS] = { 0 }; // Max time between button presses to record press count uint8_t press_counter[MAX_KEYS] = { 0 }; // Number of button presses within Button.window_timer @@ -93,7 +91,6 @@ void ButtonInit(void) { #endif // ESP8266 for (uint32_t i = 0; i < MAX_KEYS; i++) { Button.last_state[i] = NOT_PRESSED; - Button.last_state_between[i] = NOT_PRESSED; if (PinUsed(GPIO_KEY1, i)) { Button.present++; #ifdef ESP8266 @@ -207,18 +204,6 @@ void ButtonHandler(void) { button = AdcGetButton(Pin(GPIO_ADC_BUTTON_INV, button_index)); } #endif // USE_ADC - if (Button.debounce_phase == 1) { - // adjust values - Button.last_state_between[button_index] = button; - - continue; - } - - if (button != Button.last_state_between[button_index]) { - // no clean signal, just keep the previous one - button = Button.last_state[button_index]; - } - if (button_present) { XdrvMailbox.index = button_index; XdrvMailbox.payload = button; @@ -389,8 +374,6 @@ void ButtonHandler(void) { } Button.last_state[button_index] = button; } - - Button.debounce_phase = (Button.debounce_phase + 1) & 1; } /* @@ -426,7 +409,7 @@ void MqttButtonTopic(uint32_t button_id, uint32_t action, uint32_t hold) { void ButtonLoop(void) { if (Button.present) { if (TimeReached(Button.debounce)) { - SetNextTimeInterval(Button.debounce, Settings->button_debounce / 2); + SetNextTimeInterval(Button.debounce, Settings->button_debounce); // ButtonDebounce (50) ButtonHandler(); } }