Remove obsolete switch timer re-arm code

Remove obsolete switch timer re-arm code possibly attributing to watch dog restarts (#10237)
This commit is contained in:
Theo Arends 2020-12-26 14:51:24 +01:00
parent d75beb92f3
commit 9baa1bd9f4

View File

@ -89,7 +89,6 @@ void SwitchProbe(void) {
if (TasmotaGlobal.uptime < 4) { return; } // Block GPIO for 4 seconds after poweron to workaround Wemos D1 / Obi RTS circuit if (TasmotaGlobal.uptime < 4) { return; } // Block GPIO for 4 seconds after poweron to workaround Wemos D1 / Obi RTS circuit
uint32_t state_filter; uint32_t state_filter;
uint32_t switch_probe_interval;
uint32_t first_change = Switch.first_change; uint32_t first_change = Switch.first_change;
uint32_t debounce_flags = Settings.switch_debounce % 10; uint32_t debounce_flags = Settings.switch_debounce % 10;
bool force_high = (debounce_flags &1); // 51, 101, 151 etc bool force_high = (debounce_flags &1); // 51, 101, 151 etc
@ -97,7 +96,6 @@ void SwitchProbe(void) {
bool ac_detect = (debounce_flags == 9); bool ac_detect = (debounce_flags == 9);
if (ac_detect) { if (ac_detect) {
switch_probe_interval = SWITCH_FAST_PROBE_INTERVAL;
if (Settings.switch_debounce < 2 * AC_PERIOD * SWITCH_FAST_PROBE_INTERVAL + 9) { if (Settings.switch_debounce < 2 * AC_PERIOD * SWITCH_FAST_PROBE_INTERVAL + 9) {
state_filter = 2 * AC_PERIOD; state_filter = 2 * AC_PERIOD;
} else if (Settings.switch_debounce > (0x7f - 2 * AC_PERIOD) * SWITCH_FAST_PROBE_INTERVAL) { } else if (Settings.switch_debounce > (0x7f - 2 * AC_PERIOD) * SWITCH_FAST_PROBE_INTERVAL) {
@ -106,12 +104,12 @@ void SwitchProbe(void) {
state_filter = (Settings.switch_debounce - 9) / SWITCH_FAST_PROBE_INTERVAL; state_filter = (Settings.switch_debounce - 9) / SWITCH_FAST_PROBE_INTERVAL;
} }
} else { } else {
switch_probe_interval = SWITCH_PROBE_INTERVAL;
state_filter = Settings.switch_debounce / SWITCH_PROBE_INTERVAL; // 5, 10, 15 state_filter = Settings.switch_debounce / SWITCH_PROBE_INTERVAL; // 5, 10, 15
} }
for (uint32_t i = 0; i < MAX_SWITCHES; i++) { for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
if (PinUsed(GPIO_SWT1, i)) { if (!PinUsed(GPIO_SWT1, i)) { continue; }
// Olimex user_switch2.c code to fix 50Hz induced pulses // Olimex user_switch2.c code to fix 50Hz induced pulses
if (1 == digitalRead(Pin(GPIO_SWT1, i))) { if (1 == digitalRead(Pin(GPIO_SWT1, i))) {
@ -188,8 +186,6 @@ void SwitchProbe(void) {
} }
} }
} }
TickerSwitch.attach_ms(switch_probe_interval, SwitchProbe); // Re-arm as core 2.3.0 does only support ONCE mode
}
void SwitchInit(void) { void SwitchInit(void) {
bool ac_detect = (Settings.switch_debounce % 10 == 9); bool ac_detect = (Settings.switch_debounce % 10 == 9);
@ -215,12 +211,8 @@ void SwitchInit(void) {
Switch.virtual_state[i] = Switch.last_state[i]; Switch.virtual_state[i] = Switch.last_state[i];
} }
if (Switch.present) { if (Switch.present) {
if (ac_detect) {
TickerSwitch.attach_ms(SWITCH_FAST_PROBE_INTERVAL, SwitchProbe);
Switch.first_change = true; Switch.first_change = true;
} else { TickerSwitch.attach_ms((ac_detect) ? SWITCH_FAST_PROBE_INTERVAL : SWITCH_PROBE_INTERVAL, SwitchProbe);
TickerSwitch.attach_ms(SWITCH_PROBE_INTERVAL, SwitchProbe);
}
} }
} }