consolidate sketches

This commit is contained in:
2026-02-16 17:53:06 -08:00
parent 75c3f5706b
commit 838afaa36f
42 changed files with 5655 additions and 817 deletions

99
DisplayManager.h Normal file
View File

@@ -0,0 +1,99 @@
#pragma once
#include "DisplayDriver.h"
#include "ScreenData.h"
#include "Dashboard.h"
// Hold gesture result
struct HoldState {
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;
};
// Hint animation state
struct HintAnim {
bool running = false;
unsigned long startMs = 0;
unsigned long lastPlayMs = 0;
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;
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();
void stopHint();
bool updateHint();
float holdProgress() const;
private:
HintAnim _hint;
void drawHintBar(float progress);
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;
unsigned long _holdStartMs = 0;
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;
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);
};