58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "IDisplayDriver.h"
|
|
|
|
#include <Arduino.h>
|
|
|
|
class DisplayDriverGFX : public IDisplayDriver {
|
|
public:
|
|
// ── IDisplayDriver ──
|
|
void begin() override;
|
|
void setBacklight(bool on) override;
|
|
void render(const ScreenState& state) override;
|
|
|
|
TouchEvent readTouch() override;
|
|
HoldState updateHold(unsigned long holdMs) override;
|
|
void drawDebugTouch(int x, int y) override;
|
|
|
|
int width() override;
|
|
int height() override;
|
|
|
|
// Fonts
|
|
void setTitleFont() override;
|
|
void setBodyFont() override;
|
|
void setLabelFont() override;
|
|
void setDefaultFont() override;
|
|
|
|
// Transform touch coordinates (handles rotated touch panels)
|
|
void transformTouch(int* x, int* y) override;
|
|
|
|
// Dashboard tile mapping
|
|
int dashboardTouch(int x, int y);
|
|
|
|
// ── Internal ──
|
|
static DisplayDriverGFX& instance();
|
|
|
|
private:
|
|
// Test harness: parse serial commands to inject synthetic touches
|
|
bool parseTestTouch(int* outX, int* outY, bool* outPressed);
|
|
|
|
// Helper rendering functions
|
|
void drawBoot(const ScreenState& state);
|
|
void drawAlert(const ScreenState& state);
|
|
void drawDashboard(const ScreenState& state);
|
|
|
|
// Touch handling
|
|
TouchEvent _lastTouch = { false, false, 0, 0, -1, -1 };
|
|
unsigned long _pressStartMs = 0;
|
|
bool _isHolding = false;
|
|
unsigned long _lastReleaseMs = 0;
|
|
bool _touchBounced = false;
|
|
bool _testMode = false;
|
|
|
|
// Screen tracking
|
|
ScreenID _lastScreen = ScreenID::BOOT;
|
|
BootStage _lastBootStage = BootStage::SPLASH;
|
|
bool _needsRedraw = true;
|
|
};
|