Skip to content

Commit

Permalink
Add enum for modes of locking buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ia committed Jul 24, 2024
1 parent 84e53e1 commit b17cf69
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 6 additions & 0 deletions source/Core/Inc/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions source/Core/Src/settingsGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 4 additions & 5 deletions source/Core/Threads/UI/logic/Soldering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -45,18 +45,17 @@ 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:
break;
}
return OperatingMode::Soldering;
}

OperatingMode gui_solderingMode(const ButtonState buttons, guiContext *cxt) {
/*
* * Soldering (gui_solderingMode)
Expand Down

0 comments on commit b17cf69

Please sign in to comment.