74 lines
2.3 KiB
C++
74 lines
2.3 KiB
C++
#pragma once
|
|
#include <TFT_eSPI.h>
|
|
#include "ScreenData.h"
|
|
#include "Dashboard.h"
|
|
|
|
// Hold gesture result
|
|
struct HoldState {
|
|
bool active = false; // finger currently down
|
|
bool completed = false; // hold duration met
|
|
uint16_t x = 0;
|
|
uint16_t y = 0;
|
|
unsigned long holdMs = 0; // how long held so far
|
|
unsigned long targetMs = 0; // required hold duration
|
|
};
|
|
|
|
class DisplayManager {
|
|
public:
|
|
DisplayManager();
|
|
void begin();
|
|
void render(const ScreenState& state);
|
|
void setBacklight(bool on);
|
|
TouchEvent readTouch();
|
|
|
|
// Dashboard tile touch — returns TileID or -1
|
|
int dashboardTouch(uint16_t x, uint16_t y);
|
|
|
|
// Hold detection — call each loop iteration
|
|
HoldState updateHold(unsigned long requiredMs);
|
|
|
|
// Draw hold-to-silence progress bar on alert screen
|
|
void drawSilenceProgress(float progress);
|
|
|
|
private:
|
|
TFT_eSPI _tft;
|
|
Dashboard _dash;
|
|
ScreenID _lastScreen = ScreenID::BOOT_SPLASH;
|
|
bool _needsFullRedraw = true;
|
|
bool _lastBlink = false;
|
|
bool _dashSpriteReady = false;
|
|
unsigned long _lastDashRefresh = 0;
|
|
|
|
// Hold tracking state
|
|
bool _holdActive = false;
|
|
unsigned long _holdStartMs = 0;
|
|
uint16_t _holdX = 0;
|
|
uint16_t _holdY = 0;
|
|
|
|
// Colors
|
|
static constexpr uint16_t COL_NEON_TEAL = 0x07D7;
|
|
static constexpr uint16_t COL_HOT_FUCHSIA = 0xF81F;
|
|
static constexpr uint16_t COL_WHITE = 0xFFDF;
|
|
static constexpr uint16_t COL_BLACK = 0x0000;
|
|
static constexpr uint16_t COL_MINT = 0x67F5;
|
|
static constexpr uint16_t COL_DARK_GRAY = 0x2104;
|
|
static constexpr uint16_t COL_GREEN = 0x07E0;
|
|
static constexpr uint16_t COL_RED = 0xF800;
|
|
static constexpr uint16_t COL_YELLOW = 0xFFE0;
|
|
|
|
// Screen renderers
|
|
void drawBootSplash(const ScreenState& s);
|
|
void drawWifiConnecting();
|
|
void drawWifiConnected(const ScreenState& s);
|
|
void drawWifiFailed();
|
|
void drawAlertScreen(const ScreenState& s);
|
|
void drawStatusScreen(const ScreenState& s);
|
|
void drawDashboard(const ScreenState& s);
|
|
|
|
// Helpers
|
|
void drawCentered(const char* txt, int y, int sz, uint16_t col);
|
|
void drawInfoLine(int x, int y, uint16_t col, const char* text);
|
|
void drawHeaderBar(uint16_t col, const char* label, const char* timeStr);
|
|
};
|
|
|