feat(display): draw hint animation at touch position instead of center

This commit is contained in:
2026-02-17 03:49:34 -08:00
parent 23712a152b
commit 0ace263324
9 changed files with 78 additions and 31 deletions

View File

@@ -108,6 +108,7 @@ HoldState DisplayDriverGFX::updateHold(unsigned long holdMs) {
if(!_isHolding) {
_isHolding = true;
state.started = true;
}
state.active = true;
@@ -234,7 +235,7 @@ void DisplayDriverGFX::drawDashboard(const ScreenState& state) {
}
}
void DisplayDriverGFX::updateHint() {
void DisplayDriverGFX::updateHint(int x, int y) {
if(!_gfx)
return;
@@ -249,5 +250,6 @@ void DisplayDriverGFX::updateHint() {
uint8_t v = static_cast<uint8_t>(30.0f + 30.0f * sinf(t * 2 * 3.14159f));
uint16_t col = ((v >> 3) << 11) | ((v >> 2) << 5) | (v >> 3);
_gfx->drawCircle(DISP_W / 2, DISP_H / 2, 50, col);
// Draw at touch position instead of center
_gfx->drawCircle(x, y, 50, col);
}

View File

@@ -13,7 +13,7 @@ public:
TouchEvent readTouch() override;
int dashboardTouch(int x, int y) override;
HoldState updateHold(unsigned long holdMs) override;
void updateHint() override;
void updateHint(int x, int y) override;
int width() override;
int height() override;

View File

@@ -28,15 +28,32 @@ void loop() {
const ScreenState& st = logic.getScreenState();
// Track initial hold position for hint
static int holdStartX = -1;
static int holdStartY = -1;
if(st.deviceState == DeviceState::ALERTING) {
HoldState h = display.updateHold(HOLD_TO_SILENCE_MS);
if(h.completed) {
logic.silenceAlert();
holdStartX = -1;
holdStartY = -1;
}
if(!h.active) {
display.updateHint();
if(h.started) {
// Capture initial touch position
holdStartX = evt.x;
holdStartY = evt.y;
}
} else if(evt.pressed) {
if(!h.active && holdStartX >= 0) {
display.updateHint(holdStartX, holdStartY);
}
} else {
// Reset when not alerting
holdStartX = -1;
holdStartY = -1;
}
if(evt.pressed) {
if(st.screen == ScreenID::OFF) {
// Tap in OFF mode → wake to DASHBOARD
Serial.println("[TOUCH] OFF → DASHBOARD");
@@ -46,15 +63,12 @@ void loop() {
int tile = display.dashboardTouch(evt.x, evt.y);
if(tile >= 0) {
Serial.printf("[DASH] Tile %d tapped\n", tile);
// TODO: Handle tile actions
}
} else if(st.screen == ScreenID::ALERT) {
// Tap in ALERT mode → could dismiss or show more info
Serial.println("[TOUCH] ALERT tap");
// For now, let's make tap do nothing (hold to silence only)
// Or: logic.dismissAlert();
}
}
if(Serial.available()) {
String cmd = Serial.readStringUntil('\n');
cmd.trim();