feat(display): draw hint animation at touch position instead of center
This commit is contained in:
@@ -5,19 +5,33 @@
|
||||
/// Board sketch creates the concrete driver and passes it in.
|
||||
class DisplayManager {
|
||||
public:
|
||||
DisplayManager() : _drv(nullptr) {}
|
||||
explicit DisplayManager(IDisplayDriver* drv) : _drv(drv) {}
|
||||
DisplayManager()
|
||||
: _drv(nullptr) { }
|
||||
explicit DisplayManager(IDisplayDriver* drv)
|
||||
: _drv(drv) { }
|
||||
void setDriver(IDisplayDriver* drv) { _drv = drv; }
|
||||
|
||||
void begin() { if (_drv) _drv->begin(); }
|
||||
void setBacklight(bool on) { if (_drv) _drv->setBacklight(on); }
|
||||
void render(const ScreenState& st) { if (_drv) _drv->render(st); }
|
||||
TouchEvent readTouch() { return _drv ? _drv->readTouch() : TouchEvent{}; }
|
||||
int dashboardTouch(int x, int y) { return _drv ? _drv->dashboardTouch(x, y) : -1; }
|
||||
HoldState updateHold(unsigned long ms) { return _drv ? _drv->updateHold(ms) : HoldState{}; }
|
||||
void updateHint() { if (_drv) _drv->updateHint(); }
|
||||
int width() { return _drv ? _drv->width() : 0; }
|
||||
int height() { return _drv ? _drv->height() : 0; }
|
||||
void begin() {
|
||||
if(_drv)
|
||||
_drv->begin();
|
||||
}
|
||||
void setBacklight(bool on) {
|
||||
if(_drv)
|
||||
_drv->setBacklight(on);
|
||||
}
|
||||
void render(const ScreenState& st) {
|
||||
if(_drv)
|
||||
_drv->render(st);
|
||||
}
|
||||
TouchEvent readTouch() { return _drv ? _drv->readTouch() : TouchEvent {}; }
|
||||
int dashboardTouch(int x, int y) { return _drv ? _drv->dashboardTouch(x, y) : -1; }
|
||||
HoldState updateHold(unsigned long ms) { return _drv ? _drv->updateHold(ms) : HoldState {}; }
|
||||
void updateHint(int x, int y) {
|
||||
if(_drv)
|
||||
_drv->updateHint(x, y);
|
||||
}
|
||||
int width() { return _drv ? _drv->width() : 0; }
|
||||
int height() { return _drv ? _drv->height() : 0; }
|
||||
|
||||
private:
|
||||
IDisplayDriver* _drv;
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
|
||||
/// Externally trigger silence (e.g. hold-to-silence gesture).
|
||||
void silenceAlert();
|
||||
void setScreen(ScreenID s);
|
||||
|
||||
private:
|
||||
void pollTopics();
|
||||
@@ -34,7 +35,6 @@ private:
|
||||
void flushStatus(const String& message);
|
||||
void heartbeat();
|
||||
void transition(DeviceState s);
|
||||
void setScreen(ScreenID s);
|
||||
String topicUrl(const char* base);
|
||||
|
||||
DisplayManager* _display;
|
||||
|
||||
@@ -9,6 +9,7 @@ struct TouchEvent {
|
||||
|
||||
struct HoldState {
|
||||
bool active = false;
|
||||
bool started = false;
|
||||
bool completed = false;
|
||||
float progress = 0.0f; // 0.0 – 1.0
|
||||
};
|
||||
@@ -31,7 +32,7 @@ public:
|
||||
/// Track a long-press gesture; returns progress/completion.
|
||||
virtual HoldState updateHold(unsigned long holdMs) = 0;
|
||||
/// Idle hint animation (e.g. pulsing ring) while alert is showing.
|
||||
virtual void updateHint() = 0;
|
||||
virtual void updateHint(int x, int y) = 0;
|
||||
|
||||
virtual int width() = 0;
|
||||
virtual int height() = 0;
|
||||
|
||||
Reference in New Issue
Block a user