diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index d33881774a..c6e7ce675b 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -481,6 +481,23 @@ void OLED::printWholeScreen(const char *string) { } } +// Print *F or *C - in font style of Small, Large (by default) or Extra based on input arg +void OLED::printSymbolDeg(const FontStyle fontStyle) { + switch (fontStyle) { + case FontStyle::EXTRAS: + // Picks *F or *C in ExtraFontChars[] from Font.h + OLED::drawSymbol(getSettingValue(SettingsOptions::TemperatureInF) ? 0 : 1); + break; + case FontStyle::LARGE: + OLED::print(getSettingValue(SettingsOptions::TemperatureInF) ? LargeSymbolDegF : LargeSymbolDegC, fontStyle); + break; + case FontStyle::SMALL: + default: + OLED::print(getSettingValue(SettingsOptions::TemperatureInF) ? SmallSymbolDegF : SmallSymbolDegC, fontStyle); + break; + } +} + inline void stripLeaderZeros(char *buffer, uint8_t places) { // Removing the leading zero's by swapping them to SymbolSpace // Stop 1 short so that we dont blank entire number if its zero diff --git a/source/Core/Drivers/OLED.hpp b/source/Core/Drivers/OLED.hpp index 93e6f694dd..622ef90892 100644 --- a/source/Core/Drivers/OLED.hpp +++ b/source/Core/Drivers/OLED.hpp @@ -103,7 +103,8 @@ class OLED { } } - static void setRotation(bool leftHanded); // Set the rotation for the screen + // Set the rotation for the screen + static void setRotation(bool leftHanded); // Get the current rotation of the LCD static bool getRotation() { #ifdef OLED_FLIP @@ -115,8 +116,11 @@ class OLED { static void setBrightness(uint8_t contrast); static void setInverseDisplay(bool inverted); static int16_t getCursorX() { return cursor_x; } - static void print(const char *string, FontStyle fontStyle, uint8_t length = 255); // Draw a string to the current location, with selected font; optionally - with MAX length only + // Draw a string to the current location, with selected font; optionally - with MAX length only + static void print(const char *string, FontStyle fontStyle, uint8_t length = 255); static void printWholeScreen(const char *string); + // Print *F or *C - in font style of Small, Large (by default) or Extra based on input arg + static void printSymbolDeg(FontStyle fontStyle = FontStyle::LARGE); // Set the cursor location by pixels static void setCursor(int16_t x, int16_t y) { cursor_x = x; diff --git a/source/Core/Src/settingsGUI.cpp b/source/Core/Src/settingsGUI.cpp index 7dbfafb31a..4cd4e69929 100644 --- a/source/Core/Src/settingsGUI.cpp +++ b/source/Core/Src/settingsGUI.cpp @@ -757,7 +757,7 @@ static bool setTempF(void) { return res; } -static void displayTempF(void) { OLED::print((getSettingValue(SettingsOptions::TemperatureInF)) ? LargeSymbolDegF : LargeSymbolDegC, FontStyle::LARGE); } +static void displayTempF(void) { OLED::printSymbolDeg(FontStyle::LARGE); } #ifndef NO_DISPLAY_ROTATE diff --git a/source/Core/Threads/OperatingModes/HomeScreen.cpp b/source/Core/Threads/OperatingModes/HomeScreen.cpp index fd92539c25..7ac03e9eba 100644 --- a/source/Core/Threads/OperatingModes/HomeScreen.cpp +++ b/source/Core/Threads/OperatingModes/HomeScreen.cpp @@ -116,11 +116,9 @@ void drawDetailedHomeScreen(uint32_t tipTemp) { } // draw set temp OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::SMALL); - if (getSettingValue(SettingsOptions::TemperatureInF)) { - OLED::print(SmallSymbolDegF, FontStyle::SMALL); - } else { - OLED::print(SmallSymbolDegC, FontStyle::SMALL); - } + + OLED::printSymbolDeg(FontStyle::SMALL); + if (OLED::getRotation()) { OLED::setCursor(0, 8); } else { diff --git a/source/Core/Threads/OperatingModes/OperatingModes.h b/source/Core/Threads/OperatingModes/OperatingModes.h index 853e3c0ea6..8ab84391f9 100644 --- a/source/Core/Threads/OperatingModes/OperatingModes.h +++ b/source/Core/Threads/OperatingModes/OperatingModes.h @@ -46,5 +46,6 @@ void drawHomeScreen(bool buttonLockout) __attribute__((noreturn)); // IDLE / Hom void renderHomeScreenAssets(void); // Called to act as start delay and used to render out flipped images for home screen graphics // Common helpers -int8_t getPowerSourceNumber(void); // Returns number ID of power source +int8_t getPowerSourceNumber(void); // Returns number ID of power source +uint16_t getTipTemp(void); // Returns temperature of the tip in *C/*F (based on user settings) #endif diff --git a/source/Core/Threads/OperatingModes/Sleep.cpp b/source/Core/Threads/OperatingModes/Sleep.cpp index ed5fd335af..9839a25d05 100644 --- a/source/Core/Threads/OperatingModes/Sleep.cpp +++ b/source/Core/Threads/OperatingModes/Sleep.cpp @@ -25,7 +25,7 @@ int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) { } // draw the lcd - uint16_t tipTemp = getSettingValue(SettingsOptions::TemperatureInF) ? TipThermoModel::getTipInF() : TipThermoModel::getTipInC(); + uint16_t tipTemp = getTipTemp(); OLED::clearScreen(); OLED::setCursor(0, 0); @@ -34,25 +34,14 @@ int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) { OLED::setCursor(0, 8); OLED::print(translatedString(Tr->SleepingTipAdvancedString), FontStyle::SMALL); OLED::printNumber(tipTemp, 3, FontStyle::SMALL); - - if (getSettingValue(SettingsOptions::TemperatureInF)) { - OLED::print(SmallSymbolDegF, FontStyle::SMALL); - } else { - OLED::print(SmallSymbolDegC, FontStyle::SMALL); - } - + OLED::printSymbolDeg(FontStyle::SMALL); OLED::print(SmallSymbolSpace, FontStyle::SMALL); printVoltage(); OLED::print(SmallSymbolVolts, FontStyle::SMALL); } else { OLED::print(translatedString(Tr->SleepingSimpleString), FontStyle::LARGE); OLED::printNumber(tipTemp, 3, FontStyle::LARGE); - - if (getSettingValue(SettingsOptions::TemperatureInF)) { - OLED::drawSymbol(0); - } else { - OLED::drawSymbol(1); - } + OLED::printSymbolDeg(FontStyle::EXTRAS); } OLED::refresh(); diff --git a/source/Core/Threads/OperatingModes/SolderingProfile.cpp b/source/Core/Threads/OperatingModes/SolderingProfile.cpp index 84be660a49..df6b580569 100644 --- a/source/Core/Threads/OperatingModes/SolderingProfile.cpp +++ b/source/Core/Threads/OperatingModes/SolderingProfile.cpp @@ -54,11 +54,7 @@ void gui_solderingProfileMode() { break; } - if (getSettingValue(SettingsOptions::TemperatureInF)) { - tipTemp = TipThermoModel::getTipInF(); - } else { - tipTemp = TipThermoModel::getTipInC(); - } + tipTemp = getTipTemp(); // if start temp is unknown (preheat), we're setting it now if (phaseStartTemp == 0) { @@ -155,12 +151,7 @@ void gui_solderingProfileMode() { OLED::printNumber(tipTemp, 3, FontStyle::SMALL); OLED::print(SmallSymbolSlash, FontStyle::SMALL); OLED::printNumber(profileCurrentTargetTemp, 3, FontStyle::SMALL); - - if (getSettingValue(SettingsOptions::TemperatureInF)) { - OLED::print(SmallSymbolDegF, FontStyle::SMALL); - } else { - OLED::print(SmallSymbolDegC, FontStyle::SMALL); - } + OLED::printSymbolDeg(FontStyle::SMALL); // print phase if (profilePhase > 0 && profilePhase <= getSettingValue(SettingsOptions::ProfilePhases)) { diff --git a/source/Core/Threads/OperatingModes/TemperatureAdjust.cpp b/source/Core/Threads/OperatingModes/TemperatureAdjust.cpp index 06c41da515..ce06e83bad 100644 --- a/source/Core/Threads/OperatingModes/TemperatureAdjust.cpp +++ b/source/Core/Threads/OperatingModes/TemperatureAdjust.cpp @@ -107,11 +107,7 @@ void gui_solderingTempAdjust(void) { OLED::print(LargeSymbolSpace, FontStyle::LARGE); OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::LARGE); - if (getSettingValue(SettingsOptions::TemperatureInF)) { - OLED::drawSymbol(0); - } else { - OLED::drawSymbol(1); - } + OLED::printSymbolDeg(FontStyle::EXTRAS); OLED::print(LargeSymbolSpace, FontStyle::LARGE); if (OLED::getRotation()) { OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolMinus : LargeSymbolPlus, FontStyle::LARGE); diff --git a/source/Core/Threads/OperatingModes/utils/DrawTipTemperature.cpp b/source/Core/Threads/OperatingModes/utils/DrawTipTemperature.cpp index d65a71daed..b14cf64f75 100644 --- a/source/Core/Threads/OperatingModes/utils/DrawTipTemperature.cpp +++ b/source/Core/Threads/OperatingModes/utils/DrawTipTemperature.cpp @@ -1,31 +1,14 @@ #include "OperatingModeUtilities.h" +#include "OperatingModes.h" #include "TipThermoModel.h" void gui_drawTipTemp(bool symbol, const FontStyle font) { // Draw tip temp handling unit conversion & tolerance near setpoint - uint32_t Temp = 0; - if (getSettingValue(SettingsOptions::TemperatureInF)) { - Temp = TipThermoModel::getTipInF(); - } else { - Temp = TipThermoModel::getTipInC(); - } + uint16_t Temp = getTipTemp(); OLED::printNumber(Temp, 3, font); // Draw the tip temp out if (symbol) { - if (font == FontStyle::LARGE) { - // Big font, can draw nice symbols - if (getSettingValue(SettingsOptions::TemperatureInF)) { - OLED::drawSymbol(0); - } else { - OLED::drawSymbol(1); - } - } else { - // Otherwise fall back to chars - if (getSettingValue(SettingsOptions::TemperatureInF)) { - OLED::print(SmallSymbolDegF, FontStyle::SMALL); - } else { - OLED::print(SmallSymbolDegC, FontStyle::SMALL); - } - } + // For big font, can draw nice symbols, otherwise fall back to chars + OLED::printSymbolDeg(font == FontStyle::LARGE ? FontStyle::EXTRAS : font); } } diff --git a/source/Core/Threads/OperatingModes/utils/PrintVoltage.cpp b/source/Core/Threads/OperatingModes/utils/PrintVoltage.cpp index 350971dacc..ea7b8911c2 100644 --- a/source/Core/Threads/OperatingModes/utils/PrintVoltage.cpp +++ b/source/Core/Threads/OperatingModes/utils/PrintVoltage.cpp @@ -5,4 +5,4 @@ void printVoltage(void) { OLED::printNumber(volt / 10, 2, FontStyle::SMALL); OLED::print(SmallSymbolDot, FontStyle::SMALL); OLED::printNumber(volt % 10, 1, FontStyle::SMALL); -} \ No newline at end of file +} diff --git a/source/Core/Threads/OperatingModes/utils/SolderingCommon.cpp b/source/Core/Threads/OperatingModes/utils/SolderingCommon.cpp index c96fbc8dcf..3db87daca5 100644 --- a/source/Core/Threads/OperatingModes/utils/SolderingCommon.cpp +++ b/source/Core/Threads/OperatingModes/utils/SolderingCommon.cpp @@ -160,3 +160,6 @@ int8_t getPowerSourceNumber(void) { } return sourceNumber; } + +// Returns temperature of the tip in *C/*F (based on user settings) +uint16_t getTipTemp(void) { return getSettingValue(SettingsOptions::TemperatureInF) ? TipThermoModel::getTipInF() : TipThermoModel::getTipInC(); }