diff --git a/src/display/Display.cpp b/src/display/Display.cpp index dd989c9..9fe39da 100644 --- a/src/display/Display.cpp +++ b/src/display/Display.cpp @@ -112,6 +112,31 @@ void Display::print(char *value){ } }; +char Display::stringToCharArray(String value) { + const int len = value.length() + 1; // +1 for the null terminator + char msgBuffer[len]; // Create a buffer of the appropriate length + + value.toCharArray(msgBuffer, len); // Copy the string into the buffer, including the null terminator + + return *msgBuffer; +} + +void Display::print(String value){ + const int len = value.length() + 1; // +1 for the null terminator + char msgBuffer[len]; // Create a buffer of the appropriate length + value.toCharArray(msgBuffer, len); + + this->print(msgBuffer); +}; + +void Display::println(String value){ + const int len = value.length() + 1; // +1 for the null terminator + char msgBuffer[len]; // Create a buffer of the appropriate length + value.toCharArray(msgBuffer, len); + + this->println(msgBuffer); +}; + void Display::println(char *value){ this ->print(value); this->print("\n"); diff --git a/src/display/Display.h b/src/display/Display.h index 1a2fb0b..6cdc230 100644 --- a/src/display/Display.h +++ b/src/display/Display.h @@ -71,6 +71,29 @@ class Display{ * @param value the string that should be printed */ void println(char *value); + + /** + * @brief prints the passed string right behind the current displaycontent + * the sequence "\n" can be used to make a linebreak on the display + * + * @param value the string "xyz" that should be printed to the display + */ + void print(String value); + + /** + * @brief same as the print method, but after the string a line break is inserted + * + * @param value the string that should be printed + */ + void println(String value); + + /** + * @brief string to char + * + * @param value the string that should be converted to char + */ + char stringToCharArray(String value); + /** * @brief flips the horizontal orientation of all content on the display