refactor: abstract hardware in DisplayManager

- TFT_eSPI -> Gfx typedef (zero-cost on E32R35T)
- Touch reads wrapped in #if USE_TOUCH_XPT2046 / USE_TOUCH_GT911
- Hardcoded rotation -> DISPLAY_ROTATION from BoardConfig
- All 480/320 literals -> SCREEN_WIDTH / SCREEN_HEIGHT
- Boot splash shows BOARD_NAME for target identification
- Added holdProgress() convenience method using HOLD_DURATION_MS
This commit is contained in:
2026-02-16 12:38:14 -08:00
parent 97abcd9916
commit 0ed4c7ffce
2 changed files with 209 additions and 206 deletions

View File

@@ -1,37 +1,37 @@
#pragma once
#include <TFT_eSPI.h>
#include "DisplayDriver.h"
#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
bool active = false;
bool charged = false;
bool completed = false;
bool cancelled = false;
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
float progress = 0.0f;
};
// Add near the top, alongside existing structs
// Hint animation state
struct HintAnim {
bool running = false;
unsigned long startMs = 0;
unsigned long lastPlayMs = 0;
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 const unsigned long INITIAL_DELAY = 1500;
static const unsigned long FILL_DUR = 400;
static const unsigned long HOLD_DUR = 250;
static const unsigned long DRAIN_DUR = 500;
static const unsigned long REPEAT_DELAY = 5000;
static constexpr float PEAK = 0.35f; // fill to 35%
static constexpr float PEAK = 0.35f;
unsigned long totalDur() const { return FILL_DUR + HOLD_DUR + DRAIN_DUR; }
unsigned long totalDur() const { return FILL_DUR + HOLD_DUR + DRAIN_DUR; }
};
class DisplayManager {
@@ -44,31 +44,32 @@ public:
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
void startHintCycle();
void stopHint();
bool updateHint();
float holdProgress() const;
private:
HintAnim _hint;
void drawHintBar(float progress); // ← add this
TFT_eSPI _tft;
Dashboard _dash;
HintAnim _hint;
void drawHintBar(float progress);
ScreenID _lastScreen = ScreenID::BOOT_SPLASH;
bool _needsFullRedraw = true;
bool _lastBlink = false;
bool _dashSpriteReady = false;
Gfx _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
bool _holdActive = false;
bool _holdCharged = false;
unsigned long _holdStartMs = 0;
unsigned long _holdChargeMs = 0; // when charge completed
uint16_t _holdX = 0;
uint16_t _holdY = 0;
float _holdProgress = 0.0f;
unsigned long _holdChargeMs = 0;
uint16_t _holdX = 0;
uint16_t _holdY = 0;
float _holdProgress = 0.0f;
// Colors
static constexpr uint16_t COL_NEON_TEAL = 0x07D7;
@@ -96,4 +97,3 @@ private:
void drawInfoLine(int x, int y, uint16_t col, const char* text);
void drawHeaderBar(uint16_t col, const char* label, const char* timeStr);
};