fix: add debounce handling for TTP223 touch sensor

This commit is contained in:
Manuel Weiser 2025-03-29 14:23:55 +01:00
parent 2bf7c9fb7d
commit 83d14b32d1

View File

@ -87,17 +87,23 @@ uint8_t autoAmsCounter = 0;
uint8_t weightSend = 0;
int16_t lastWeight = 0;
// WIFI check variables
unsigned long lastWifiCheckTime = 0;
const unsigned long wifiCheckInterval = 60000; // Überprüfe alle 60 Sekunden (60000 ms)
// Button debounce variables
unsigned long lastButtonPress = 0;
const unsigned long debounceDelay = 500; // 500 ms debounce delay
// ##### PROGRAM START #####
void loop() {
unsigned long currentMillis = millis();
// Überprüfe den Status des Touch Sensors
if (digitalRead(TTP223_PIN) == LOW)
if (digitalRead(TTP223_PIN) == LOW && currentMillis - lastButtonPress > debounceDelay)
{
tareScale();
lastButtonPress = currentMillis;
scaleTareRequest = true;
}
// Überprüfe regelmäßig die WLAN-Verbindung