merged old Esp Verison with better FileManagement
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
#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);
|
||||
_tft.setRotation(1);
|
||||
clear();
|
||||
}
|
||||
|
||||
void DisplayManager::clear() {
|
||||
_tft.fillScreen(ST77XX_BLACK);
|
||||
}
|
||||
|
||||
void DisplayManager::setState(DisplayState state) {
|
||||
_currentState = state;
|
||||
// Force a redraw when state changes
|
||||
if (_currentState == STATE_FACE) {
|
||||
drawFaceScreen();
|
||||
} else {
|
||||
drawMenuScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayManager::toggleState() {
|
||||
if (_currentState == STATE_FACE) {
|
||||
setState(STATE_MENU);
|
||||
} else {
|
||||
setState(STATE_FACE);
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayManager::update() {
|
||||
// Put any periodic animations here (e.g., blinking face frames)
|
||||
}
|
||||
|
||||
// --- DESIGNED VIA LOPAKA.APP ---
|
||||
void DisplayManager::drawFaceScreen() {
|
||||
clear();
|
||||
// Example layout elements generated/inspired by Lopaka:
|
||||
_tft.setTextColor(ST77XX_CYAN);
|
||||
_tft.setTextSize(3);
|
||||
_tft.setCursor(90, 100);
|
||||
_tft.print("^ _ ^"); // Simple default face
|
||||
}
|
||||
|
||||
void DisplayManager::drawMenuScreen() {
|
||||
clear();
|
||||
|
||||
// Example Menu/Stats UI layout adapted from Lopaka export
|
||||
_tft.drawRect(10, 10, 300, 220, ST77XX_BLUE); // Outer box
|
||||
|
||||
_tft.setTextColor(ST77XX_WHITE);
|
||||
_tft.setTextSize(2);
|
||||
_tft.setCursor(30, 30);
|
||||
_tft.print("-- JACKBOT CONFIG --");
|
||||
|
||||
_tft.setTextSize(1);
|
||||
_tft.setCursor(30, 80);
|
||||
_tft.print("Status: Connected (UDP)");
|
||||
|
||||
_tft.setCursor(30, 110);
|
||||
_tft.print("Servo Profile: Standard");
|
||||
|
||||
_tft.setCursor(30, 140);
|
||||
_tft.print("Press button to exit menu");
|
||||
}
|
||||
|
||||
void DisplayManager::drawCenteredText(const char* text, uint16_t color) {
|
||||
if (_currentState != STATE_FACE) return; // Only override face text if we are on face screen
|
||||
|
||||
clear();
|
||||
_tft.setTextSize(2);
|
||||
_tft.setTextColor(color);
|
||||
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
_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);
|
||||
}
|
||||
Reference in New Issue
Block a user