60 lines
1.8 KiB
C++
60 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "board_config.h"
|
|
|
|
#include <KlubhausCore.h>
|
|
#include <TFT_eSPI.h>
|
|
|
|
class DisplayDriverTFT : public IDisplayDriver {
|
|
public:
|
|
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;
|
|
int width() override {
|
|
// Use TFT_eSPI's dimensions after rotation - it's more reliable
|
|
return _tft.width();
|
|
}
|
|
int height() override { return _tft.height(); }
|
|
|
|
// Dashboard - uses transform for touch coordinate correction
|
|
void transformTouch(int* x, int* y) override;
|
|
|
|
// Fonts
|
|
void setTitleFont() override;
|
|
void setBodyFont() override;
|
|
void setLabelFont() override;
|
|
void setDefaultFont() override;
|
|
|
|
private:
|
|
void drawBoot(const ScreenState& st);
|
|
void drawAlert(const ScreenState& st);
|
|
void drawDashboard(const ScreenState& st);
|
|
void drawStatus(const ScreenState& st);
|
|
|
|
TFT_eSPI _tft;
|
|
|
|
bool _holdActive = false;
|
|
uint32_t _holdStartMs = 0;
|
|
ScreenID _lastScreen = ScreenID::BOOT;
|
|
BootStage _lastBootStage = BootStage::SPLASH;
|
|
bool _needsRedraw = true;
|
|
|
|
// Touch hint for alert - progressive fill from bottom
|
|
bool _alertTouchDown = false;
|
|
bool _alertNeedsRedraw = false; // force redraw after touch release
|
|
uint32_t _alertTouchStartMs = 0;
|
|
bool _lastAlertPhase = false; // tracks bright/dark phase for 2-color alert
|
|
static constexpr uint32_t ALERT_FILL_DURATION_MS = 3000;
|
|
|
|
// Touch tracking for press/release detection
|
|
bool _touchWasPressed = false;
|
|
int _touchDownX = -1;
|
|
int _touchDownY = -1;
|
|
|
|
// Test mode for touch injection
|
|
bool _testMode = false;
|
|
bool parseTestTouch(int* outX, int* outY, bool* outPressed);
|
|
};
|