From 9451f987b5e171142804b7161a49eaa3c01cf3b0 Mon Sep 17 00:00:00 2001 From: Adam Wonak Date: Fri, 23 May 2025 17:21:40 -0700 Subject: [PATCH] fix long press handler --- button.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/button.h b/button.h index 3546c50..16bd9a9 100644 --- a/button.h +++ b/button.h @@ -72,9 +72,6 @@ class Button { bool pressed = read == 0 && old_read_ == 1 && debounced; bool released = read == 1 && old_read_ == 0 && debounced; - // Update variables for next loop - last_press_ = (pressed || released) ? millis() : last_press_; - // Determine current clock input state. change_ = CHANGE_UNCHANGED; if (pressed) { @@ -89,6 +86,9 @@ class Button { if (on_long_press_ != NULL) on_long_press_(); } } + + // Update variables for next loop + last_press_ = (pressed || released) ? millis() : last_press_; old_read_ = read; }