From 147e8edeee1a2f7465be9cf59c36688a501320c9 Mon Sep 17 00:00:00 2001 From: sanni Date: Tue, 26 Oct 2021 21:57:21 +0200 Subject: [PATCH] Add 10 second button press for rotary encoder --- Cart_Reader/Cart_Reader.ino | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Cart_Reader/Cart_Reader.ino b/Cart_Reader/Cart_Reader.ino index d96d974..2912f93 100644 --- a/Cart_Reader/Cart_Reader.ino +++ b/Cart_Reader/Cart_Reader.ino @@ -1092,13 +1092,25 @@ int checkButton() { if (reading != lastButtonState) { lastDebounceTime = millis(); } + // Debounce button if ((millis() - lastDebounceTime) > debounceDelay) { if (reading != buttonState) { buttonState = reading; + // Button was pressed down if (buttonState == 0) { + unsigned long pushTime = millis(); + // Wait until button was let go again while ((PING & (1 << PING2)) >> PING2 == 0); lastButtonState = reading; - return 3; + + // If the hold time was over 10 seconds, super long press for resetting eeprom in about screen + if (millis() - pushTime > 10000) { + return 4; + } + // long press + else { + return 3; + } } } else {