Files
klubhaus-doorbell/boards/esp32-s3-lcd-43/DisplayDriverGFX.h

64 lines
1.8 KiB
C++

#pragma once
#include "IDisplayDriver.h"
#include "Style.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(const TouchEvent& evt, 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);
void drawStatus(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;
// Text scrollers for scrolling elements
TextScroller _headerScroller;
TextScroller _wifiScroller;
};