From b17cf69273760fb1b877fef542933c527c5e05b2 Mon Sep 17 00:00:00 2001 From: Ivan Zorin Date: Wed, 24 Jul 2024 10:30:40 +0300 Subject: [PATCH] Add enum for modes of locking buttons --- source/Core/Inc/Settings.h | 6 ++++++ source/Core/Src/settingsGUI.cpp | 6 +++--- source/Core/Threads/UI/logic/Soldering.cpp | 9 ++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/source/Core/Inc/Settings.h b/source/Core/Inc/Settings.h index e84fbd872c..5e82f1e234 100644 --- a/source/Core/Inc/Settings.h +++ b/source/Core/Inc/Settings.h @@ -110,6 +110,12 @@ typedef enum { NO_DYNAMIC = 0, // PPS + EPR disabled, fixed PDO only } usbpdMode_t; +typedef enum { + DISABLED = 0, // Locking buttons is disabled + BOOST = 1, // Locking buttons for Boost mode only + FULL = 2, // Locking buttons fully +} lockingMode_t; + // Settings wide operations void saveSettings(); bool loadSettings(); diff --git a/source/Core/Src/settingsGUI.cpp b/source/Core/Src/settingsGUI.cpp index 7265e2ba2f..1a9d4373e1 100644 --- a/source/Core/Src/settingsGUI.cpp +++ b/source/Core/Src/settingsGUI.cpp @@ -611,13 +611,13 @@ static void displayTempChangeLongStep(void) { OLED::printNumber(getSettingValue( static void displayLockingMode(void) { switch (getSettingValue(SettingsOptions::LockingMode)) { - case 0: + case lockingMode_t::DISABLED: OLED::drawUnavailableIcon(); break; - case 1: + case lockingMode_t::BOOST: OLED::print(translatedString(Tr->SettingLockBoostChar), FontStyle::LARGE); break; - case 2: + case lockingMode_t::FULL: OLED::print(translatedString(Tr->SettingLockFullChar), FontStyle::LARGE); break; default: diff --git a/source/Core/Threads/UI/logic/Soldering.cpp b/source/Core/Threads/UI/logic/Soldering.cpp index 9f6368c22c..4b794943f6 100644 --- a/source/Core/Threads/UI/logic/Soldering.cpp +++ b/source/Core/Threads/UI/logic/Soldering.cpp @@ -10,7 +10,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) if (cxt->scratch_state.state1 == 1) { // Buttons are currently locked if (buttons == BUTTON_F_LONG) { - if (getSettingValue(SettingsOptions::BoostTemp) && (getSettingValue(SettingsOptions::LockingMode) == 1)) { + if (getSettingValue(SettingsOptions::BoostTemp) && (getSettingValue(SettingsOptions::LockingMode) == lockingMode_t::BOOST)) { cxt->scratch_state.state2 = 1; } } else if (buttons == BUTTON_BOTH_LONG) { @@ -45,11 +45,9 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) cxt->transitionMode = TransitionAnimation::Left; return OperatingMode::TemperatureAdjust; case BUTTON_BOTH_LONG: - if (getSettingValue(SettingsOptions::LockingMode) != 0) { + if (getSettingValue(SettingsOptions::LockingMode) && warnUser(translatedString(Tr->LockingKeysString), buttons)) { // Lock buttons - if (warnUser(translatedString(Tr->LockingKeysString), buttons)) { - cxt->scratch_state.state1 = 1; - } + cxt->scratch_state.state1 = 1; } break; default: @@ -57,6 +55,7 @@ OperatingMode handleSolderingButtons(const ButtonState buttons, guiContext *cxt) } return OperatingMode::Soldering; } + OperatingMode gui_solderingMode(const ButtonState buttons, guiContext *cxt) { /* * * Soldering (gui_solderingMode)