fix: add touch sensor connection check and update logic

This commit is contained in:
Manuel Weiser 2025-03-30 12:55:26 +02:00
parent 476d3e82e2
commit 8c7fc159d3

View File

@ -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;