Fix switchmode 6 according to issue 7778

This commit is contained in:
Phonog 2020-03-01 09:42:59 +00:00
parent b7c6a7bcbb
commit 9498cde5e5
2 changed files with 14 additions and 8 deletions

6
.theia/launch.json Normal file
View File

@ -0,0 +1,6 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
"version": "0.2.0",
"configurations": []
}

View File

@ -214,20 +214,20 @@ void SwitchHandler(uint8_t mode)
break; break;
case PUSHBUTTONHOLD: case PUSHBUTTONHOLD:
if ((PRESSED == button) && (NOT_PRESSED == Switch.last_state[i])) { 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])) { if ((NOT_PRESSED == button) && (PRESSED == Switch.last_state[i]) && (Switch.hold_timer[i])) {
Switch.hold_timer[i] = 0; Switch.hold_timer[i] = 0; // Button released and hold timer not expired : stop timer...
switchflag = POWER_TOGGLE; // Toggle with pushbutton to Gnd switchflag = POWER_TOGGLE; // ...and Toggle
} }
break; break;
case PUSHBUTTONHOLD_INV: case PUSHBUTTONHOLD_INV:
if ((NOT_PRESSED == button) && (PRESSED == Switch.last_state[i])) { 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...
switchflag = POWER_TOGGLE; // ...and Toggle
} }
if ((PRESSED == button) && (NOT_PRESSED == Switch.last_state[i]) && (Switch.hold_timer[i])) { if ((NOT_PRESSED == button) && (PRESSED == Switch.last_state[i])) {
Switch.hold_timer[i] = 0; Switch.hold_timer[i] = 0; // Button released : stop timer.
switchflag = POWER_TOGGLE; // Toggle with pushbutton to Gnd
} }
break; break;
case TOGGLEMULTI: case TOGGLEMULTI: