Skip to content

Commit

Permalink
refactor(core/settingsgui): code cleaning
Browse files Browse the repository at this point in the history
moving common code out of branching inside the some function.

added FIXME comment for unusable code.
  • Loading branch information
safocl committed Feb 2, 2025
1 parent 22d0676 commit 041c2d8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions source/Core/Src/settingsGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,6 @@ static void setBoostTemp(void) {
if (value >= MAX_TEMP_F) {
value = 0; // jump to off
}
setSettingValue(SettingsOptions::BoostTemp, value);
} else {
if (value == 0) {
value = MIN_BOOST_TEMP_C; // loop back at 250
Expand Down Expand Up @@ -654,14 +653,13 @@ static void setProfileTemp(const enum SettingsOptions option) {
if (temp > MAX_TEMP_F) {
temp = MIN_TEMP_F;
}
setSettingValue(option, temp);
} else {
temp += 5;
if (temp > MAX_TEMP_C) {
temp = MIN_TEMP_C;
}
setSettingValue(option, temp);
}
setSettingValue(option, temp);
}

static void setProfilePreheatTemp(void) { return setProfileTemp(SettingsOptions::ProfilePreheatTemp); }
Expand Down Expand Up @@ -712,14 +710,13 @@ static void setSleepTemp(void) {
if (temp > 580) {
temp = 60;
}
setSettingValue(SettingsOptions::SleepTemp, temp);
} else {
temp += 10;
if (temp > 300) {
temp = 10;
}
setSettingValue(SettingsOptions::SleepTemp, temp);
}
setSettingValue(SettingsOptions::SleepTemp, temp);
}

static void displaySleepTemp(void) { OLED::printNumber(getSettingValue(SettingsOptions::SleepTemp), 3, FontStyle::LARGE); }
Expand Down Expand Up @@ -759,12 +756,11 @@ static bool showHallEffect(void) { return getHallSensorFitted(); }
static void displayHallEffectSleepTime(void) {
if (getSettingValue(SettingsOptions::HallEffectSleepTime)) {
OLED::printNumber(getSettingValue(SettingsOptions::HallEffectSleepTime) * 5, 2, FontStyle::LARGE, false);
OLED::print(LargeSymbolSeconds, FontStyle::LARGE);
} else {
// When sleep time is set to zero, we sleep for 1 second anyways. This is the default.
OLED::printNumber(1, 2, FontStyle::LARGE, false);
OLED::print(LargeSymbolSeconds, FontStyle::LARGE);
}
OLED::print(LargeSymbolSeconds, FontStyle::LARGE);
}
#endif /* HALL_SENSOR */

Expand Down Expand Up @@ -1032,6 +1028,7 @@ static void displayMenu(size_t index) {
size_t currentFrame;
if (!animOpenState && (getSettingValue(SettingsOptions::AnimationSpeed) != settingOffSpeed_t::OFF)) {
if (menuCurrentIndex != index) {
// FIXME: asignment isn't affected on any outside code!!!
menuCurrentIndex = index;
menuSwitchLoopTick = xTaskGetTickCount();
}
Expand All @@ -1043,6 +1040,7 @@ static void displayMenu(size_t index) {
}
} else {
// We want the animation to restart after completing the transition.
// FIXME: asignment isn't affected on any outside code!!!
menuCurrentIndex = sizeof(rootSettingsMenu) + 1;
// Always draw the last frame if icon animation is disabled.
currentFrame = getSettingValue(SettingsOptions::AnimationSpeed) == settingOffSpeed_t::OFF ? 2 : 0;
Expand Down

0 comments on commit 041c2d8

Please sign in to comment.