First Git Push
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user