Smart Matrix
|
String class implements text manipulation to be used by a Screen object e.g. matrix object. More...
#include <String.hpp>
Public Member Functions | |
String (Screen &w, const uint8_t *font, char *text, uint8_t r, uint8_t g, uint8_t b, vector location=vector(31, 63)) | |
String constructor. More... | |
String (Screen &w, const uint8_t *font, char *text, uint32_t color, vector location=vector(31, 63)) | |
String constructor. More... | |
void | draw () override |
Print the text on the screen. More... | |
void | scroll (int updateInterval=10, bool loop=false, int startX=64) |
Scroll text from left to right at startX. More... | |
void | setText (char *t) |
Set the text of string. More... | |
void | setColor (uint32_t c) |
Set the color of the string. More... | |
void | setColor (uint8_t rc, uint8_t gc, uint8_t bc) |
Set the color of the string. More... | |
void | setFont (const uint8_t *f) |
Set the font of the string. More... | |
![]() | |
Graphics (Screen &w, vector size, vector location) | |
Graphics constructor. More... | |
vector | getSize () const |
return the size of a graphics object. | |
vector | getLocation () const |
return the location of a graphics object. | |
Screen & | getScreen () const |
return the screen used by graphics object | |
void | setLocation (vector l) |
change the location of a graphics object. | |
void | setSize (vector s) |
change the size of a graphics object | |
Additional Inherited Members | |
![]() | |
Screen & | w |
vector | size |
vector | location |
String class implements text manipulation to be used by a Screen object e.g. matrix object.
String class can print a text on the screen and/or scroll it from right to left.
String::String | ( | Screen & | w, |
const uint8_t * | font, | ||
char * | text, | ||
uint8_t | r, | ||
uint8_t | g, | ||
uint8_t | b, | ||
vector | location = vector(31,63) |
||
) |
String constructor.
Screen is the display you want to draw text on to it e.g. matrix. font is a font file. you need to convert the normal .ttf font with a commandline script and then include the .h file into your project. font is the name of array in that file (usually the same as the file name e.g. tahoma10). text is the string you want to write on the screen. You have to typecast your string first to char*. for example if you want to print "Hallo World" you have to pass it like this: (char*)"Hallo World". r g b are colors of the text. they are between 0 and 255. location is the location of line you want to write text on it. The height or Y should be greater than font size to be able to see the text on screen. The characters will be printed from bottom to top.
String::String | ( | Screen & | w, |
const uint8_t * | font, | ||
char * | text, | ||
uint32_t | color, | ||
vector | location = vector(31,63) |
||
) |
String constructor.
Screen is the display you want to draw text on to it e.g. matrix. font is a font file. you need to convert the normal .ttf font with a commandline script and then include the .h file into your project. font is the name of array in that file (usually the same as the file name e.g. tahoma10). text is the string you want to write on the screen. You have to typecast your string first to char*. for example if you want to print "Hallo World" you have to pass it like this: (char*)"Hallo World". color is the colors of the text. It can be max 24 bits (2^24-1). location is the location of line you want to write text on it. The height or Y should be greater than font size to be able to see the text on screen. The characters will be printed from bottom to top.
|
overridevirtual |
Print the text on the screen.
The characters will be printed on the screen at the specified position. Note that if double buffering is enabled you have to swap the buffers for the text to be showed on the screen.
Implements Graphics.
void String::scroll | ( | int | updateInterval = 10 , |
bool | loop = false , |
||
int | startX = 64 |
||
) |
Scroll text from left to right at startX.
This function scrolls the text from right to left at the speed of "updateInterval". "updateInterval" is in milliseconds. if loop is true the scrolling of the text would be continuously. startX is width's postion where the text start to scroll from. You do not need to swap the buffer. It's done internally.
void String::setColor | ( | uint32_t | c | ) |
Set the color of the string.
This function changes the color of the text. the color can be a (hexa)decimal between 0 and 2^24-1.
void String::setColor | ( | uint8_t | rc, |
uint8_t | gc, | ||
uint8_t | bc | ||
) |
Set the color of the string.
This function changes the color of the text. r g and b can be between 0 and 255.
|
inline |
Set the font of the string.
This function changes the font of the string. font is a font file. you need to convert the normal .ttf font with a commandline script and then include the .h file into your project. font is the name of array in that file (usually the same as the file name e.g. tahoma10).
|
inline |
Set the text of string.
This function changes the text of the string. It has to be typecasted to char*. For example if you want to pass "Hallo World" to the function, you have to write it as: (char*)"Hallo World".