Implement printSymbolDeg() helper function as method for OLED class (#1743)
* implement printSymbolDeg() helper function as method for OLED class * Remove extra line added by mistake * OLED::printSymbolDeg - add drawSymbol calls * OLED: make comments more clear for implemented method * OLED::printSymbolDeg(): attempt to improve read-ability replacing if/else by switch/case * OLED::printSymbolDeg() - add comment for drawSymbol to clarify its underhood * get tipTemp using ?/: instead of if/else * Implement getTipTemp() helper * Add missing header --------- Co-authored-by: Ben V. Brown <5425387+Ralim@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -103,7 +103,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ public:
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(); }
|
||||
|
||||
Reference in New Issue
Block a user