From 8c7fc159d327fcf01cc61ebf134fa721411f4bb1 Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Sun, 30 Mar 2025 12:55:26 +0200 Subject: [PATCH] fix: add touch sensor connection check and update logic --- src/main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 1db296a..9c4b62f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,7 @@ bool mainTaskWasPaused = 0; uint8_t scaleTareCounter = 0; +bool touchSensorConnected = false; // ##### SETUP ##### void setup() { @@ -59,6 +60,16 @@ void setup() { // Touch Sensor pinMode(TTP223_PIN, INPUT_PULLUP); + if (digitalRead(TTP223_PIN) == HIGH) + { + Serial.println("Touch Sensor is not connected"); + touchSensorConnected = false; + } + else + { + Serial.println("Touch Sensor is connected"); + touchSensorConnected + } } @@ -100,7 +111,7 @@ void loop() { unsigned long currentMillis = millis(); // Überprüfe den Status des Touch Sensors - if (digitalRead(TTP223_PIN) == HIGH && currentMillis - lastButtonPress > debounceDelay) + if (touchSensorConnected && digitalRead(TTP223_PIN) == HIGH && currentMillis - lastButtonPress > debounceDelay) { lastButtonPress = currentMillis; scaleTareRequest = true;