Refactoring: unify the names of the variables related to ReverseButtonMenu handling and add the option to the end of the settings struct to avoid the collisions on factory resets

This commit is contained in:
Ivan Zorin
2025-02-17 18:20:55 +03:00
parent 726140d06f
commit 7e57184b65
8 changed files with 14 additions and 13 deletions

View File

@@ -76,7 +76,7 @@ enum SettingsOptions {
ProfileCooldownSpeed = 52, // Maximum allowed cooldown speed in degrees per second
HallEffectSleepTime = 53, // Seconds (/5) timeout to sleep when hall effect over threshold
SolderingTipType = 54, // Selecting the type of soldering tip fitted
ReverseButtonNavEnabled = 55, // Change the A and B button assigment in menus
ReverseButtonMenu = 55, // Change the A and B button assigment in menus
//
SettingsOptionsLength = 56, // End marker
};

View File

@@ -90,7 +90,6 @@ enum class SettingsItemIndex : uint8_t {
CooldownBlink,
ScrollingSpeed,
ReverseButtonTempChange,
ReverseButtonNav,
AnimSpeed,
AnimLoop,
Brightness,
@@ -108,6 +107,7 @@ enum class SettingsItemIndex : uint8_t {
SettingsReset,
LanguageSwitch,
SolderingTipType,
ReverseButtonMenu,
NUM_ITEMS,
};

View File

@@ -81,7 +81,6 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
{MIN_CALIBRATION_OFFSET, 2500, 1, CALIBRATION_OFFSET}, // CalibrationOffset
{ 0, MAX_POWER_LIMIT, POWER_LIMIT_STEPS, POWER_LIMIT}, // PowerLimit
{ 0, 1, 1, REVERSE_BUTTON_TEMP_CHANGE}, // ReverseButtonTempChangeEnabled
{ 0, 1, 1, REVERSE_BUTTON_NAV}, // ReverseButtonNavEnabled
{ 5, TEMP_CHANGE_LONG_STEP_MAX, 5, TEMP_CHANGE_LONG_STEP}, // TempChangeLongStep
{ 1, TEMP_CHANGE_SHORT_STEP_MAX, 1, TEMP_CHANGE_SHORT_STEP}, // TempChangeShortStep
{ 0, 9, 1, 7}, // HallEffectSensitivity
@@ -111,6 +110,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
{ 1, 10, 1, 2}, // ProfileCooldownSpeed
{ 0, 12, 1, 0}, // HallEffectSleepTime
{ 0, (tipType_t::TIP_TYPE_MAX - 1) > 0 ? (tipType_t::TIP_TYPE_MAX - 1) : 0, 1, 0}, // SolderingTipType
{ 0, 1, 1, REVERSE_BUTTON_MENU}, // ReverseButtonMenu
};
static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength));

View File

@@ -47,7 +47,7 @@ static void displayAdvancedSolderingScreens(void);
static void displayAdvancedIDLEScreens(void);
static void displayScrollSpeed(void);
static void displayReverseButtonTempChangeEnabled(void);
static void displayReverseButtonNavEnabled(void);
static void displayReverseButtonMenu(void);
static void displayPowerLimit(void);
#ifdef BLE_ENABLED
@@ -397,7 +397,7 @@ const menuitem UIMenu[] = {
/* Reverse Temp change buttons +/- */
{SETTINGS_DESC(SettingsItemIndex::ReverseButtonTempChange), nullptr, displayReverseButtonTempChangeEnabled, nullptr, SettingsOptions::ReverseButtonTempChangeEnabled, SettingsItemIndex::ReverseButtonTempChange, 7},
/* Reverse menu nav buttons A/B */
{SETTINGS_DESC(SettingsItemIndex::ReverseButtonNav), nullptr, displayReverseButtonNavEnabled, nullptr, SettingsOptions::ReverseButtonNavEnabled, SettingsItemIndex::ReverseButtonNav, 7},
{SETTINGS_DESC(SettingsItemIndex::ReverseButtonMenu), nullptr, displayReverseButtonMenu, nullptr, SettingsOptions::ReverseButtonMenu, SettingsItemIndex::ReverseButtonMenu, 7},
/* Animation Speed adjustment */
{SETTINGS_DESC(SettingsItemIndex::AnimSpeed), nullptr, displayAnimationSpeed, nullptr, SettingsOptions::AnimationSpeed, SettingsItemIndex::AnimSpeed, 7},
/* Animation Loop switch */
@@ -855,7 +855,8 @@ static void displayCoolingBlinkEnabled(void) { OLED::drawCheckbox(getSettingValu
static void displayScrollSpeed(void) { OLED::print(translatedString((getSettingValue(SettingsOptions::DescriptionScrollSpeed)) ? Tr->SettingFastChar : Tr->SettingSlowChar), FontStyle::LARGE); }
static void displayReverseButtonTempChangeEnabled(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)); }
static void displayReverseButtonNavEnabled(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::ReverseButtonNavEnabled)); }
static void displayReverseButtonMenu(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::ReverseButtonMenu)); }
static void displayAnimationSpeed(void) {
switch (getSettingValue(SettingsOptions::AnimationSpeed)) {
@@ -952,7 +953,7 @@ static void setCalibrateVIN(void) {
OLED::setCursor(0, 8);
OLED::printNumber(getSettingValue(SettingsOptions::VoltageDiv), 3, FontStyle::SMALL);
switch (getButtonState(getSettingValue(SettingsOptions::ReverseButtonNavEnabled))) {
switch (getButtonState(getSettingValue(SettingsOptions::ReverseButtonMenu))) {
case BUTTON_F_SHORT:
prevSettingValue(SettingsOptions::VoltageDiv);
break;

View File

@@ -43,7 +43,7 @@ guiContext context; // Conte
OperatingMode handle_post_init_state();
OperatingMode guiHandleDraw(void) {
OLED::clearScreen(); // Clear ready for render pass
bool d = getSettingValue(SettingsOptions::ReverseButtonNavEnabled);
bool d = getSettingValue(SettingsOptions::ReverseButtonMenu);
bool e = getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled);
#ifdef REVERSE_NAV_EVERYWHERE
bool f = currentOperatingMode == OperatingMode::TemperatureAdjust;

View File

@@ -10,7 +10,7 @@ void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
bool isFlipped = OLED::getRotation();
bool tipDisconnected = isTipDisconnected();
#ifdef REVERSE_NAV_EVERYWHERE
bool isReverse = getSettingValue(SettingsOptions::ReverseButtonNavEnabled);
bool isReverse = getSettingValue(SettingsOptions::ReverseButtonMenu);
#endif
// Flip and switch buttons accordingly
@@ -52,4 +52,4 @@ void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
OLED::setCursor(isFlipped ? 0 : 116, 0);
ui_draw_power_source_icon();
}
#endif
#endif

View File

@@ -9,7 +9,7 @@ void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
bool isFlipped = OLED::getRotation();
bool tipDisconnected = isTipDisconnected();
#ifdef REVERSE_NAV_EVERYWHERE
bool isReverse = getSettingValue(SettingsOptions::ReverseButtonNavEnabled);
bool isReverse = getSettingValue(SettingsOptions::ReverseButtonMenu);
#endif
// Flip and switch buttons accordingly
@@ -51,4 +51,4 @@ void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
OLED::setCursor(isFlipped ? 0 : 84, 0);
ui_draw_power_source_icon();
}
#endif
#endif

View File

@@ -18,7 +18,7 @@ bool shouldShutdown(void) {
}
}
#ifdef REVERSE_NAV_EVERYWHERE
if (getButtonState(getSettingValue(SettingsOptions::ReverseButtonNavEnabled) == BUTTON_B_LONG) { // allow also if back button is pressed long
if (getButtonState(getSettingValue(SettingsOptions::ReverseButtonMenu) == BUTTON_B_LONG) { // allow also if back button is pressed long
#else
if (getButtonState() == BUTTON_B_LONG) { // allow also if back button is pressed long
#endif