stackchan: NFC reader polled from the head touch interval, its RF field caused phantom touches

This commit is contained in:
randy committed 2026-11-29 12:24:04 +01:00
1 parent 44b0601bf2
commit 6be43cb95e
1 file changed
+18 -4
+18 -4
View File
@@ -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();