mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Merge pull request #1149 from Ralim/handle-menu-sizing-better
Handle menu sizing better
This commit is contained in:
@@ -16,9 +16,9 @@
|
|||||||
bool sanitiseSettings();
|
bool sanitiseSettings();
|
||||||
|
|
||||||
#ifdef POW_QC_20V
|
#ifdef POW_QC_20V
|
||||||
#define QC_VOLTAGE_MAX 222
|
#define QC_VOLTAGE_MAX 220
|
||||||
#else
|
#else
|
||||||
#define QC_VOLTAGE_MAX 142
|
#define QC_VOLTAGE_MAX 140
|
||||||
#endif
|
#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, 320}, // SolderingTemp
|
||||||
{MIN_TEMP_C, MAX_TEMP_F, 5, 150}, // SleepTemp
|
{MIN_TEMP_C, MAX_TEMP_F, 5, 150}, // SleepTemp
|
||||||
{0, 15, 1, SLEEP_TIME}, // SleepTime
|
{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
|
{24, 38, 1, RECOM_VOL_CELL}, // MinVoltageCells
|
||||||
{90, QC_VOLTAGE_MAX, 2, 90}, // QCIdealVoltage
|
{90, QC_VOLTAGE_MAX, 2, 90}, // QCIdealVoltage
|
||||||
{0, 2, 1, ORIENTATION_MODE}, // OrientationMode
|
{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}, // AccelMissingWarningCounter
|
||||||
{0, 9, 1, 0}, // PDMissingWarningCounter
|
{0, 9, 1, 0}, // PDMissingWarningCounter
|
||||||
{0, 0xFFFF, 0, 41431 /*EN*/}, // UILanguage
|
{0, 0xFFFF, 0, 41431 /*EN*/}, // UILanguage
|
||||||
{0, 50, 1, 0}, // PDNegTimeout
|
{0, 50, 1, 20}, // PDNegTimeout
|
||||||
{0, 1, 1, 0}, // OLEDInversion
|
{0, 1, 1, 0}, // OLEDInversion
|
||||||
{0, 99, 11, 33}, // OLEDBrightness
|
{0, 99, 11, 33}, // OLEDBrightness
|
||||||
|
|
||||||
|
|||||||
@@ -330,7 +330,6 @@ static void settings_displayQCInputV(void) {
|
|||||||
OLED::printNumber(voltage / 10, 2, FontStyle::LARGE);
|
OLED::printNumber(voltage / 10, 2, FontStyle::LARGE);
|
||||||
OLED::print(SymbolDot, FontStyle::LARGE);
|
OLED::print(SymbolDot, FontStyle::LARGE);
|
||||||
OLED::printNumber(voltage % 10, 1, FontStyle::LARGE);
|
OLED::printNumber(voltage % 10, 1, FontStyle::LARGE);
|
||||||
OLED::print(SymbolVolts, FontStyle::LARGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -857,6 +856,17 @@ static bool settings_enterAdvancedMenu(void) {
|
|||||||
return false;
|
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) {
|
void gui_Menu(const menuitem *menu) {
|
||||||
// Draw the settings menu and provide iteration support etc
|
// Draw the settings menu and provide iteration support etc
|
||||||
|
|
||||||
@@ -871,29 +881,24 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
Exiting,
|
Exiting,
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t currentScreen = 0;
|
uint8_t currentScreen = 0; // Current screen index in the menu struct
|
||||||
TickType_t autoRepeatTimer = 0;
|
uint8_t screensSkipped = 0; // Number of screens skipped due to being disabled
|
||||||
TickType_t autoRepeatAcceleration = 0;
|
TickType_t autoRepeatTimer = 0;
|
||||||
bool earlyExit = false;
|
TickType_t autoRepeatAcceleration = 0;
|
||||||
bool lcdRefresh = true;
|
bool earlyExit = false;
|
||||||
ButtonState lastButtonState = BUTTON_NONE;
|
bool lcdRefresh = true;
|
||||||
uint8_t scrollContentSize = 0;
|
|
||||||
bool scrollBlink = false;
|
ButtonState lastButtonState = BUTTON_NONE;
|
||||||
bool lastValue = false;
|
uint8_t scrollContentSize = gui_getMenuLength(menu);
|
||||||
NavState navState = NavState::Entering;
|
|
||||||
|
bool scrollBlink = false;
|
||||||
|
bool lastValue = false;
|
||||||
|
NavState navState = NavState::Entering;
|
||||||
|
|
||||||
ScrollMessage scrollMessage;
|
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) {
|
while ((menu[currentScreen].draw != nullptr) && earlyExit == false) {
|
||||||
|
bool valueChanged = false;
|
||||||
// Handle menu transition:
|
// Handle menu transition:
|
||||||
if (navState != NavState::Idle) {
|
if (navState != NavState::Idle) {
|
||||||
// Check if this menu item shall be skipped. If it shall be skipped,
|
// 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 != nullptr) {
|
||||||
if (!menu[currentScreen].isVisible()) {
|
if (!menu[currentScreen].isVisible()) {
|
||||||
currentScreen++;
|
currentScreen++;
|
||||||
|
screensSkipped++;
|
||||||
OLED::useSecondaryFramebuffer(false);
|
OLED::useSecondaryFramebuffer(false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -942,7 +948,7 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
OLED::clearScreen();
|
OLED::clearScreen();
|
||||||
menu[currentScreen].draw();
|
menu[currentScreen].draw();
|
||||||
uint8_t indicatorHeight = OLED_HEIGHT / scrollContentSize;
|
uint8_t indicatorHeight = OLED_HEIGHT / scrollContentSize;
|
||||||
uint8_t position = OLED_HEIGHT * currentScreen / scrollContentSize;
|
uint8_t position = OLED_HEIGHT * (currentScreen - screensSkipped) / scrollContentSize;
|
||||||
if (lastValue)
|
if (lastValue)
|
||||||
scrollBlink = !scrollBlink;
|
scrollBlink = !scrollBlink;
|
||||||
if (!lastValue || !scrollBlink)
|
if (!lastValue || !scrollBlink)
|
||||||
@@ -968,6 +974,7 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
|
|
||||||
auto callIncrementHandler = [&]() {
|
auto callIncrementHandler = [&]() {
|
||||||
wasInGuiMenu = false;
|
wasInGuiMenu = false;
|
||||||
|
valueChanged = true;
|
||||||
bool res = false;
|
bool res = false;
|
||||||
if ((int)menu[currentScreen].autoSettingOption < (int)SettingsOptions::SettingsOptionsLength) {
|
if ((int)menu[currentScreen].autoSettingOption < (int)SettingsOptions::SettingsOptionsLength) {
|
||||||
res = nextSettingValue(menu[currentScreen].autoSettingOption);
|
res = nextSettingValue(menu[currentScreen].autoSettingOption);
|
||||||
@@ -1043,6 +1050,10 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
earlyExit = true;
|
earlyExit = true;
|
||||||
scrollMessage.reset();
|
scrollMessage.reset();
|
||||||
}
|
}
|
||||||
|
if (valueChanged) {
|
||||||
|
// If user changed value, update the scroll content size
|
||||||
|
scrollContentSize = gui_getMenuLength(menu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user