From 6be43cb95ebe682dba2c910f748d319c6cbd97ac Mon Sep 17 00:00:00 2001 From: Roman Priesol Date: Sun, 29 Nov 2026 12:24:04 +0100 Subject: [PATCH] stackchan: NFC reader polled from the head touch interval, its RF field caused phantom touches --- mcu-stackchan.yaml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/mcu-stackchan.yaml b/mcu-stackchan.yaml index 85b4423..269c3c3 100644 --- a/mcu-stackchan.yaml +++ b/mcu-stackchan.yaml @@ -501,21 +501,35 @@ interval: then: - component.update: display_tft # head touch gestures: a touch episode ends after 250 ms without contact; - # tap = short episode, stroke = longer episode that reaches the pads one after another + # tap = short episode, stroke = longer episode that reaches the pads one after another. + # Each ST25R scan switches its RF field on and the pads report a 50-350 ms phantom touch, at any + # si12t sensitivity, so the NFC reader is scanned from here: every 2 s between episodes, with the + # pads ignored for 400 ms afterwards, and at once when an episode starts (a card being laid on). - interval: 50ms then: - lambda: |- static bool active = false; - static uint32_t start = 0, last_on = 0; + static uint32_t start = 0, last_on = 0, last_scan = 0; static uint32_t first_on[3]; + const uint32_t now = millis(); + if (!active) { + if (now - last_scan >= 2000) { + last_scan = now; + id(nfc_reader).update(); + return; + } + if (now - last_scan < 400) + return; + } const bool on[3] = {id(head_touch_1).state != "No touch", id(head_touch_2).state != "No touch", id(head_touch_3).state != "No touch"}; - const uint32_t now = millis(); if (on[0] || on[1] || on[2]) { if (!active) { active = true; start = now; + last_scan = now; + id(nfc_reader).update(); first_on[0] = first_on[1] = first_on[2] = 0; } for (int i = 0; i < 3; i++) @@ -898,7 +912,7 @@ event: st25r_i2c: id: nfc_reader i2c_id: i2c_bsp - update_interval: 200ms + update_interval: never # polled from the head touch interval, see there on_tag: - lambda: |- id(nfc_changed_ms) = millis();