#pragma once #include #include "ScreenData.h" #include "Dashboard.h" // Hold gesture result struct HoldState { bool active = false; // finger currently down bool charged = false; // hold duration met, waiting for release bool completed = false; // finger RELEASED after being charged → act now bool cancelled = false; // finger released before charge completed uint16_t x = 0; uint16_t y = 0; unsigned long holdMs = 0; unsigned long targetMs = 0; float progress = 0.0f; // 0.0 to 1.0 }; // Add near the top, alongside existing structs struct HintAnim { bool running = false; unsigned long startMs = 0; unsigned long lastPlayMs = 0; // Timing (ms) static const unsigned long INITIAL_DELAY = 1500; // pause before first hint static const unsigned long FILL_DUR = 400; // ease-in to peak static const unsigned long HOLD_DUR = 250; // dwell at peak static const unsigned long DRAIN_DUR = 500; // ease-out back to 0 static const unsigned long REPEAT_DELAY = 5000; // gap before replaying static constexpr float PEAK = 0.35f; // fill to 35% unsigned long totalDur() const { return FILL_DUR + HOLD_DUR + DRAIN_DUR; } }; class DisplayManager { public: DisplayManager(); void begin(); void render(const ScreenState& state); void setBacklight(bool on); TouchEvent readTouch(); int dashboardTouch(uint16_t x, uint16_t y); HoldState updateHold(unsigned long requiredMs); void startHintCycle(); // call when entering alert screen void stopHint(); // call when real hold begins or leaving alert bool updateHint(); // call each loop; returns true if it drew something private: HintAnim _hint; void drawHintBar(float progress); // ← add this 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 bool _holdActive = false; bool _holdCharged = false; // bar is full, waiting for release unsigned long _holdStartMs = 0; unsigned long _holdChargeMs = 0; // when charge completed uint16_t _holdX = 0; uint16_t _holdY = 0; float _holdProgress = 0.0f; // 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); void drawSilenceProgress(float progress, bool charged); // 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); };