diff --git a/source/Core/Src/Settings.cpp b/source/Core/Src/Settings.cpp index d7a6e5ac..8beb8c9c 100644 --- a/source/Core/Src/Settings.cpp +++ b/source/Core/Src/Settings.cpp @@ -16,9 +16,9 @@ bool sanitiseSettings(); #ifdef POW_QC_20V -#define QC_VOLTAGE_MAX 222 +#define QC_VOLTAGE_MAX 220 #else -#define QC_VOLTAGE_MAX 142 +#define QC_VOLTAGE_MAX 140 #endif /* @@ -52,7 +52,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp {MIN_TEMP_C, MAX_TEMP_F, 5, 320}, // SolderingTemp {MIN_TEMP_C, MAX_TEMP_F, 5, 150}, // SleepTemp {0, 15, 1, SLEEP_TIME}, // SleepTime - {0, 5, 1, CUT_OUT_SETTING}, // MinDCVoltageCells + {0, 4, 1, CUT_OUT_SETTING}, // MinDCVoltageCells {24, 38, 1, RECOM_VOL_CELL}, // MinVoltageCells {90, QC_VOLTAGE_MAX, 2, 90}, // QCIdealVoltage {0, 2, 1, ORIENTATION_MODE}, // OrientationMode @@ -81,7 +81,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp {0, 9, 1, 0}, // AccelMissingWarningCounter {0, 9, 1, 0}, // PDMissingWarningCounter {0, 0xFFFF, 0, 41431 /*EN*/}, // UILanguage - {0, 50, 1, 0}, // PDNegTimeout + {0, 50, 1, 20}, // PDNegTimeout {0, 1, 1, 0}, // OLEDInversion {0, 99, 11, 33}, // OLEDBrightness diff --git a/source/Core/Src/gui.cpp b/source/Core/Src/gui.cpp index ee905c5f..b562491d 100644 --- a/source/Core/Src/gui.cpp +++ b/source/Core/Src/gui.cpp @@ -330,7 +330,6 @@ static void settings_displayQCInputV(void) { OLED::printNumber(voltage / 10, 2, FontStyle::LARGE); OLED::print(SymbolDot, FontStyle::LARGE); OLED::printNumber(voltage % 10, 1, FontStyle::LARGE); - OLED::print(SymbolVolts, FontStyle::LARGE); } #endif @@ -857,6 +856,17 @@ static bool settings_enterAdvancedMenu(void) { return false; } +uint8_t gui_getMenuLength(const menuitem *menu) { + uint8_t scrollContentSize = 0; + for (uint8_t i = 0; menu[i].draw != nullptr; i++) { + if (menu[i].isVisible == nullptr) { + scrollContentSize += 1; // Always visible + } else if (menu[i].isVisible()) { + scrollContentSize += 1; // Selectively visible and chosen to show + } + } + return scrollContentSize; +} void gui_Menu(const menuitem *menu) { // Draw the settings menu and provide iteration support etc @@ -871,29 +881,24 @@ void gui_Menu(const menuitem *menu) { Exiting, }; - uint8_t currentScreen = 0; - TickType_t autoRepeatTimer = 0; - TickType_t autoRepeatAcceleration = 0; - bool earlyExit = false; - bool lcdRefresh = true; - ButtonState lastButtonState = BUTTON_NONE; - uint8_t scrollContentSize = 0; - bool scrollBlink = false; - bool lastValue = false; - NavState navState = NavState::Entering; + uint8_t currentScreen = 0; // Current screen index in the menu struct + uint8_t screensSkipped = 0; // Number of screens skipped due to being disabled + TickType_t autoRepeatTimer = 0; + TickType_t autoRepeatAcceleration = 0; + bool earlyExit = false; + bool lcdRefresh = true; + + ButtonState lastButtonState = BUTTON_NONE; + uint8_t scrollContentSize = gui_getMenuLength(menu); + + bool scrollBlink = false; + bool lastValue = false; + NavState navState = NavState::Entering; ScrollMessage scrollMessage; - for (uint8_t i = 0; menu[i].draw != nullptr; i++) { - if (menu[i].isVisible == nullptr) { - scrollContentSize += 1; // Always visible - } else if (menu[i].isVisible()) { - scrollContentSize += 1; // Selectively visible and chosen to show - } - } - while ((menu[currentScreen].draw != nullptr) && earlyExit == false) { - + bool valueChanged = false; // Handle menu transition: if (navState != NavState::Idle) { // Check if this menu item shall be skipped. If it shall be skipped, @@ -904,6 +909,7 @@ void gui_Menu(const menuitem *menu) { if (menu[currentScreen].isVisible != nullptr) { if (!menu[currentScreen].isVisible()) { currentScreen++; + screensSkipped++; OLED::useSecondaryFramebuffer(false); continue; } @@ -942,7 +948,7 @@ void gui_Menu(const menuitem *menu) { OLED::clearScreen(); menu[currentScreen].draw(); uint8_t indicatorHeight = OLED_HEIGHT / scrollContentSize; - uint8_t position = OLED_HEIGHT * currentScreen / scrollContentSize; + uint8_t position = OLED_HEIGHT * (currentScreen - screensSkipped) / scrollContentSize; if (lastValue) scrollBlink = !scrollBlink; if (!lastValue || !scrollBlink) @@ -968,6 +974,7 @@ void gui_Menu(const menuitem *menu) { auto callIncrementHandler = [&]() { wasInGuiMenu = false; + valueChanged = true; bool res = false; if ((int)menu[currentScreen].autoSettingOption < (int)SettingsOptions::SettingsOptionsLength) { res = nextSettingValue(menu[currentScreen].autoSettingOption); @@ -1043,6 +1050,10 @@ void gui_Menu(const menuitem *menu) { earlyExit = true; scrollMessage.reset(); } + if (valueChanged) { + // If user changed value, update the scroll content size + scrollContentSize = gui_getMenuLength(menu); + } } }