31 lines
626 B
C++
31 lines
626 B
C++
#include "Emotes.h"
|
|
|
|
JackBot::Emotes::Emotes(Adafruit_GFX* display) {
|
|
tft = display;
|
|
}
|
|
|
|
void JackBot::Emotes::clearScreen() {
|
|
tft->fillScreen(0x0000); // black
|
|
}
|
|
|
|
// Draw centered text
|
|
void JackBot::Emotes::drawCenteredText(const char* text, uint16_t color) {
|
|
clearScreen();
|
|
|
|
tft->setTextSize(2);
|
|
tft->setTextColor(color);
|
|
|
|
int16_t x1, y1;
|
|
uint16_t w, h;
|
|
|
|
// Measure the text
|
|
tft->getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
|
|
|
// Calculate center
|
|
int16_t cx = (tft->width() - w) / 2;
|
|
int16_t cy = (tft->height() - h) / 2;
|
|
|
|
tft->setCursor(cx, cy);
|
|
tft->print(text);
|
|
}
|