diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 7adf77a7..309fe87c 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -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 diff --git a/source/Core/Drivers/OLED.hpp b/source/Core/Drivers/OLED.hpp index 458f74ef..9332c4ee 100644 --- a/source/Core/Drivers/OLED.hpp +++ b/source/Core/Drivers/OLED.hpp @@ -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; diff --git a/source/Core/Src/gui.cpp b/source/Core/Src/gui.cpp index 9af35b9b..72b6b320 100644 --- a/source/Core/Src/gui.cpp +++ b/source/Core/Src/gui.cpp @@ -237,17 +237,6 @@ const menuitem advancedMenu[] = { {nullptr, nullptr, nullptr} // end of menu marker. DO NOT REMOVE }; -static void printShortDescriptionDoubleLine(SettingsItemIndex settingsItemIndex) { - uint8_t shortDescIndex = static_cast(settingsItemIndex); - OLED::setCursor(0, 0); - if (SettingsShortNames[shortDescIndex][0] == '\x01') { - // Empty first line means that this uses large font (for CJK). - OLED::print(SettingsShortNames[shortDescIndex] + 1, FontStyle::LARGE); - } else { - OLED::print(SettingsShortNames[shortDescIndex], FontStyle::SMALL); - } -} - /** * Prints two small lines (or one line for CJK) of short description for * setting items and prepares cursor after it. @@ -257,7 +246,8 @@ static void printShortDescriptionDoubleLine(SettingsItemIndex settingsItemIndex) */ static void printShortDescription(SettingsItemIndex settingsItemIndex, uint16_t cursorCharPosition) { // print short description (default single line, explicit double line) - printShortDescriptionDoubleLine(settingsItemIndex); + uint8_t shortDescIndex = static_cast(settingsItemIndex); + OLED::printWholeScreen(SettingsShortNames[shortDescIndex]); // prepare cursor for value // make room for scroll indicator @@ -1011,18 +1001,8 @@ static bool animOpenState = false; static void displayMenu(size_t index) { // Call into the menu - const char *textPtr = SettingsMenuEntries[index]; - FontStyle font; - if (textPtr[0] == '\x01') { // `\x01` is used as newline. - // Empty first line means that this uses large font (for CJK). - font = FontStyle::LARGE; - textPtr++; - } else { - font = FontStyle::SMALL; - } - OLED::setCursor(0, 0); // Draw title - OLED::print(textPtr, font); + OLED::printWholeScreen(SettingsMenuEntries[index]); // Draw symbol // 16 pixel wide image // 2 pixel wide scrolling indicator