From 9498cde5e5a7ec1c833c3180af731f63178780cc Mon Sep 17 00:00:00 2001 From: Phonog Date: Sun, 1 Mar 2020 09:42:59 +0000 Subject: [PATCH] Fix switchmode 6 according to issue 7778 --- .theia/launch.json | 6 ++++++ tasmota/support_switch.ino | 16 ++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 .theia/launch.json diff --git a/.theia/launch.json b/.theia/launch.json new file mode 100644 index 000000000..a2ea02c46 --- /dev/null +++ b/.theia/launch.json @@ -0,0 +1,6 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + "version": "0.2.0", + "configurations": [] +} diff --git a/tasmota/support_switch.ino b/tasmota/support_switch.ino index 24470ff93..49b9428b0 100644 --- a/tasmota/support_switch.ino +++ b/tasmota/support_switch.ino @@ -214,20 +214,20 @@ void SwitchHandler(uint8_t mode) break; case PUSHBUTTONHOLD: if ((PRESSED == button) && (NOT_PRESSED == Switch.last_state[i])) { - Switch.hold_timer[i] = loops_per_second * Settings.param[P_HOLD_TIME] / 10; + Switch.hold_timer[i] = loops_per_second * Settings.param[P_HOLD_TIME] / 10; // Start timer on button press } if ((NOT_PRESSED == button) && (PRESSED == Switch.last_state[i]) && (Switch.hold_timer[i])) { - Switch.hold_timer[i] = 0; - switchflag = POWER_TOGGLE; // Toggle with pushbutton to Gnd + Switch.hold_timer[i] = 0; // Button released and hold timer not expired : stop timer... + switchflag = POWER_TOGGLE; // ...and Toggle } break; case PUSHBUTTONHOLD_INV: - if ((NOT_PRESSED == button) && (PRESSED == Switch.last_state[i])) { - Switch.hold_timer[i] = loops_per_second * Settings.param[P_HOLD_TIME] / 10; + if ((PRESSED == button) && (NOT_PRESSED == Switch.last_state[i])) { + Switch.hold_timer[i] = loops_per_second * Settings.param[P_HOLD_TIME] / 10; // Start timer on button press... + switchflag = POWER_TOGGLE; // ...and Toggle } - if ((PRESSED == button) && (NOT_PRESSED == Switch.last_state[i]) && (Switch.hold_timer[i])) { - Switch.hold_timer[i] = 0; - switchflag = POWER_TOGGLE; // Toggle with pushbutton to Gnd + if ((NOT_PRESSED == button) && (PRESSED == Switch.last_state[i])) { + Switch.hold_timer[i] = 0; // Button released : stop timer. } break; case TOGGLEMULTI: