Close cards through one path so the page swipe is never left blocked (0.2.32)

Read live on a Guition: every edge swipe was recognised but refused by the
"card open" check, because the light, climate and vacuum cards cleared
their overlay on close (X, tap beside the card, wake from standby) without
forgetting active_entity. One opened card blocked swiping until the next
layout change; the old whole-screen gesture and the CYD had the same gate.
Both boards now close cards through one script, close_cards, which hides
every overlay and clears that state; wake_display uses it too.

The Guition edge swipe now follows LVGL's own pointer events
(lv_indev_add_event_cb: PRESSED begins, PRESSING flips the page and calls
lv_indev_wait_release from inside LVGL) instead of ESPHome's touchscreen
on_update, so the point arrives already rotated. The direction rule is 45
degrees instead of twice as horizontal, and the log now says why a swipe
was refused or how far an unfinished one got. Firmware 0.2.27 for both
boards; the app only moves its target version.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Max Gramser
2026-09-14 13:09:53 +02:00
parent 95cdfa30cf
commit b9e1dfbd95
11 changed files with 248 additions and 109 deletions
+16 -16
View File
@@ -86,32 +86,32 @@ int main() {
resistive.update(50, 180); // 70 px past the settled point: a swipe
assert(!resistive.accept(1100, 1));
assert(!resistive.accept_repeat(1100, 1));
// Edge swipe (0.2.24): only a touch that starts in the side band flips a page, from the
// right edge leftwards "next", from the left edge rightwards "previous", once per touch,
// slow or fast, and never diagonally or from the middle. Rotation follows ESPHome's mapping.
// Edge swipe (0.2.24, LVGL pointer coordinates since 0.2.27): only a touch that starts in
// the side band flips a page, from the right edge leftwards "next", from the left edge
// rightwards "previous", once per touch, slow or fast, more sideways than vertical, never
// from the middle. The width follows the rotated screen.
cyd::EdgeSwipe edge;
edge.configure(480, 480, 32, 40);
edge.begin(6, 240);
edge.configure(32, 40);
edge.begin(6, 240, 480);
assert(edge.armed());
assert(edge.update(30, 242) == 0); // not far enough yet
assert(edge.update(48, 245) == -1); // 42 px inward from the left edge: previous page
assert(edge.update(90, 245) == 0); // once per touch
assert(!edge.armed());
edge.begin(474, 100);
edge.begin(474, 100, 480);
assert(edge.update(430, 104) == 1); // from the right edge: next page
edge.begin(240, 240);
edge.begin(240, 240, 480);
assert(!edge.armed());
assert(edge.update(300, 240) == 0); // started in the middle: never a page swipe
edge.begin(6, 240);
assert(edge.update(50, 300) == 0); // diagonal: 44 px sideways against 60 down
edge.begin(6, 240, 480);
assert(edge.update(50, 300) == 0); // steeper than 45 degrees: 44 px sideways against 60 down
assert(edge.update(-10, 240) == 0); // moving outward: nothing
assert(edge.update(60, 244) == -1); // straightened out later: still counts
edge.begin(240, 6, 90);
assert(edge.update(240, 60) == -1); // rotated 90: the user's left edge is the panel's top
edge.begin(240, 6, 270);
assert(edge.update(240, 60) == 1); // rotated 270: that same edge is the user's right
edge.begin(6, 240, 180);
assert(edge.update(60, 240) == 1); // upside down: the panel's left is the user's right
assert(edge.update(60, 270) == -1); // 54 sideways against 30 down: a slanted thumb swipe counts
edge.begin(6, 240, 480);
edge.update(20, 250);
assert(edge.inward() == 14 && edge.sideways() == 10); // what the log reports for a swipe that ended early
edge.begin(300, 240, 320);
assert(edge.update(250, 240) == 1); // a 320 px wide (rotated or smaller) screen: right band from 288
cyd::TouchGuard rollover;
rollover.begin(std::numeric_limits<uint32_t>::max() - 30);
assert(rollover.accept(50, 1)); // millis wraps after 49 days