Let a tap survive a centimetre of finger drift and log every refused tap (0.2.28)

The touch guard dropped a tap as soon as the finger drifted more than
18 px (under 3 mm) from its very first contact point, on both boards and
regardless of the page-swipe setting; LVGL itself never cancelled these
clicks (no scrollable ancestors, gestures do not suppress clicks). A finger
that flattens or rolls while pressing was enough, and the tap vanished
without a trace in the log.

The limit is now about one centimetre per board (TOUCH_MOVE_LIMIT_PX:
Guition 67 px, CYD 56 px), measured from a reference that settles over the
first four samples; only the contact that started the touch is followed,
so a second finger no longer counts as movement; the minimum contact time
is per board too (TOUCH_MIN_PRESS_MS: 60 ms resistive, 20 ms capacitive).
Every refused tap is logged on INFO with its reason (moved, too short,
already used, bounce). Firmware 0.2.23 for CYD and Guition.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Max Gramser
2026-09-14 11:30:23 +02:00
parent 2327d31261
commit ea0b423fab
13 changed files with 236 additions and 40 deletions
+41 -1
View File
@@ -37,7 +37,8 @@ int main() {
moving.update(52, 48);
assert(moving.accept(180, 1)); // small resistive jitter remains usable
moving.begin(1000, 50, 50);
moving.update(50, 80);
moving.update(51, 50); moving.update(50, 51); moving.update(50, 50); // reference settled
moving.update(50, 80); // 30 px beyond the default 18 px
moving.update(50, 50);
assert(!moving.accept(1200, 2)); // excursion stays cancelled, even on return
assert(moving.accept_slider(1200, 202)); // captured drag is a valid slider gesture
@@ -46,6 +47,45 @@ int main() {
moving.begin(1250);
assert(!moving.accept_slider(1260, 202)); // noise remains rejected
assert(!moving.accept_slider(1350, 202)); // same-control bounce remains rejected
// Per-board limits (0.2.23): a centimetre of drift on the Guition is still a tap, and the
// reference settles over the first samples, so the landing wobble does not count.
cyd::TouchGuard wide;
wide.configure(67, 20);
assert(wide.move_limit() == 67 && wide.min_press() == 20);
wide.begin(100, 200, 200, 3);
wide.update(206, 203, 3); wide.update(210, 205, 3); wide.update(212, 206, 3); // finger flattens
wide.update(262, 206, 3); // 55 px from the settled point
assert(wide.distance() > 45 && wide.distance() <= 67);
assert(wide.accept(180, 1)); // under one centimetre: still a tap
wide.begin(1000, 200, 200, 3);
wide.update(275, 200, 3); wide.update(300, 200, 3); wide.update(340, 200, 3); // a real swipe: the reference
wide.update(380, 200, 3); // settles, the finger keeps going
assert(!wide.accept(1100, 1));
assert(wide.reason().rfind("verplaatst", 0) == 0);
wide.begin(2000, 200, 200, 3);
wide.update(400, 400, 5); // a second finger elsewhere
assert(wide.accept(2050, 1)); // ignored: only contact 3 is followed; 50 ms is long enough here
wide.begin(3000, 200, 200, 3);
assert(!wide.accept(3010, 2)); // 10 ms is below the capacitive minimum
assert(wide.reason().rfind("te kort", 0) == 0);
wide.begin(3100, 200, 200, 3);
assert(wide.accept(3160, 2));
assert(wide.reason().empty());
assert(!wide.accept(3170, 2));
assert(wide.reason() == "al verwerkt in dit contact");
wide.begin(3200, 200, 200, 3);
assert(!wide.accept(3260, 2)); // same tile within 600 ms
assert(wide.reason() == "dezelfde knop binnen de dendertijd");
cyd::TouchGuard resistive;
resistive.configure(56, 60);
resistive.begin(100, 50, 50);
resistive.update(80, 50); resistive.update(50, 50); // the CYD's jump of 30 px is fine now
assert(resistive.accept(180, 1));
resistive.begin(1000, 50, 50);
resistive.update(50, 120); resistive.update(50, 130); resistive.update(50, 140);
resistive.update(50, 180); // 70 px past the settled point: a swipe
assert(!resistive.accept(1100, 1));
assert(!resistive.accept_repeat(1100, 1));
cyd::TouchGuard rollover;
rollover.begin(std::numeric_limits<uint32_t>::max() - 30);
assert(rollover.accept(50, 1)); // millis wraps after 49 days