From 035f3dd20554123ca15682d946d9e8509d332d1d Mon Sep 17 00:00:00 2001 From: Ivan Zorin Date: Mon, 17 Feb 2025 19:13:48 +0300 Subject: [PATCH] Refactoring: trying to find a more suitable variable name to check status if swap buttons in menu is enabled --- source/Core/Threads/GUIThread.cpp | 6 ++--- .../draw_homescreen_simplified.cpp | 22 +++++++++---------- .../mono_96x16/draw_homescreen_simplified.cpp | 22 +++++++++---------- .../UI/logic/utils/shouldDeviceShutdown.cpp | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index 4180b5c1..a8b9b903 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -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); diff --git a/source/Core/Threads/UI/drawing/mono_128x32/draw_homescreen_simplified.cpp b/source/Core/Threads/UI/drawing/mono_128x32/draw_homescreen_simplified.cpp index 4337de9f..cf69795e 100644 --- a/source/Core/Threads/UI/drawing/mono_128x32/draw_homescreen_simplified.cpp +++ b/source/Core/Threads/UI/drawing/mono_128x32/draw_homescreen_simplified.cpp @@ -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))) { diff --git a/source/Core/Threads/UI/drawing/mono_96x16/draw_homescreen_simplified.cpp b/source/Core/Threads/UI/drawing/mono_96x16/draw_homescreen_simplified.cpp index e740dabe..870ef639 100644 --- a/source/Core/Threads/UI/drawing/mono_96x16/draw_homescreen_simplified.cpp +++ b/source/Core/Threads/UI/drawing/mono_96x16/draw_homescreen_simplified.cpp @@ -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))) { diff --git a/source/Core/Threads/UI/logic/utils/shouldDeviceShutdown.cpp b/source/Core/Threads/UI/logic/utils/shouldDeviceShutdown.cpp index bf9112d8..271285cf 100644 --- a/source/Core/Threads/UI/logic/utils/shouldDeviceShutdown.cpp +++ b/source/Core/Threads/UI/logic/utils/shouldDeviceShutdown.cpp @@ -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