Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible fix for lock/unlock toggle loop #1956

Merged
merged 6 commits into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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