From 713621a157326f81b1629d2d0bded35d3bf28ad4 Mon Sep 17 00:00:00 2001 From: Kai R Date: Wed, 6 Dec 2023 19:03:40 +0100 Subject: [PATCH] Repeated debounce removed --- library.json | 2 +- library.properties | 2 +- src/Button_SL.cpp | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/library.json b/library.json index ea68d09..a174bdd 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Button_SL", - "version": "1.1.3", + "version": "1.1.4", "keywords": "button, debounce, signal, input, ouput", "description": "Button_SL enables the query of buttons. The query is debounced. A query can be made as to whether the button was pressed for a short or long time.", "repository": { diff --git a/library.properties b/library.properties index 4ce13cc..bcca4ac 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Button_SL -version=1.1.3 +version=1.1.4 author=Kai R. maintainer=Kai R. sentence=Button query diff --git a/src/Button_SL.cpp b/src/Button_SL.cpp index 239c60b..63129c2 100644 --- a/src/Button_SL.cpp +++ b/src/Button_SL.cpp @@ -21,6 +21,9 @@ /// @version 1.1.0 The ButtonSL class can now provide a status after the specified time period /// for a long button press, even if the button remains permanently pressed. /// +/// @date 2023-12-06 +/// @version 1.1.4 Repeated debounce in the button class removed. +/// /// @copyright Copyright (c) 2022 /// MIT license, check license.md for more information /// All text above must be included in any redistribution @@ -54,12 +57,12 @@ bool Button::tick() { [[fallthrough]]; case HIGH: if (millis() - timeStamp > dbTime_ms) { - compareState = LOW; // If the button press is equal to the specified debounce time, - flag = true; // confirm the button press with true. + // If the button press is equal to the specified debounce time, confirm the button press with true. + flag = true; } break; } - } else if (compareState) { + } else if (compareState == true) { compareState = LOW; // set to LOW if button is no longer pressed } return flag;