1
0
forked from me/IronOS

Refactor printing CJK menu with large font into OLED.cpp

This commit is contained in:
Alvin Wong
2021-03-29 19:07:50 +08:00
parent 55fa5c95e4
commit 53c02dca33
3 changed files with 24 additions and 23 deletions

View File

@@ -267,6 +267,26 @@ void OLED::print(const char *const str, FontStyle fontStyle) {
}
}
/**
* Prints a static string message designed to use the whole screen, starting
* from the top-left corner.
*
* If the message starts with a newline (`\\x01`), the string starting from
* after the newline is printed in the large font. Otherwise, the message
* is printed in the small font.
*
* @param string The string message to be printed
*/
void OLED::printWholeScreen(const char *string) {
setCursor(0, 0);
if (string[0] == '\x01') {
// Empty first line means that this uses large font (for CJK).
OLED::print(string + 1, FontStyle::LARGE);
} else {
OLED::print(string, FontStyle::SMALL);
}
}
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

View File

@@ -55,6 +55,7 @@ public:
static bool getRotation() { return inLeftHandedMode; }
static int16_t getCursorX() { return cursor_x; }
static void print(const char *string, FontStyle fontStyle); // Draw a string to the current location, with selected font
static void printWholeScreen(const char *string);
// Set the cursor location by pixels
static void setCursor(int16_t x, int16_t y) {
cursor_x = x;