print string to display

This commit is contained in:
Anton Jacker 2024-06-13 14:03:18 +02:00
parent 2d01315d45
commit 215155035e
No known key found for this signature in database
GPG Key ID: 6581AFF52DAA87AC
2 changed files with 48 additions and 0 deletions

View File

@ -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");

View File

@ -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