From ba2f25293b8280c85cfe8f9fb8c2833d9ebee8e3 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Sat, 2 Nov 2024 23:36:40 +1300 Subject: [PATCH] Fix flipped logic after move to Throttle::isWithinTimespanMs (#5221) --- src/input/ScanAndSelect.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/input/ScanAndSelect.cpp b/src/input/ScanAndSelect.cpp index e1b39edf5..d8767fab8 100644 --- a/src/input/ScanAndSelect.cpp +++ b/src/input/ScanAndSelect.cpp @@ -59,7 +59,7 @@ int32_t ScanAndSelectInput::runOnce() // If: "no messages added" alert screen currently shown if (alertingNoMessage) { // Dismiss the alert screen several seconds after it appears - if (now > alertingSinceMs + durationAlertMs) { + if (!Throttle::isWithinTimespanMs(alertingSinceMs, durationAlertMs)) { alertingNoMessage = false; screen->endAlert(); } @@ -74,9 +74,9 @@ int32_t ScanAndSelectInput::runOnce() // Existing press else { - // Duration enough for long press + // Longer than shortpress window // Long press not yet fired (prevent repeat firing while held) - if (!longPressFired && Throttle::isWithinTimespanMs(downSinceMs, durationLongMs)) { + if (!longPressFired && !Throttle::isWithinTimespanMs(downSinceMs, durationLongMs)) { longPressFired = true; longPress(); } @@ -91,7 +91,9 @@ int32_t ScanAndSelectInput::runOnce() // Button newly released // Long press event didn't already fire if (held && !longPressFired) { - // Duration enough for short press + // Duration within shortpress window + // - longer than durationShortPress (debounce) + // - shorter than durationLongPress if (!Throttle::isWithinTimespanMs(downSinceMs, durationShortMs)) { shortPress(); }