1
0
forked from me/IronOS

Refactor font style to be set when printing

Removes the font setting as a global state.
This commit is contained in:
Alvin Wong
2021-03-21 21:46:12 +08:00
parent a9ddcd1d9b
commit b2f9eab7fb
5 changed files with 224 additions and 262 deletions

View File

@@ -12,7 +12,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
const uint8_t *OLED::currentFont; // Pointer to the current font used for
// rendering to the buffer // rendering to the buffer
uint8_t *OLED::firstStripPtr; // Pointers to the strips to allow for buffer uint8_t *OLED::firstStripPtr; // Pointers to the strips to allow for buffer
// having extra content // having extra content
@@ -20,7 +19,6 @@ uint8_t *OLED::secondStripPtr; // Pointers to the strips
bool OLED::inLeftHandedMode; // Whether the screen is in left or not (used for bool OLED::inLeftHandedMode; // Whether the screen is in left or not (used for
// offsets in GRAM) // offsets in GRAM)
OLED::DisplayState OLED::displayState; OLED::DisplayState OLED::displayState;
uint8_t OLED::fontWidth, OLED::fontHeight;
int16_t OLED::cursor_x, OLED::cursor_y; int16_t OLED::cursor_x, OLED::cursor_y;
bool OLED::initDone = false; bool OLED::initDone = false;
uint8_t OLED::displayOffset; uint8_t OLED::displayOffset;
@@ -81,12 +79,9 @@ static uint8_t lerp(uint8_t a, uint8_t b, uint8_t t) { return a + t * (b - a) /
void OLED::initialize() { void OLED::initialize() {
cursor_x = cursor_y = 0; cursor_x = cursor_y = 0;
currentFont = USER_FONT_12;
fontWidth = 12;
inLeftHandedMode = false; inLeftHandedMode = false;
firstStripPtr = &screenBuffer[FRAMEBUFFER_START]; firstStripPtr = &screenBuffer[FRAMEBUFFER_START];
secondStripPtr = &screenBuffer[FRAMEBUFFER_START + OLED_WIDTH]; secondStripPtr = &screenBuffer[FRAMEBUFFER_START + OLED_WIDTH];
fontHeight = 16;
displayOffset = 0; displayOffset = 0;
memcpy(&screenBuffer[0], &REFRESH_COMMANDS[0], sizeof(REFRESH_COMMANDS)); memcpy(&screenBuffer[0], &REFRESH_COMMANDS[0], sizeof(REFRESH_COMMANDS));
@@ -117,18 +112,37 @@ void OLED::setFramebuffer(uint8_t *buffer) {
* UTF font handling is done using the two input chars. * UTF font handling is done using the two input chars.
* Precursor is the command char that is used to select the table. * Precursor is the command char that is used to select the table.
*/ */
void OLED::drawChar(const uint16_t charCode) { void OLED::drawChar(const uint16_t charCode, const FontStyle fontStyle) {
const uint8_t *currentFont;
static uint8_t fontWidth, fontHeight;
switch (fontStyle) {
case FontStyle::SMALL:
currentFont = USER_FONT_6x8;
fontHeight = 8;
fontWidth = 6;
break;
case FontStyle::EXTRAS:
currentFont = ExtraFontChars;
fontHeight = 16;
fontWidth = 12;
break;
case FontStyle::LARGE:
default:
currentFont = USER_FONT_12;
fontHeight = 16;
fontWidth = 12;
break;
}
if (charCode == '\x01' && cursor_y == 0) { // 0x01 is used as new line char if (charCode == '\x01' && cursor_y == 0) { // 0x01 is used as new line char
cursor_x = 0; setCursor(0, 8);
cursor_y = 8;
return; return;
} else if (charCode <= 0x01) { } else if (charCode <= 0x01) {
return; return;
} }
// First index is \x02 // First index is \x02
uint16_t index = charCode - 2; const uint16_t index = charCode - 2;
uint8_t *charPointer; const uint8_t *charPointer = currentFont + ((fontWidth * (fontHeight / 8)) * index);
charPointer = ((uint8_t *)currentFont) + ((fontWidth * (fontHeight / 8)) * index);
drawArea(cursor_x, cursor_y, fontWidth, fontHeight, charPointer); drawArea(cursor_x, cursor_y, fontWidth, fontHeight, charPointer);
cursor_x += fontWidth; cursor_x += fontWidth;
} }
@@ -235,7 +249,7 @@ void OLED::setRotation(bool leftHanded) {
} }
// print a string to the current cursor location // print a string to the current cursor location
void OLED::print(const char *const str) { void OLED::print(const char *const str, FontStyle fontStyle) {
const uint8_t *next = reinterpret_cast<const uint8_t *>(str); const uint8_t *next = reinterpret_cast<const uint8_t *>(str);
while (next[0]) { while (next[0]) {
uint16_t index; uint16_t index;
@@ -249,34 +263,10 @@ void OLED::print(const char *const str) {
index = (next[0] - 0xF0) * 0xFF - 15 + next[1]; index = (next[0] - 0xF0) * 0xFF - 15 + next[1];
next += 2; next += 2;
} }
drawChar(index); drawChar(index, fontStyle);
} }
} }
void OLED::setFont(uint8_t fontNumber) {
if (fontNumber == 1) {
// small font
currentFont = USER_FONT_6x8;
fontHeight = 8;
fontWidth = 6;
} else if (fontNumber == 2) {
currentFont = ExtraFontChars;
fontHeight = 16;
fontWidth = 12;
} else {
currentFont = USER_FONT_12;
fontHeight = 16;
fontWidth = 12;
}
}
uint8_t OLED::getFont() {
if (currentFont == USER_FONT_6x8)
return 1;
else if (currentFont == ExtraFontChars)
return 2;
else
return 0;
}
inline void stripLeaderZeros(char *buffer, uint8_t places) { inline void stripLeaderZeros(char *buffer, uint8_t places) {
// Removing the leading zero's by swapping them to SymbolSpace // Removing the leading zero's by swapping them to SymbolSpace
// Stop 1 short so that we dont blank entire number if its zero // Stop 1 short so that we dont blank entire number if its zero
@@ -289,7 +279,7 @@ inline void stripLeaderZeros(char *buffer, uint8_t places) {
} }
} }
// maximum places is 5 // maximum places is 5
void OLED::printNumber(uint16_t number, uint8_t places, bool noLeaderZeros) { void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, bool noLeaderZeros) {
char buffer[7] = {0}; char buffer[7] = {0};
if (places >= 5) { if (places >= 5) {
@@ -319,28 +309,26 @@ void OLED::printNumber(uint16_t number, uint8_t places, bool noLeaderZeros) {
buffer[0] = 2 + number % 10; buffer[0] = 2 + number % 10;
if (noLeaderZeros) if (noLeaderZeros)
stripLeaderZeros(buffer, places); stripLeaderZeros(buffer, places);
print(buffer); print(buffer, fontStyle);
} }
void OLED::debugNumber(int32_t val) { void OLED::debugNumber(int32_t val, FontStyle fontStyle) {
if (abs(val) > 99999) { if (abs(val) > 99999) {
OLED::print(SymbolSpace); // out of bounds OLED::print(SymbolSpace, fontStyle); // out of bounds
return; return;
} }
if (val >= 0) { if (val >= 0) {
OLED::print(SymbolSpace); OLED::print(SymbolSpace, fontStyle);
OLED::printNumber(val, 5); OLED::printNumber(val, 5, fontStyle);
} else { } else {
OLED::print(SymbolMinus); OLED::print(SymbolMinus, fontStyle);
OLED::printNumber(-val, 5); OLED::printNumber(-val, 5, fontStyle);
} }
} }
void OLED::drawSymbol(uint8_t symbolID) { void OLED::drawSymbol(uint8_t symbolID) {
// draw a symbol to the current cursor location // draw a symbol to the current cursor location
setFont(2); drawChar(symbolID + 2, FontStyle::EXTRAS);
drawChar(symbolID + 2);
setFont(0);
} }
// Draw an area, but y must be aligned on 0/8 offset // Draw an area, but y must be aligned on 0/8 offset

View File

@@ -26,6 +26,12 @@ extern "C" {
#define OLED_HEIGHT 16 #define OLED_HEIGHT 16
#define FRAMEBUFFER_START 17 #define FRAMEBUFFER_START 17
enum class FontStyle {
SMALL,
LARGE,
EXTRAS,
};
class OLED { class OLED {
public: public:
enum DisplayState : bool { OFF = false, ON = true }; enum DisplayState : bool { OFF = false, ON = true };
@@ -48,30 +54,23 @@ public:
// Get the current rotation of the LCD // Get the current rotation of the LCD
static bool getRotation() { return inLeftHandedMode; } static bool getRotation() { return inLeftHandedMode; }
static int16_t getCursorX() { return cursor_x; } static int16_t getCursorX() { return cursor_x; }
static void print(const char *string); // Draw a string to the current location, with current font static void print(const char *string, FontStyle fontStyle); // Draw a string to the current location, with selected font
// Set the cursor location by pixels // Set the cursor location by pixels
static void setCursor(int16_t x, int16_t y) { static void setCursor(int16_t x, int16_t y) {
cursor_x = x; cursor_x = x;
cursor_y = y; cursor_y = y;
} }
// Set cursor location by chars in current font
static void setCharCursor(int16_t x, int16_t y) {
cursor_x = x * fontWidth;
cursor_y = y * fontHeight;
}
static void setFont(uint8_t fontNumber); // (Future) Set the font that is being used
static uint8_t getFont();
static void drawImage(const uint8_t *buffer, uint8_t x, uint8_t width) { drawArea(x, 0, width, 16, buffer); }
// Draws an image to the buffer, at x offset from top to bottom (fixed height renders) // Draws an image to the buffer, at x offset from top to bottom (fixed height renders)
static void printNumber(uint16_t number, uint8_t places, bool noLeaderZeros = true); static void drawImage(const uint8_t *buffer, uint8_t x, uint8_t width) { drawArea(x, 0, width, 16, buffer); }
// Draws a number at the current cursor location // Draws a number at the current cursor location
static void printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, bool noLeaderZeros = true);
// Clears the buffer // Clears the buffer
static void clearScreen() { memset(firstStripPtr, 0, OLED_WIDTH * 2); } static void clearScreen() { memset(firstStripPtr, 0, OLED_WIDTH * 2); }
// Draws the battery level symbol // Draws the battery level symbol
static void drawBattery(uint8_t state) { drawSymbol(3 + (state > 10 ? 10 : state)); } static void drawBattery(uint8_t state) { drawSymbol(3 + (state > 10 ? 10 : state)); }
// Draws a checkbox // Draws a checkbox
static void drawCheckbox(bool state) { drawSymbol((state) ? 16 : 17); } static void drawCheckbox(bool state) { drawSymbol((state) ? 16 : 17); }
static void debugNumber(int32_t val); static void debugNumber(int32_t val, FontStyle fontStyle);
static void drawSymbol(uint8_t symbolID); // Used for drawing symbols of a predictable width static void drawSymbol(uint8_t symbolID); // Used for drawing symbols of a predictable width
static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
@@ -83,15 +82,13 @@ public:
static void useSecondaryFramebuffer(bool useSecondary); static void useSecondaryFramebuffer(bool useSecondary);
private: private:
static void drawChar(const uint16_t charCode); // Draw a character to the current cursor location static void drawChar(uint16_t charCode, FontStyle fontStyle); // Draw a character to the current cursor location
static void setFramebuffer(uint8_t *buffer); static void setFramebuffer(uint8_t *buffer);
static const uint8_t *currentFont; // Pointer to the current font used for rendering to the buffer
static uint8_t * firstStripPtr; // Pointers to the strips to allow for buffer having extra content static uint8_t * firstStripPtr; // Pointers to the strips to allow for buffer having extra content
static uint8_t * secondStripPtr; // Pointers to the strips static uint8_t * secondStripPtr; // Pointers to the strips
static bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM) static bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
static bool initDone; static bool initDone;
static DisplayState displayState; static DisplayState displayState;
static uint8_t fontWidth, fontHeight;
static int16_t cursor_x, cursor_y; static int16_t cursor_x, cursor_y;
static uint8_t displayOffset; static uint8_t displayOffset;
static uint8_t screenBuffer[16 + (OLED_WIDTH * 2) + 10]; // The data buffer static uint8_t screenBuffer[16 + (OLED_WIDTH * 2) + 10]; // The data buffer

View File

@@ -243,15 +243,13 @@ const menuitem advancedMenu[] = {
static void printShortDescriptionDoubleLine(uint32_t shortDescIndex) { static void printShortDescriptionDoubleLine(uint32_t shortDescIndex) {
if (SettingsShortNames[shortDescIndex][0][0] == '\x00') { if (SettingsShortNames[shortDescIndex][0][0] == '\x00') {
// Empty first line means that this uses large font (for CJK). // Empty first line means that this uses large font (for CJK).
OLED::setFont(0); OLED::setCursor(0, 0);
OLED::setCharCursor(0, 0); OLED::print(SettingsShortNames[shortDescIndex][1], FontStyle::LARGE);
OLED::print(SettingsShortNames[shortDescIndex][1]);
} else { } else {
OLED::setFont(1); OLED::setCursor(0, 0);
OLED::setCharCursor(0, 0); OLED::print(SettingsShortNames[shortDescIndex][0], FontStyle::SMALL);
OLED::print(SettingsShortNames[shortDescIndex][0]); OLED::setCursor(0, 8);
OLED::setCharCursor(0, 1); OLED::print(SettingsShortNames[shortDescIndex][1], FontStyle::SMALL);
OLED::print(SettingsShortNames[shortDescIndex][1]);
} }
} }
@@ -267,10 +265,8 @@ static void printShortDescription(uint32_t shortDescIndex, uint16_t cursorCharPo
printShortDescriptionDoubleLine(shortDescIndex); printShortDescriptionDoubleLine(shortDescIndex);
// prepare cursor for value // prepare cursor for value
OLED::setFont(0);
OLED::setCharCursor(cursorCharPosition, 0);
// make room for scroll indicator // make room for scroll indicator
OLED::setCursor(OLED::getCursorX() - 2, 0); OLED::setCursor(cursorCharPosition * FONT_12_WIDTH - 2, 0);
} }
/** /**
@@ -302,7 +298,6 @@ static int userConfirmation(const char *message) {
uint16_t messageWidth = FONT_12_WIDTH * (str_display_len(message) + 7); uint16_t messageWidth = FONT_12_WIDTH * (str_display_len(message) + 7);
uint32_t messageStart = xTaskGetTickCount(); uint32_t messageStart = xTaskGetTickCount();
OLED::setFont(0);
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
int16_t lastOffset = -1; int16_t lastOffset = -1;
bool lcdRefresh = true; bool lcdRefresh = true;
@@ -316,7 +311,7 @@ static int userConfirmation(const char *message) {
//^ Rolling offset based on time //^ Rolling offset based on time
OLED::setCursor((OLED_WIDTH - messageOffset), 0); OLED::setCursor((OLED_WIDTH - messageOffset), 0);
OLED::print(message); OLED::print(message, FontStyle::LARGE);
lastOffset = messageOffset; lastOffset = messageOffset;
lcdRefresh = true; lcdRefresh = true;
} }
@@ -357,10 +352,10 @@ static bool settings_displayInputVRange(void) {
printShortDescription(0, 6); printShortDescription(0, 6);
if (systemSettings.minDCVoltageCells) { if (systemSettings.minDCVoltageCells) {
OLED::printNumber(2 + systemSettings.minDCVoltageCells, 1); OLED::printNumber(2 + systemSettings.minDCVoltageCells, 1, FontStyle::LARGE);
OLED::print(SymbolCellCount); OLED::print(SymbolCellCount, FontStyle::LARGE);
} else { } else {
OLED::print(SymbolDC); OLED::print(SymbolDC, FontStyle::LARGE);
} }
return false; return false;
} }
@@ -377,12 +372,12 @@ static bool settings_setInputMinVRange(void) {
static bool settings_displayInputMinVRange(void) { static bool settings_displayInputMinVRange(void) {
if (systemSettings.minDCVoltageCells) { if (systemSettings.minDCVoltageCells) {
printShortDescription(28, 4); printShortDescription(28, 4);
OLED::printNumber(systemSettings.minVoltageCells / 10, 2); OLED::printNumber(systemSettings.minVoltageCells / 10, 2, FontStyle::LARGE);
OLED::print(SymbolDot); OLED::print(SymbolDot, FontStyle::LARGE);
OLED::printNumber(systemSettings.minVoltageCells % 10, 1); OLED::printNumber(systemSettings.minVoltageCells % 10, 1, FontStyle::LARGE);
} else { } else {
printShortDescription(28, 5); printShortDescription(28, 5);
OLED::print(SettingNAChar); OLED::print(SettingNAChar, FontStyle::LARGE);
} }
return false; return false;
} }
@@ -404,16 +399,16 @@ static bool settings_displayQCInputV(void) {
// These are only used in QC modes // These are only used in QC modes
switch (systemSettings.QCIdealVoltage) { switch (systemSettings.QCIdealVoltage) {
case 0: case 0:
OLED::printNumber(9, 2); OLED::printNumber(9, 2, FontStyle::LARGE);
OLED::print(SymbolVolts); OLED::print(SymbolVolts, FontStyle::LARGE);
break; break;
case 1: case 1:
OLED::printNumber(12, 2); OLED::printNumber(12, 2, FontStyle::LARGE);
OLED::print(SymbolVolts); OLED::print(SymbolVolts, FontStyle::LARGE);
break; break;
case 2: case 2:
OLED::printNumber(20, 2); OLED::printNumber(20, 2, FontStyle::LARGE);
OLED::print(SymbolVolts); OLED::print(SymbolVolts, FontStyle::LARGE);
break; break;
default: default:
break; break;
@@ -439,7 +434,7 @@ static bool settings_setSleepTemp(void) {
static bool settings_displaySleepTemp(void) { static bool settings_displaySleepTemp(void) {
printShortDescription(1, 5); printShortDescription(1, 5);
OLED::printNumber(systemSettings.SleepTemp, 3); OLED::printNumber(systemSettings.SleepTemp, 3, FontStyle::LARGE);
return false; return false;
} }
@@ -457,13 +452,13 @@ static bool settings_setSleepTime(void) {
static bool settings_displaySleepTime(void) { static bool settings_displaySleepTime(void) {
printShortDescription(2, 5); printShortDescription(2, 5);
if (systemSettings.SleepTime == 0) { if (systemSettings.SleepTime == 0) {
OLED::print(OffString); OLED::print(OffString, FontStyle::LARGE);
} else if (systemSettings.SleepTime < 6) { } else if (systemSettings.SleepTime < 6) {
OLED::printNumber(systemSettings.SleepTime * 10, 2); OLED::printNumber(systemSettings.SleepTime * 10, 2, FontStyle::LARGE);
OLED::print(SymbolSeconds); OLED::print(SymbolSeconds, FontStyle::LARGE);
} else { } else {
OLED::printNumber(systemSettings.SleepTime - 5, 2); OLED::printNumber(systemSettings.SleepTime - 5, 2, FontStyle::LARGE);
OLED::print(SymbolMinutes); OLED::print(SymbolMinutes, FontStyle::LARGE);
} }
return false; return false;
} }
@@ -481,10 +476,10 @@ static bool settings_setShutdownTime(void) {
static bool settings_displayShutdownTime(void) { static bool settings_displayShutdownTime(void) {
printShortDescription(3, 5); printShortDescription(3, 5);
if (systemSettings.ShutdownTime == 0) { if (systemSettings.ShutdownTime == 0) {
OLED::print(OffString); OLED::print(OffString, FontStyle::LARGE);
} else { } else {
OLED::printNumber(systemSettings.ShutdownTime, 2); OLED::printNumber(systemSettings.ShutdownTime, 2, FontStyle::LARGE);
OLED::print(SymbolMinutes); OLED::print(SymbolMinutes, FontStyle::LARGE);
} }
return false; return false;
} }
@@ -516,7 +511,7 @@ static bool settings_setTempF(void) {
static bool settings_displayTempF(void) { static bool settings_displayTempF(void) {
printShortDescription(5, 7); printShortDescription(5, 7);
OLED::print((systemSettings.temperatureInF) ? SymbolDegF : SymbolDegC); OLED::print((systemSettings.temperatureInF) ? SymbolDegF : SymbolDegC, FontStyle::LARGE);
return false; return false;
} }
@@ -528,7 +523,7 @@ static bool settings_setSensitivity(void) {
static bool settings_displaySensitivity(void) { static bool settings_displaySensitivity(void) {
printShortDescription(4, 7); printShortDescription(4, 7);
OLED::printNumber(systemSettings.sensitivity, 1, false); OLED::printNumber(systemSettings.sensitivity, 1, FontStyle::LARGE, false);
return false; return false;
} }
@@ -566,10 +561,10 @@ static bool settings_setPowerLimit(void) {
static bool settings_displayPowerLimit(void) { static bool settings_displayPowerLimit(void) {
printShortDescription(20, 5); printShortDescription(20, 5);
if (systemSettings.powerLimit == 0) { if (systemSettings.powerLimit == 0) {
OLED::print(OffString); OLED::print(OffString, FontStyle::LARGE);
} else { } else {
OLED::printNumber(systemSettings.powerLimit, 2); OLED::printNumber(systemSettings.powerLimit, 2, FontStyle::LARGE);
OLED::print(SymbolWatts); OLED::print(SymbolWatts, FontStyle::LARGE);
} }
return false; return false;
} }
@@ -584,7 +579,7 @@ static bool settings_setScrollSpeed(void) {
static bool settings_displayScrollSpeed(void) { static bool settings_displayScrollSpeed(void) {
printShortDescription(15, 7); printShortDescription(15, 7);
OLED::print((systemSettings.descriptionScrollSpeed) ? SettingFastChar : SettingSlowChar); OLED::print((systemSettings.descriptionScrollSpeed) ? SettingFastChar : SettingSlowChar, FontStyle::LARGE);
return false; return false;
} }
@@ -612,16 +607,16 @@ static bool settings_displayDisplayRotation(void) {
switch (systemSettings.OrientationMode) { switch (systemSettings.OrientationMode) {
case 0: case 0:
OLED::print(SettingRightChar); OLED::print(SettingRightChar, FontStyle::LARGE);
break; break;
case 1: case 1:
OLED::print(SettingLeftChar); OLED::print(SettingLeftChar, FontStyle::LARGE);
break; break;
case 2: case 2:
OLED::print(SettingAutoChar); OLED::print(SettingAutoChar, FontStyle::LARGE);
break; break;
default: default:
OLED::print(SettingRightChar); OLED::print(SettingRightChar, FontStyle::LARGE);
break; break;
} }
return false; return false;
@@ -655,9 +650,9 @@ static bool settings_setBoostTemp(void) {
static bool settings_displayBoostTemp(void) { static bool settings_displayBoostTemp(void) {
printShortDescription(8, 5); printShortDescription(8, 5);
if (systemSettings.BoostTemp) { if (systemSettings.BoostTemp) {
OLED::printNumber(systemSettings.BoostTemp, 3); OLED::printNumber(systemSettings.BoostTemp, 3, FontStyle::LARGE);
} else { } else {
OLED::print(OffString); OLED::print(OffString, FontStyle::LARGE);
} }
return false; return false;
} }
@@ -673,19 +668,19 @@ static bool settings_displayAutomaticStartMode(void) {
switch (systemSettings.autoStartMode) { switch (systemSettings.autoStartMode) {
case 0: case 0:
OLED::print(SettingStartNoneChar); OLED::print(SettingStartNoneChar, FontStyle::LARGE);
break; break;
case 1: case 1:
OLED::print(SettingStartSolderingChar); OLED::print(SettingStartSolderingChar, FontStyle::LARGE);
break; break;
case 2: case 2:
OLED::print(SettingStartSleepChar); OLED::print(SettingStartSleepChar, FontStyle::LARGE);
break; break;
case 3: case 3:
OLED::print(SettingStartSleepOffChar); OLED::print(SettingStartSleepOffChar, FontStyle::LARGE);
break; break;
default: default:
OLED::print(SettingStartNoneChar); OLED::print(SettingStartNoneChar, FontStyle::LARGE);
break; break;
} }
return false; return false;
@@ -702,16 +697,16 @@ static bool settings_displayLockingMode(void) {
switch (systemSettings.lockingMode) { switch (systemSettings.lockingMode) {
case 0: case 0:
OLED::print(SettingLockDisableChar); OLED::print(SettingLockDisableChar, FontStyle::LARGE);
break; break;
case 1: case 1:
OLED::print(SettingLockBoostChar); OLED::print(SettingLockBoostChar, FontStyle::LARGE);
break; break;
case 2: case 2:
OLED::print(SettingLockFullChar); OLED::print(SettingLockFullChar, FontStyle::LARGE);
break; break;
default: default:
OLED::print(SettingLockDisableChar); OLED::print(SettingLockDisableChar, FontStyle::LARGE);
break; break;
} }
return false; return false;
@@ -732,10 +727,9 @@ static bool settings_setResetSettings(void) {
if (userConfirmation(SettingsResetWarning)) { if (userConfirmation(SettingsResetWarning)) {
resetSettings(); resetSettings();
OLED::setFont(0);
OLED::clearScreen(); OLED::clearScreen();
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::print(ResetOKMessage); OLED::print(ResetOKMessage, FontStyle::LARGE);
OLED::refresh(); OLED::refresh();
waitForButtonPressOrTimeout(2000); // 2 second timeout waitForButtonPressOrTimeout(2000); // 2 second timeout
@@ -761,9 +755,9 @@ static void setTipOffset() {
// cycle through the filter a fair bit to ensure we're stable. // cycle through the filter a fair bit to ensure we're stable.
OLED::clearScreen(); OLED::clearScreen();
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::print(SymbolDot); OLED::print(SymbolDot, FontStyle::LARGE);
for (uint8_t x = 0; x < (i / 4); x++) for (uint8_t x = 0; x < (i / 4); x++)
OLED::print(SymbolDot); OLED::print(SymbolDot, FontStyle::LARGE);
OLED::refresh(); OLED::refresh();
osDelay(100); osDelay(100);
} }
@@ -772,7 +766,7 @@ static void setTipOffset() {
OLED::clearScreen(); OLED::clearScreen();
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::drawCheckbox(true); OLED::drawCheckbox(true);
OLED::printNumber(systemSettings.CalibrationOffset, 4); OLED::printNumber(systemSettings.CalibrationOffset, 4, FontStyle::LARGE);
OLED::refresh(); OLED::refresh();
osDelay(1200); osDelay(1200);
} }
@@ -796,15 +790,14 @@ static bool settings_displayCalibrate(void) {
static bool settings_setCalibrateVIN(void) { static bool settings_setCalibrateVIN(void) {
// Jump to the voltage calibration subscreen // Jump to the voltage calibration subscreen
OLED::setFont(0);
OLED::clearScreen(); OLED::clearScreen();
for (;;) { for (;;) {
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::printNumber(getInputVoltageX10(systemSettings.voltageDiv, 0) / 10, 2); OLED::printNumber(getInputVoltageX10(systemSettings.voltageDiv, 0) / 10, 2, FontStyle::LARGE);
OLED::print(SymbolDot); OLED::print(SymbolDot, FontStyle::LARGE);
OLED::printNumber(getInputVoltageX10(systemSettings.voltageDiv, 0) % 10, 1, false); OLED::printNumber(getInputVoltageX10(systemSettings.voltageDiv, 0) % 10, 1, FontStyle::LARGE, false);
OLED::print(SymbolVolts); OLED::print(SymbolVolts, FontStyle::LARGE);
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
switch (buttons) { switch (buttons) {
@@ -821,7 +814,7 @@ static bool settings_setCalibrateVIN(void) {
case BUTTON_B_LONG: case BUTTON_B_LONG:
saveSettings(); saveSettings();
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::printNumber(systemSettings.voltageDiv, 3); OLED::printNumber(systemSettings.voltageDiv, 3, FontStyle::LARGE);
OLED::refresh(); OLED::refresh();
waitForButtonPressOrTimeout(1000); waitForButtonPressOrTimeout(1000);
return false; return false;
@@ -872,7 +865,7 @@ static bool settings_setTempChangeShortStep(void) {
static bool settings_displayTempChangeShortStep(void) { static bool settings_displayTempChangeShortStep(void) {
printShortDescription(22, 6); printShortDescription(22, 6);
OLED::printNumber(systemSettings.TempChangeShortStep, 2); OLED::printNumber(systemSettings.TempChangeShortStep, 2, FontStyle::LARGE);
return false; return false;
} }
@@ -892,7 +885,7 @@ static bool settings_setTempChangeLongStep(void) {
static bool settings_displayTempChangeLongStep(void) { static bool settings_displayTempChangeLongStep(void) {
printShortDescription(23, 6); printShortDescription(23, 6);
OLED::printNumber(systemSettings.TempChangeLongStep, 2); OLED::printNumber(systemSettings.TempChangeLongStep, 2, FontStyle::LARGE);
return false; return false;
} }
@@ -905,11 +898,11 @@ static bool settings_setPowerPulse(void) {
static bool settings_displayPowerPulse(void) { static bool settings_displayPowerPulse(void) {
printShortDescription(24, 5); printShortDescription(24, 5);
if (systemSettings.KeepAwakePulse) { if (systemSettings.KeepAwakePulse) {
OLED::printNumber(systemSettings.KeepAwakePulse / 10, 1); OLED::printNumber(systemSettings.KeepAwakePulse / 10, 1, FontStyle::LARGE);
OLED::print(SymbolDot); OLED::print(SymbolDot, FontStyle::LARGE);
OLED::printNumber(systemSettings.KeepAwakePulse % 10, 1); OLED::printNumber(systemSettings.KeepAwakePulse % 10, 1, FontStyle::LARGE);
} else { } else {
OLED::print(OffString); OLED::print(OffString, FontStyle::LARGE);
} }
return false; return false;
} }
@@ -935,16 +928,16 @@ static bool settings_displayAnimationSpeed(void) {
printShortDescription(30, 7); printShortDescription(30, 7);
switch (systemSettings.animationSpeed) { switch (systemSettings.animationSpeed) {
case settingOffSpeed_t::SLOW: case settingOffSpeed_t::SLOW:
OLED::print(SettingSlowChar); OLED::print(SettingSlowChar, FontStyle::LARGE);
break; break;
case settingOffSpeed_t::MEDIUM: case settingOffSpeed_t::MEDIUM:
OLED::print(SettingMediumChar); OLED::print(SettingMediumChar, FontStyle::LARGE);
break; break;
case settingOffSpeed_t::FAST: case settingOffSpeed_t::FAST:
OLED::print(SettingFastChar); OLED::print(SettingFastChar, FontStyle::LARGE);
break; break;
default: default:
OLED::print(SettingOffChar); OLED::print(SettingOffChar, FontStyle::LARGE);
break; break;
} }
return false; return false;
@@ -963,7 +956,7 @@ static bool settings_setPowerPulseWait(void) {
static bool settings_displayPowerPulseWait(void) { static bool settings_displayPowerPulseWait(void) {
if (systemSettings.KeepAwakePulse) { if (systemSettings.KeepAwakePulse) {
printShortDescription(31, 7); printShortDescription(31, 7);
OLED::printNumber(systemSettings.KeepAwakePulseWait, 1); OLED::printNumber(systemSettings.KeepAwakePulseWait, 1, FontStyle::LARGE);
return false; return false;
} else { } else {
return true; // skip return true; // skip
@@ -983,7 +976,7 @@ static bool settings_setPowerPulseDuration(void) {
static bool settings_displayPowerPulseDuration(void) { static bool settings_displayPowerPulseDuration(void) {
if (systemSettings.KeepAwakePulse) { if (systemSettings.KeepAwakePulse) {
printShortDescription(32, 7); printShortDescription(32, 7);
OLED::printNumber(systemSettings.KeepAwakePulseDuration, 1); OLED::printNumber(systemSettings.KeepAwakePulseDuration, 1, FontStyle::LARGE);
return false; return false;
} else { } else {
return true; // skip return true; // skip
@@ -995,17 +988,17 @@ static bool settings_displayHallEffect(void) {
printShortDescription(26, 7); printShortDescription(26, 7);
switch (systemSettings.hallEffectSensitivity) { switch (systemSettings.hallEffectSensitivity) {
case 1: case 1:
OLED::print(SettingSensitivityLow); OLED::print(SettingSensitivityLow, FontStyle::LARGE);
break; break;
case 2: case 2:
OLED::print(SettingSensitivityMedium); OLED::print(SettingSensitivityMedium, FontStyle::LARGE);
break; break;
case 3: case 3:
OLED::print(SettingSensitivityHigh); OLED::print(SettingSensitivityHigh, FontStyle::LARGE);
break; break;
case 0: case 0:
default: default:
OLED::print(SettingSensitivityOff); OLED::print(SettingSensitivityOff, FontStyle::LARGE);
break; break;
} }
return false; return false;
@@ -1024,16 +1017,17 @@ static bool animOpenState = false;
static void displayMenu(size_t index) { static void displayMenu(size_t index) {
// Call into the menu // Call into the menu
const char *textPtr = SettingsMenuEntries[index]; const char *textPtr = SettingsMenuEntries[index];
FontStyle font;
if (textPtr[0] == '\x01') { // `\x01` is used as newline. if (textPtr[0] == '\x01') { // `\x01` is used as newline.
// Empty first line means that this uses large font (for CJK). // Empty first line means that this uses large font (for CJK).
OLED::setFont(0); font = FontStyle::LARGE;
textPtr++; textPtr++;
} else { } else {
OLED::setFont(1); font = FontStyle::SMALL;
} }
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
// Draw title // Draw title
OLED::print(textPtr); OLED::print(textPtr, font);
// Draw symbol // Draw symbol
// 16 pixel wide image // 16 pixel wide image
// 2 pixel wide scrolling indicator // 2 pixel wide scrolling indicator
@@ -1135,7 +1129,6 @@ void gui_Menu(const menuitem *menu) {
// The extra buffer is discarded at the end of the transition. // The extra buffer is discarded at the end of the transition.
animOpenState = true; animOpenState = true;
OLED::useSecondaryFramebuffer(true); OLED::useSecondaryFramebuffer(true);
OLED::setFont(0);
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::clearScreen(); OLED::clearScreen();
menu[currentScreen].draw(); menu[currentScreen].draw();
@@ -1145,7 +1138,6 @@ void gui_Menu(const menuitem *menu) {
} }
while ((menu[currentScreen].draw != NULL) && earlyExit == false) { while ((menu[currentScreen].draw != NULL) && earlyExit == false) {
OLED::setFont(0);
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
// If the user has hesitated for >=3 seconds, show the long text // If the user has hesitated for >=3 seconds, show the long text
// Otherwise "draw" the option // Otherwise "draw" the option
@@ -1174,7 +1166,7 @@ void gui_Menu(const menuitem *menu) {
if (lastOffset != descriptionOffset) { if (lastOffset != descriptionOffset) {
OLED::clearScreen(); OLED::clearScreen();
OLED::setCursor((OLED_WIDTH - descriptionOffset), 0); OLED::setCursor((OLED_WIDTH - descriptionOffset), 0);
OLED::print(menu[currentScreen].description); OLED::print(menu[currentScreen].description, FontStyle::LARGE);
lastOffset = descriptionOffset; lastOffset = descriptionOffset;
lcdRefresh = true; lcdRefresh = true;
} }

View File

@@ -41,7 +41,6 @@ int main(void) {
preRToSInit(); preRToSInit();
setTipX10Watts(0); // force tip off setTipX10Watts(0); // force tip off
resetWatchdog(); resetWatchdog();
OLED::setFont(0); // default to bigger font
// Testing for which accelerometer is mounted // Testing for which accelerometer is mounted
settingsWereReset = restoreSettings(); // load the settings from flash settingsWereReset = restoreSettings(); // load the settings from flash
resetWatchdog(); resetWatchdog();

View File

@@ -43,20 +43,19 @@ static uint16_t min(uint16_t a, uint16_t b) {
else else
return a; return a;
} }
void warnUser(const char *warning, const int font, const int timeout) { void warnUser(const char *warning, const FontStyle font, const int timeout) {
OLED::setFont(font);
OLED::clearScreen(); OLED::clearScreen();
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::print(warning); OLED::print(warning, font);
OLED::refresh(); OLED::refresh();
waitForButtonPressOrTimeout(timeout); waitForButtonPressOrTimeout(timeout);
} }
void printVoltage() { void printVoltage() {
uint32_t volt = getInputVoltageX10(systemSettings.voltageDiv, 0); uint32_t volt = getInputVoltageX10(systemSettings.voltageDiv, 0);
OLED::printNumber(volt / 10, 2); OLED::printNumber(volt / 10, 2, FontStyle::SMALL);
OLED::print(SymbolDot); OLED::print(SymbolDot, FontStyle::SMALL);
OLED::printNumber(volt % 10, 1); OLED::printNumber(volt % 10, 1, FontStyle::SMALL);
} }
void GUIDelay() { void GUIDelay() {
// Called in all UI looping tasks, // Called in all UI looping tasks,
@@ -65,7 +64,7 @@ void GUIDelay() {
// prevent the movement detection from running // prevent the movement detection from running
osDelay(50); osDelay(50);
} }
void gui_drawTipTemp(bool symbol) { void gui_drawTipTemp(bool symbol, const FontStyle font) {
// Draw tip temp handling unit conversion & tolerance near setpoint // Draw tip temp handling unit conversion & tolerance near setpoint
uint32_t Temp = 0; uint32_t Temp = 0;
if (systemSettings.temperatureInF) { if (systemSettings.temperatureInF) {
@@ -74,9 +73,9 @@ void gui_drawTipTemp(bool symbol) {
Temp = TipThermoModel::getTipInC(); Temp = TipThermoModel::getTipInC();
} }
OLED::printNumber(Temp, 3); // Draw the tip temp out OLED::printNumber(Temp, 3, font); // Draw the tip temp out
if (symbol) { if (symbol) {
if (OLED::getFont() == 0) { if (font == FontStyle::LARGE) {
// Big font, can draw nice symbols // Big font, can draw nice symbols
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
OLED::drawSymbol(0); OLED::drawSymbol(0);
@@ -85,9 +84,9 @@ void gui_drawTipTemp(bool symbol) {
} else { } else {
// Otherwise fall back to chars // Otherwise fall back to chars
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
OLED::print(SymbolDegF); OLED::print(SymbolDegF, FontStyle::SMALL);
else else
OLED::print(SymbolDegC); OLED::print(SymbolDegC, FontStyle::SMALL);
} }
} }
} }
@@ -108,15 +107,13 @@ static bool checkVoltageForExit() {
OLED::clearScreen(); OLED::clearScreen();
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
if (systemSettings.detailedSoldering) { if (systemSettings.detailedSoldering) {
OLED::setFont(1); OLED::print(UndervoltageString, FontStyle::SMALL);
OLED::print(UndervoltageString);
OLED::setCursor(0, 8); OLED::setCursor(0, 8);
OLED::print(InputVoltageString); OLED::print(InputVoltageString, FontStyle::SMALL);
printVoltage(); printVoltage();
OLED::print(SymbolVolts); OLED::print(SymbolVolts, FontStyle::SMALL);
} else { } else {
OLED::setFont(0); OLED::print(UVLOWarningString, FontStyle::LARGE);
OLED::print(UVLOWarningString);
} }
OLED::refresh(); OLED::refresh();
@@ -140,14 +137,12 @@ static void gui_drawBatteryIcon() {
V = V / 10; V = V / 10;
if (V >= 10) { if (V >= 10) {
int16_t xPos = OLED::getCursorX(); int16_t xPos = OLED::getCursorX();
OLED::setFont(1); OLED::printNumber(V / 10, 1, FontStyle::SMALL);
OLED::printNumber(V / 10, 1);
OLED::setCursor(xPos, 8); OLED::setCursor(xPos, 8);
OLED::printNumber(V % 10, 1); OLED::printNumber(V % 10, 1, FontStyle::SMALL);
OLED::setFont(0);
OLED::setCursor(xPos + 12, 0); // need to reset this as if we drew a wide char OLED::setCursor(xPos + 12, 0); // need to reset this as if we drew a wide char
} else { } else {
OLED::printNumber(V, 1); OLED::printNumber(V, 1, FontStyle::LARGE);
} }
return; return;
} }
@@ -185,7 +180,6 @@ static void gui_solderingTempAdjust() {
for (;;) { for (;;) {
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::clearScreen(); OLED::clearScreen();
OLED::setFont(0);
buttons = getButtonState(); buttons = getButtonState();
if (buttons) { if (buttons) {
if (waitForRelease) { if (waitForRelease) {
@@ -264,27 +258,27 @@ static void gui_solderingTempAdjust() {
#else #else
if (OLED::getRotation()) { if (OLED::getRotation()) {
#endif #endif
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus); OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus, FontStyle::LARGE);
} else { } else {
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus); OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus, FontStyle::LARGE);
} }
OLED::print(SymbolSpace); OLED::print(SymbolSpace, FontStyle::LARGE);
OLED::printNumber(systemSettings.SolderingTemp, 3); OLED::printNumber(systemSettings.SolderingTemp, 3, FontStyle::LARGE);
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
OLED::drawSymbol(0); OLED::drawSymbol(0);
else { else {
OLED::drawSymbol(1); OLED::drawSymbol(1);
} }
OLED::print(SymbolSpace); OLED::print(SymbolSpace, FontStyle::LARGE);
#ifdef OLED_FLIP #ifdef OLED_FLIP
if (!OLED::getRotation()) { if (!OLED::getRotation()) {
#else #else
if (OLED::getRotation()) { if (OLED::getRotation()) {
#endif #endif
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus); OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus, FontStyle::LARGE);
} else { } else {
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus); OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus, FontStyle::LARGE);
} }
OLED::refresh(); OLED::refresh();
GUIDelay(); GUIDelay();
@@ -332,24 +326,22 @@ static int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
OLED::clearScreen(); OLED::clearScreen();
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
if (systemSettings.detailedSoldering) { if (systemSettings.detailedSoldering) {
OLED::setFont(1); OLED::print(SleepingAdvancedString, FontStyle::SMALL);
OLED::print(SleepingAdvancedString);
OLED::setCursor(0, 8); OLED::setCursor(0, 8);
OLED::print(SleepingTipAdvancedString); OLED::print(SleepingTipAdvancedString, FontStyle::SMALL);
OLED::printNumber(tipTemp, 3); OLED::printNumber(tipTemp, 3, FontStyle::SMALL);
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
OLED::print(SymbolDegF); OLED::print(SymbolDegF, FontStyle::SMALL);
else { else {
OLED::print(SymbolDegC); OLED::print(SymbolDegC, FontStyle::SMALL);
} }
OLED::print(SymbolSpace); OLED::print(SymbolSpace, FontStyle::SMALL);
printVoltage(); printVoltage();
OLED::print(SymbolVolts); OLED::print(SymbolVolts, FontStyle::SMALL);
} else { } else {
OLED::setFont(0); OLED::print(SleepingSimpleString, FontStyle::LARGE);
OLED::print(SleepingSimpleString); OLED::printNumber(tipTemp, 3, FontStyle::LARGE);
OLED::printNumber(tipTemp, 3);
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
OLED::drawSymbol(0); OLED::drawSymbol(0);
else { else {
@@ -379,11 +371,11 @@ static void display_countdown(int sleepThres) {
int lastEventTime = lastButtonTime < lastMovementTime ? lastMovementTime : lastButtonTime; int lastEventTime = lastButtonTime < lastMovementTime ? lastMovementTime : lastButtonTime;
TickType_t downCount = sleepThres - xTaskGetTickCount() + lastEventTime; TickType_t downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
if (downCount > (99 * TICKS_SECOND)) { if (downCount > (99 * TICKS_SECOND)) {
OLED::printNumber(downCount / 60000 + 1, 2); OLED::printNumber(downCount / 60000 + 1, 2, FontStyle::SMALL);
OLED::print(SymbolMinutes); OLED::print(SymbolMinutes, FontStyle::SMALL);
} else { } else {
OLED::printNumber(downCount / 1000 + 1, 2); OLED::printNumber(downCount / 1000 + 1, 2, FontStyle::SMALL);
OLED::print(SymbolSeconds); OLED::print(SymbolSeconds, FontStyle::SMALL);
} }
} }
static uint32_t getSleepTimeout() { static uint32_t getSleepTimeout() {
@@ -470,7 +462,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
case BUTTON_BOTH_LONG: case BUTTON_BOTH_LONG:
// Unlock buttons // Unlock buttons
buttonsLocked = false; buttonsLocked = false;
warnUser(UnlockingKeysString, 0, TICKS_SECOND); warnUser(UnlockingKeysString, FontStyle::LARGE, TICKS_SECOND);
break; break;
case BUTTON_F_LONG: case BUTTON_F_LONG:
// if boost mode is enabled turn it on // if boost mode is enabled turn it on
@@ -484,7 +476,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
case BUTTON_F_SHORT: case BUTTON_F_SHORT:
case BUTTON_B_SHORT: case BUTTON_B_SHORT:
// Do nothing and display a lock warming // Do nothing and display a lock warming
warnUser(WarningKeysLockedString, 0, TICKS_SECOND / 2); warnUser(WarningKeysLockedString, FontStyle::LARGE, TICKS_SECOND / 2);
break; break;
default: default:
break; break;
@@ -519,7 +511,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
if (systemSettings.lockingMode != 0) { if (systemSettings.lockingMode != 0) {
// Lock buttons // Lock buttons
buttonsLocked = true; buttonsLocked = true;
warnUser(LockingKeysString, 0, TICKS_SECOND); warnUser(LockingKeysString, FontStyle::LARGE, TICKS_SECOND);
} }
break; break;
default: default:
@@ -529,47 +521,45 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
// else we update the screen information // else we update the screen information
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::clearScreen(); OLED::clearScreen();
OLED::setFont(0);
// Draw in the screen details // Draw in the screen details
if (systemSettings.detailedSoldering) { if (systemSettings.detailedSoldering) {
OLED::setFont(1); OLED::print(SolderingAdvancedPowerPrompt, FontStyle::SMALL); // Power:
OLED::print(SolderingAdvancedPowerPrompt); // Power: OLED::printNumber(x10WattHistory.average() / 10, 2, FontStyle::SMALL);
OLED::printNumber(x10WattHistory.average() / 10, 2); OLED::print(SymbolDot, FontStyle::SMALL);
OLED::print(SymbolDot); OLED::printNumber(x10WattHistory.average() % 10, 1, FontStyle::SMALL);
OLED::printNumber(x10WattHistory.average() % 10, 1); OLED::print(SymbolWatts, FontStyle::SMALL);
OLED::print(SymbolWatts);
if (systemSettings.sensitivity && systemSettings.SleepTime) { if (systemSettings.sensitivity && systemSettings.SleepTime) {
OLED::print(SymbolSpace); OLED::print(SymbolSpace, FontStyle::SMALL);
display_countdown(getSleepTimeout()); display_countdown(getSleepTimeout());
} }
OLED::setCursor(0, 8); OLED::setCursor(0, 8);
OLED::print(SleepingTipAdvancedString); OLED::print(SleepingTipAdvancedString, FontStyle::SMALL);
gui_drawTipTemp(true); gui_drawTipTemp(true, FontStyle::SMALL);
if (boostModeOn) { if (boostModeOn) {
OLED::print(SymbolPlus); OLED::print(SymbolPlus, FontStyle::SMALL);
} else { } else {
OLED::print(SymbolSpace); OLED::print(SymbolSpace, FontStyle::SMALL);
} }
printVoltage(); printVoltage();
OLED::print(SymbolVolts); OLED::print(SymbolVolts, FontStyle::SMALL);
} else { } else {
// We switch the layout direction depending on the orientation of the oled // We switch the layout direction depending on the orientation of the oled
if (OLED::getRotation()) { if (OLED::getRotation()) {
// battery // battery
gui_drawBatteryIcon(); gui_drawBatteryIcon();
OLED::print(SymbolSpace); // Space out gap between battery <-> temp OLED::print(SymbolSpace, FontStyle::LARGE); // Space out gap between battery <-> temp
gui_drawTipTemp(true); // Draw current tip temp gui_drawTipTemp(true, FontStyle::LARGE); // Draw current tip temp
// We draw boost arrow if boosting, or else gap temp <-> heat // We draw boost arrow if boosting, or else gap temp <-> heat
// indicator // indicator
if (boostModeOn) if (boostModeOn)
OLED::drawSymbol(2); OLED::drawSymbol(2);
else else
OLED::print(SymbolSpace); OLED::print(SymbolSpace, FontStyle::LARGE);
// Draw heating/cooling symbols // Draw heating/cooling symbols
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average())); OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
@@ -581,10 +571,10 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
if (boostModeOn) if (boostModeOn)
OLED::drawSymbol(2); OLED::drawSymbol(2);
else else
OLED::print(SymbolSpace); OLED::print(SymbolSpace, FontStyle::LARGE);
gui_drawTipTemp(true); // Draw current tip temp gui_drawTipTemp(true, FontStyle::LARGE); // Draw current tip temp
OLED::print(SymbolSpace); // Space out gap between battery <-> temp OLED::print(SymbolSpace, FontStyle::LARGE); // Space out gap between battery <-> temp
gui_drawBatteryIcon(); gui_drawBatteryIcon();
} }
@@ -627,47 +617,46 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
void showDebugMenu(void) { void showDebugMenu(void) {
uint8_t screen = 0; uint8_t screen = 0;
ButtonState b; ButtonState b;
OLED::setFont(1); // small font
for (;;) { for (;;) {
OLED::clearScreen(); // Ensure the buffer starts clean OLED::clearScreen(); // Ensure the buffer starts clean
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left) OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
OLED::print(SymbolVersionNumber); // Print version number OLED::print(SymbolVersionNumber, FontStyle::SMALL); // Print version number
OLED::setCursor(0, 8); // second line OLED::setCursor(0, 8); // second line
OLED::print(DebugMenu[screen]); OLED::print(DebugMenu[screen], FontStyle::SMALL);
switch (screen) { switch (screen) {
case 0: // Just prints date case 0: // Just prints date
break; break;
case 1: case 1:
// High water mark for GUI // High water mark for GUI
OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5); OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL);
break; break;
case 2: case 2:
// High water mark for the Movement task // High water mark for the Movement task
OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5); OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL);
break; break;
case 3: case 3:
// High water mark for the PID task // High water mark for the PID task
OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5); OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL);
break; break;
case 4: case 4:
// system up time stamp // system up time stamp
OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 5); OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 5, FontStyle::SMALL);
break; break;
case 5: case 5:
// Movement time stamp // Movement time stamp
OLED::printNumber(lastMovementTime / TICKS_100MS, 5); OLED::printNumber(lastMovementTime / TICKS_100MS, 5, FontStyle::SMALL);
break; break;
case 6: case 6:
// Raw Tip // Raw Tip
{ OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), 6); } { OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), 6, FontStyle::SMALL); }
break; break;
case 7: case 7:
// Temp in C // Temp in C
OLED::printNumber(TipThermoModel::getTipInC(), 5); OLED::printNumber(TipThermoModel::getTipInC(), 5, FontStyle::SMALL);
break; break;
case 8: case 8:
// Handle Temp // Handle Temp
OLED::printNumber(getHandleTemperature(), 3); OLED::printNumber(getHandleTemperature(), 3, FontStyle::SMALL);
break; break;
case 9: case 9:
// Voltage input // Voltage input
@@ -675,12 +664,12 @@ void showDebugMenu(void) {
break; break;
case 10: case 10:
// Print PCB ID number // Print PCB ID number
OLED::printNumber(DetectedAccelerometerVersion, 2); OLED::printNumber(DetectedAccelerometerVersion, 2, FontStyle::SMALL);
break; break;
case 11: case 11:
// Power negotiation status // Power negotiation status
if (getIsPoweredByDCIN()) { if (getIsPoweredByDCIN()) {
OLED::printNumber(0, 1); OLED::printNumber(0, 1, FontStyle::SMALL);
} else { } else {
// We are not powered via DC, so want to display the appropriate state for PD or QC // We are not powered via DC, so want to display the appropriate state for PD or QC
bool poweredbyPD = false; bool poweredbyPD = false;
@@ -694,16 +683,16 @@ void showDebugMenu(void) {
} }
#endif #endif
if (poweredbyPD) { if (poweredbyPD) {
OLED::printNumber(2, 1); OLED::printNumber(2, 1, FontStyle::SMALL);
} else { } else {
OLED::printNumber(1, 1); OLED::printNumber(1, 1, FontStyle::SMALL);
} }
} }
break; break;
case 12: case 12:
// Max deg C limit // Max deg C limit
OLED::printNumber(TipThermoModel::getTipMaxInC(), 3); OLED::printNumber(TipThermoModel::getTipMaxInC(), 3, FontStyle::SMALL);
break; break;
default: default:
break; break;
@@ -726,9 +715,9 @@ void showWarnings() {
if (settingsWereReset) { if (settingsWereReset) {
if (SettingsResetMessage[0] == '\x01') { // `\x01` is used as newline. if (SettingsResetMessage[0] == '\x01') { // `\x01` is used as newline.
// Empty first line means that this uses large font (for CJK). // Empty first line means that this uses large font (for CJK).
warnUser(SettingsResetMessage + 1, 0, 10 * TICKS_SECOND); warnUser(SettingsResetMessage + 1, FontStyle::LARGE, 10 * TICKS_SECOND);
} else { } else {
warnUser(SettingsResetMessage, 1, 10 * TICKS_SECOND); warnUser(SettingsResetMessage, FontStyle::SMALL, 10 * TICKS_SECOND);
} }
} }
#ifndef NO_WARN_MISSING #ifndef NO_WARN_MISSING
@@ -743,7 +732,7 @@ void showWarnings() {
if (systemSettings.accelMissingWarningCounter < 2) { if (systemSettings.accelMissingWarningCounter < 2) {
systemSettings.accelMissingWarningCounter++; systemSettings.accelMissingWarningCounter++;
saveSettings(); saveSettings();
warnUser(NoAccelerometerMessage, 1, 10 * TICKS_SECOND); warnUser(NoAccelerometerMessage, FontStyle::SMALL, 10 * TICKS_SECOND);
} }
} }
#ifdef POW_PD #ifdef POW_PD
@@ -752,7 +741,7 @@ void showWarnings() {
if (systemSettings.pdMissingWarningCounter < 2) { if (systemSettings.pdMissingWarningCounter < 2) {
systemSettings.pdMissingWarningCounter++; systemSettings.pdMissingWarningCounter++;
saveSettings(); saveSettings();
warnUser(NoPowerDeliveryMessage, 1, 10 * TICKS_SECOND); warnUser(NoPowerDeliveryMessage, FontStyle::SMALL, 10 * TICKS_SECOND);
} }
} }
#endif #endif
@@ -802,7 +791,6 @@ void startGUITask(void const *argument __unused) {
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
if (buttons != BUTTON_NONE) { if (buttons != BUTTON_NONE) {
OLED::setDisplayState(OLED::DisplayState::ON); OLED::setDisplayState(OLED::DisplayState::ON);
OLED::setFont(0);
} }
if (tempWarningState == 2) if (tempWarningState == 2)
buttons = BUTTON_F_SHORT; buttons = BUTTON_F_SHORT;
@@ -860,22 +848,20 @@ void startGUITask(void const *argument __unused) {
OLED::clearScreen(); OLED::clearScreen();
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
if (systemSettings.detailedIDLE) { if (systemSettings.detailedIDLE) {
OLED::setFont(1);
if (tipTemp > tipDisconnectedThres) { if (tipTemp > tipDisconnectedThres) {
OLED::print(TipDisconnectedString); OLED::print(TipDisconnectedString, FontStyle::SMALL);
} else { } else {
OLED::print(IdleTipString); OLED::print(IdleTipString, FontStyle::SMALL);
gui_drawTipTemp(false); gui_drawTipTemp(false, FontStyle::SMALL);
OLED::print(IdleSetString); OLED::print(IdleSetString, FontStyle::SMALL);
OLED::printNumber(systemSettings.SolderingTemp, 3); OLED::printNumber(systemSettings.SolderingTemp, 3, FontStyle::SMALL);
} }
OLED::setCursor(0, 8); OLED::setCursor(0, 8);
OLED::print(InputVoltageString); OLED::print(InputVoltageString, FontStyle::SMALL);
printVoltage(); printVoltage();
} else { } else {
OLED::setFont(0);
#ifdef OLED_FLIP #ifdef OLED_FLIP
if (!OLED::getRotation()) { if (!OLED::getRotation()) {
#else #else
@@ -919,7 +905,7 @@ void startGUITask(void const *argument __unused) {
if (!tipDisconnectedDisplay) { if (!tipDisconnectedDisplay) {
// draw in the temp // draw in the temp
if (!(systemSettings.coolingTempBlink && (xTaskGetTickCount() % 260 < 160))) if (!(systemSettings.coolingTempBlink && (xTaskGetTickCount() % 260 < 160)))
gui_drawTipTemp(false); // draw in the temp gui_drawTipTemp(false, FontStyle::LARGE); // draw in the temp
} else { } else {
// Draw in missing tip symbol // Draw in missing tip symbol