Skip to content

Commit

Permalink
Merge pull request #1956 from neon12345/dev
Browse files Browse the repository at this point in the history
Possible fix for lock/unlock toggle loop
  • Loading branch information
discip authored Aug 1, 2024
2 parents 56d8082 + 6a2f2dc commit 2bce5b7
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions source/Core/Threads/UI/logic/Soldering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,43 @@
#include "OperatingModes.h"
#include "SolderingCommon.h"
#include "ui_drawing.hpp"
// State 1 = button locking
// State 1 = button locking (0:unlocked+released, 1:unlocked, 2:locked, 3:locked+released)
// State 2 = boost mode
// State 3 = buzzer timer

OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) {
if (cxt->scratch_state.state1 == 1) {
if (cxt->scratch_state.state1 >= 2) {
// Buttons are currently locked
if (buttons == BUTTON_F_LONG) {
switch (buttons) {
case BUTTON_F_LONG:
if (getSettingValue(SettingsOptions::BoostTemp) && (getSettingValue(SettingsOptions::LockingMode) == lockingMode_t::BOOST)) {
cxt->scratch_state.state2 = 1;
}
} else if (buttons == BUTTON_BOTH_LONG) {
// Unlocking
if (warnUser(translatedString(Tr->UnlockingKeysString), buttons)) {
cxt->scratch_state.state1 = 0;
break;
case BUTTON_BOTH_LONG:
if (cxt->scratch_state.state1 == 3) {
// Unlocking
if (warnUser(translatedString(Tr->UnlockingKeysString), buttons)) {
cxt->scratch_state.state1 = 1;
}
} else {
warnUser(translatedString(Tr->WarningKeysLockedString), buttons);
}
} else if (buttons != BUTTON_NONE) {
// Do nothing and display a lock warning
break;
case BUTTON_NONE:
cxt->scratch_state.state1 = 3;
break;
default: // Do nothing and display a lock warning
warnUser(translatedString(Tr->WarningKeysLockedString), buttons);
break;
}
return OperatingMode::Soldering;
}
// otherwise we are unlocked
switch (buttons) {
case BUTTON_NONE:
cxt->scratch_state.state2 = 0;
cxt->scratch_state.state1 = 0;
break;
case BUTTON_BOTH:
/*Fall through*/
Expand All @@ -45,9 +56,16 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt)
cxt->transitionMode = TransitionAnimation::Left;
return OperatingMode::TemperatureAdjust;
case BUTTON_BOTH_LONG:
if (getSettingValue(SettingsOptions::LockingMode) && warnUser(translatedString(Tr->LockingKeysString), buttons)) {
if (getSettingValue(SettingsOptions::LockingMode)) {
// Lock buttons
cxt->scratch_state.state1 = 1;
if (cxt->scratch_state.state1 == 0) {
if (warnUser(translatedString(Tr->LockingKeysString), buttons)) {
cxt->scratch_state.state1 = 2;
}
} else {
// FIXME should be WarningKeysUnlockedString
warnUser(translatedString(Tr->UnlockingKeysString), buttons);
}
}
break;
default:
Expand Down

0 comments on commit 2bce5b7

Please sign in to comment.