app: add function to draw text on RGB panel
This commit is contained in:
parent
0e91b71aae
commit
a1da462852
@ -229,6 +229,38 @@ static void rgbmatrix_putc(uint8_t x, uint8_t y, char c, enum font_name font, bo
|
||||
}
|
||||
}
|
||||
|
||||
/** draw text on RGB matrix
|
||||
* @param[in] x horizontal position (0 = left)
|
||||
* @param[in] y vertical position (0 = top)
|
||||
* @param[in] str text to draw
|
||||
* @param[in] font font to use
|
||||
* @param[in] r if the character should be drawn in red
|
||||
* @param[in] g if the character should be drawn in green
|
||||
* @param[in] b if the character should be drawn in blue
|
||||
*/
|
||||
static void rgbmatrix_puts(uint8_t x, uint8_t y, char* str, enum font_name font, bool red, bool green, bool blue)
|
||||
{
|
||||
// sanity checks
|
||||
if (NULL == str) {
|
||||
return;
|
||||
}
|
||||
if (font >= FONT_MAX) {
|
||||
return;
|
||||
}
|
||||
if (y >= RGBMATRIX_HEIGHT) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t len = strlen(str);
|
||||
for (uint8_t i = 0; i < len; i++) {
|
||||
if (x >= RGBMATRIX_WIDTH) {
|
||||
return;
|
||||
}
|
||||
rgbmatrix_putc(x, y, str[i], font, red, green, blue);
|
||||
x += fonts[font].width + 1;
|
||||
}
|
||||
}
|
||||
|
||||
size_t putc(char c)
|
||||
{
|
||||
size_t length = 0; // number of characters printed
|
||||
@ -840,7 +872,9 @@ void main(void)
|
||||
command_speed(&speed);
|
||||
|
||||
// draw welcome text
|
||||
rgbmatrix_putc(1, 1, 'D', FONT_KING14, false, true, false);
|
||||
rgbmatrix_puts(1, 1, "DACHBODEN", FONT_KING10, false, true, false);
|
||||
rgbmatrix_puts(1, 12, "ZEIT", FONT_KING10, false, true, true);
|
||||
rgbmatrix_puts(1, 23, "MASCHINE", FONT_KING10, true, true, false);
|
||||
|
||||
// start main loop
|
||||
bool action = false; // if an action has been performed don't go to sleep
|
||||
|
Loading…
Reference in New Issue
Block a user