44 lines
1.0 KiB
C++
44 lines
1.0 KiB
C++
#include "DisplayManager.h"
|
|
|
|
DisplayManager::DisplayManager(int8_t cs, int8_t dc, int8_t rst)
|
|
: _tft(cs, dc, rst)
|
|
{
|
|
}
|
|
|
|
void DisplayManager::begin() {
|
|
_tft.init(240, 320); // Initialize your specific ST7789 size
|
|
_tft.setRotation(1);
|
|
clear();
|
|
}
|
|
|
|
void DisplayManager::clear() {
|
|
_tft.fillScreen(ST77XX_BLACK);
|
|
}
|
|
|
|
void DisplayManager::drawCenteredText(const char* text, uint16_t color) {
|
|
clear();
|
|
_tft.setTextSize(2);
|
|
_tft.setTextColor(color);
|
|
|
|
int16_t x1, y1;
|
|
uint16_t w, h;
|
|
|
|
// Use the actual _tft object logic you had in Emotes.cpp
|
|
_tft.getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
|
|
|
int16_t cx = (_tft.width() - w) / 2;
|
|
int16_t cy = (_tft.height() - h) / 2;
|
|
|
|
_tft.setCursor(cx, cy);
|
|
_tft.print(text);
|
|
}
|
|
|
|
void DisplayManager::setEmote(uint8_t emoteId) {
|
|
_currentEmote = emoteId;
|
|
// Logic for drawing different faces based on ID
|
|
// switch(emoteId) { case 1: drawHappyFace(); break; ... }
|
|
}
|
|
|
|
void DisplayManager::update() {
|
|
// If you add eyes that blink, the logic goes here
|
|
} |