From 3b17f1fe5032fa4394e0c1179f7050c317718a8a Mon Sep 17 00:00:00 2001 From: eddy Date: Tue, 4 Aug 2026 01:20:47 +0200 Subject: [PATCH] touch: INPUT_PULLUP, !t1Active logica (sensor actief LOW) --- AGENTS.md | 2 +- src/client.cpp | 2 +- src/main.cpp | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index f488092..eacdaf0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -6,7 +6,7 @@ M5Stack Atom S3 Lite (ESP32-S3), 2 relais, 2 touch sensors (HS-S43A), BLE, Andro - **Board:** M5Stack Atom S3 Lite (ESP32-S3) - **Pinnen:** G1=RELAY1, G2=RELAY2, G8=TOUCH1, G6=TOUCH2, G41=BUTTON (active low), G46=LED -- **Touch:** HS-S43A Digital Capacitive Switch Module (epenelab.io), actief HIGH, geen pullup nodig. +- **Touch:** HS-S43A Digital Capacitive Switch Module (openelab.io), actief HIGH. Pin mode: `INPUT_PULLUP` (pullup voor veiligheid zonder sensor; sensor overrulet de pullup bij aanraking). - **BLE:** "SylDa_Server", service `4fafc201-1fb5-459e-8fcc-c5c9c331914b` - **BLE cmds:** 0x00=relay1 OFF, 0x01=ON, 0x02=relay2 ON, 0x03=OFF, HMAC_PKT_SIZE=37 (1 cmd + 4 seq + 32 hmac) - **NVS:** namespace `hmac`, key `key` — HMAC key 32 bytes, NVS op 0x9000-0xDFFF (partitie tabel) diff --git a/src/client.cpp b/src/client.cpp index 99a4d99..4965916 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -632,7 +632,7 @@ void loop() { static uint32_t heartbeat = 0; if (millis() - heartbeat > 60000) { - ESP_LOGD(TAG, "[heartbeat] t1=%s t2=%s btn=%s r1=%s r2=%s connected=%s ecdh=%s", + ESP_LOGD(TAG, "[hb] t1=%s t2=%s btn=%s r1=%s r2=%s conn=%s ecdh=%s", !t1Active ? "YES" : "no", !t2Active ? "YES" : "no", btnActive ? "YES" : "no", diff --git a/src/main.cpp b/src/main.cpp index 17f7848..f22cbdf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -489,8 +489,8 @@ void setup() { memset(clients[i].aesKey, 0, AES_KEY_LEN); } - pinMode(TOUCH1_PIN, INPUT); - pinMode(TOUCH2_PIN, INPUT); + pinMode(TOUCH1_PIN, INPUT_PULLUP); + pinMode(TOUCH2_PIN, INPUT_PULLUP); pinMode(BUTTON_PIN, INPUT); pinMode(RELAY1_PIN, OUTPUT); pinMode(RELAY2_PIN, OUTPUT); @@ -753,8 +753,8 @@ void loop() { ESP_LOGI(TAG, "Relays: R1=%s R2=%s (t1=%s t2=%s btn=%s ble1=%s ble2=%s)", relay1State ? "ON" : "OFF", relay2State ? "ON" : "OFF", - t1Active ? "YES" : "no", - t2Active ? "YES" : "no", + !t1Active ? "YES" : "no", + !t2Active ? "YES" : "no", btnActive ? "YES" : "no", anyBle1 ? "ON" : "OFF", anyBle2 ? "ON" : "OFF"); @@ -769,8 +769,8 @@ void loop() { ESP_LOGD(TAG, "[heartbeat] R1=%s R2=%s t1=%s t2=%s btn=%s ble1=%s ble2=%s clients=%d", relay1State ? "ON" : "OFF", relay2State ? "ON" : "OFF", - t1Active ? "YES" : "no", - t2Active ? "YES" : "no", + !t1Active ? "YES" : "no", + !t2Active ? "YES" : "no", btnActive ? "YES" : "no", anyBle1 ? "ON" : "OFF", anyBle2 ? "ON" : "OFF",