mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 09:06:52 +01:00
stackchan: NFC reader polled from the head touch interval, its RF field caused phantom touches
This commit is contained in:
1 parent
44b0601bf2
commit
6be43cb95e
1 file changed
+18
-4
+18
-4
@@ -501,21 +501,35 @@ interval:
|
|||||||
then:
|
then:
|
||||||
- component.update: display_tft
|
- component.update: display_tft
|
||||||
# head touch gestures: a touch episode ends after 250 ms without contact;
|
# 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
|
- interval: 50ms
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
static bool active = false;
|
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];
|
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",
|
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"};
|
id(head_touch_3).state != "No touch"};
|
||||||
const uint32_t now = millis();
|
|
||||||
|
|
||||||
if (on[0] || on[1] || on[2]) {
|
if (on[0] || on[1] || on[2]) {
|
||||||
if (!active) {
|
if (!active) {
|
||||||
active = true;
|
active = true;
|
||||||
start = now;
|
start = now;
|
||||||
|
last_scan = now;
|
||||||
|
id(nfc_reader).update();
|
||||||
first_on[0] = first_on[1] = first_on[2] = 0;
|
first_on[0] = first_on[1] = first_on[2] = 0;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
@@ -898,7 +912,7 @@ event:
|
|||||||
st25r_i2c:
|
st25r_i2c:
|
||||||
id: nfc_reader
|
id: nfc_reader
|
||||||
i2c_id: i2c_bsp
|
i2c_id: i2c_bsp
|
||||||
update_interval: 200ms
|
update_interval: never # polled from the head touch interval, see there
|
||||||
on_tag:
|
on_tag:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(nfc_changed_ms) = millis();
|
id(nfc_changed_ms) = millis();
|
||||||
|
|||||||
Reference in new issue
Block a user