Refactoring: trying to find a more suitable variable name to check status if swap buttons in menu is enabled

This commit is contained in:
Ivan Zorin
2025-02-17 19:13:48 +03:00
parent 432b583d89
commit 035f3dd205
4 changed files with 26 additions and 26 deletions

View File

@@ -45,7 +45,7 @@ OperatingMode guiHandleDraw(void) {
OLED::clearScreen(); // Clear ready for render pass
bool d = getSettingValue(SettingsOptions::ReverseButtonMenu);
bool e = getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled);
#ifdef REVERSE_NAV_EVERYWHERE
#ifdef OPT_FULL_BUTTON_REVERSE
bool f = currentOperatingMode == OperatingMode::TemperatureAdjust;
// Read button state
ButtonState buttons = getButtonState((e && f) || (d && !e && !f) || (d && e && !f));
@@ -117,7 +117,7 @@ OperatingMode guiHandleDraw(void) {
newMode = gui_SolderingSleepingMode(buttons, &context);
break;
case OperatingMode::TemperatureAdjust:
#ifdef REVERSE_NAV_EVERYWHERE
#ifdef OPT_FULL_BUTTON_REVERSE
newMode = gui_solderingTempAdjust(getButtonState(), &context);
#else
newMode = gui_solderingTempAdjust(getButtonState(e), &context);
@@ -130,7 +130,7 @@ OperatingMode guiHandleDraw(void) {
newMode = performCJCC(buttons, &context);
break;
case OperatingMode::SettingsMenu:
#ifdef REVERSE_NAV_EVERYWHERE
#ifdef OPT_FULL_BUTTON_REVERSE
newMode = gui_SettingsMenu(getButtonState(), &context);
#else
newMode = gui_SettingsMenu(getButtonState(d), &context);

View File

@@ -9,14 +9,14 @@ extern uint8_t disconnectedTipF[sizeof(disconnectedTip)];
void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
bool isFlipped = OLED::getRotation();
bool tipDisconnected = isTipDisconnected();
#ifdef REVERSE_NAV_EVERYWHERE
bool isReverse = getSettingValue(SettingsOptions::ReverseButtonMenu);
#ifdef OPT_FULL_BUTTON_REVERSE
bool swapButtonMenu = getSettingValue(SettingsOptions::ReverseButtonMenu);
#endif
// Flip and switch buttons accordingly
#ifdef REVERSE_NAV_EVERYWHERE
OLED::drawArea(isFlipped ? 68 : 0, 0, 56, 32, isFlipped ? (isReverse ? buttonBF : buttonAF) : (isReverse ? buttonB : buttonA));
OLED::drawArea(isFlipped ? 12 : 58, 0, 56, 32, isFlipped ? (isReverse ? buttonAF : buttonBF) : (isReverse ? buttonA : buttonB));
#ifdef OPT_FULL_BUTTON_REVERSE
OLED::drawArea(isFlipped ? 68 : 0, 0, 56, 32, isFlipped ? (swapButtonMenu ? buttonBF : buttonAF) : (swapButtonMenu ? buttonB : buttonA));
OLED::drawArea(isFlipped ? 12 : 58, 0, 56, 32, isFlipped ? (swapButtonMenu ? buttonAF : buttonBF) : (swapButtonMenu ? buttonA : buttonB));
#else
OLED::drawArea(isFlipped ? 68 : 0, 0, 56, 32, isFlipped ? buttonAF : buttonA);
OLED::drawArea(isFlipped ? 12 : 58, 0, 56, 32, isFlipped ? buttonBF : buttonB);
@@ -26,9 +26,9 @@ void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
// draw temp over the start soldering button
// Location changes on screen rotation and due to button swapping
// in right handed mode we want to draw over the first part
#ifdef REVERSE_NAV_EVERYWHERE
OLED::fillArea(isReverse ? (isFlipped ? 26 : 58) : (isFlipped ? 68 : 0), 0, 56, 32, 0); // clear the area
OLED::setCursor(isReverse ? (isFlipped ? 27 : 59) : (isFlipped ? 56 : 0), 0);
#ifdef OPT_FULL_BUTTON_REVERSE
OLED::fillArea(swapButtonMenu ? (isFlipped ? 26 : 58) : (isFlipped ? 68 : 0), 0, 56, 32, 0); // clear the area
OLED::setCursor(swapButtonMenu ? (isFlipped ? 27 : 59) : (isFlipped ? 56 : 0), 0);
#else
OLED::fillArea(isFlipped ? 68 : 0, 0, 56, 32, 0); // clear the area
OLED::setCursor(isFlipped ? 56 : 0, 0);
@@ -36,13 +36,13 @@ void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
// If tip is disconnected draw the notification, otherwise - the temp
if (tipDisconnected) {
// Draw-in the missing tip symbol
#ifdef REVERSE_NAV_EVERYWHERE
if (isReverse) {
#ifdef OPT_FULL_BUTTON_REVERSE
if (swapButtonMenu) {
OLED::drawArea(isFlipped ? 20 : 54, 0, 56, 32, isFlipped ? disconnectedTipF : disconnectedTip);
} else {
#endif
OLED::drawArea(isFlipped ? 54 : 0, 0, 56, 32, isFlipped ? disconnectedTipF : disconnectedTip);
#ifdef REVERSE_NAV_EVERYWHERE
#ifdef OPT_FULL_BUTTON_REVERSE
}
#endif
} else if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300))) {

View File

@@ -8,14 +8,14 @@ extern uint8_t disconnectedTipF[sizeof(disconnectedTip)];
void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
bool isFlipped = OLED::getRotation();
bool tipDisconnected = isTipDisconnected();
#ifdef REVERSE_NAV_EVERYWHERE
bool isReverse = getSettingValue(SettingsOptions::ReverseButtonMenu);
#ifdef OPT_FULL_BUTTON_REVERSE
bool swapButtonMenu = getSettingValue(SettingsOptions::ReverseButtonMenu);
#endif
// Flip and switch buttons accordingly
#ifdef REVERSE_NAV_EVERYWHERE
OLED::drawArea(isFlipped ? 54 : 0, 0, 42, 16, isFlipped ? (isReverse ? buttonBF : buttonAF) : (isReverse ? buttonB : buttonA));
OLED::drawArea(isFlipped ? 12 : 42, 0, 42, 16, isFlipped ? (isReverse ? buttonAF : buttonBF) : (isReverse ? buttonA : buttonB));
#ifdef OPT_FULL_BUTTON_REVERSE
OLED::drawArea(isFlipped ? 54 : 0, 0, 42, 16, isFlipped ? (swapButtonMenu ? buttonBF : buttonAF) : (swapButtonMenu ? buttonB : buttonA));
OLED::drawArea(isFlipped ? 12 : 42, 0, 42, 16, isFlipped ? (swapButtonMenu ? buttonAF : buttonBF) : (swapButtonMenu ? buttonA : buttonB));
#else
OLED::drawArea(isFlipped ? 54 : 0, 0, 42, 16, isFlipped ? buttonAF : buttonA);
OLED::drawArea(isFlipped ? 12 : 42, 0, 42, 16, isFlipped ? buttonBF : buttonB);
@@ -25,9 +25,9 @@ void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
// draw temp over the start soldering button
// Location changes on screen rotation and due to button swapping
// in right handed mode we want to draw over the first part
#ifdef REVERSE_NAV_EVERYWHERE
OLED::fillArea(isReverse ? (isFlipped ? 14 : 42) : (isFlipped ? 55 : 0), 0, 41, 16, 0); // clear the area
OLED::setCursor(isReverse ? (isFlipped ? 15 : 43) : (isFlipped ? 56 : 0), 0);
#ifdef OPT_FULL_BUTTON_REVERSE
OLED::fillArea(swapButtonMenu ? (isFlipped ? 14 : 42) : (isFlipped ? 55 : 0), 0, 41, 16, 0); // clear the area
OLED::setCursor(swapButtonMenu ? (isFlipped ? 15 : 43) : (isFlipped ? 56 : 0), 0);
#else
OLED::fillArea(isFlipped ? 55 : 0, 0, 41, 16, 0); // clear the area
OLED::setCursor(isFlipped ? 56 : 0, 0);
@@ -35,13 +35,13 @@ void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
// If tip is disconnected draw the notification, otherwise - the temp
if (tipDisconnected) {
// Draw-in the missing tip symbol
#ifdef REVERSE_NAV_EVERYWHERE
if (isReverse) {
#ifdef OPT_FULL_BUTTON_REVERSE
if (swapButtonMenu) {
OLED::drawArea(isFlipped ? 12 : 42, 0, 42, 16, isFlipped ? disconnectedTipF : disconnectedTip);
} else {
#endif
OLED::drawArea(isFlipped ? 54 : 0, 0, 42, 16, isFlipped ? disconnectedTipF : disconnectedTip);
#ifdef REVERSE_NAV_EVERYWHERE
#ifdef OPT_FULL_BUTTON_REVERSE
}
#endif
} else if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300))) {

View File

@@ -17,7 +17,7 @@ bool shouldShutdown(void) {
}
}
}
#ifdef REVERSE_NAV_EVERYWHERE
#ifdef OPT_FULL_BUTTON_REVERSE
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