Skip to content

fix: re-introduce debounce logic in MomentaryButton for NewUI#2559

Open
The-Bober wants to merge 1 commit into
meshcore-dev:devfrom
The-Bober:fix/momentarybutton-debounce-newui
Open

fix: re-introduce debounce logic in MomentaryButton for NewUI#2559
The-Bober wants to merge 1 commit into
meshcore-dev:devfrom
The-Bober:fix/momentarybutton-debounce-newui

Conversation

@The-Bober
Copy link
Copy Markdown

Problem

The de-bounce logic present in the original UI was not carried over
during the NewUI / MomentaryButton refactor. Without it, a single
physical button press can generate multiple edges within a few
milliseconds, causing spurious clicks and unreliable multi-click
detection.

Fix

  • Added DEBOUNCE_MS (50ms) constant to MomentaryButton.cpp
  • Added _last_edge_ms member to track the last valid edge timestamp
  • Inside check(), any btn != prev transition that occurs within
    50ms of the previous valid edge is silently ignored via a goto
  • All existing logic (long press, multi-click window, repeat click)
    is unchanged

Behaviour

  • Debounce fires first, before the 280ms multi-click window
  • Only clean, intentional edges reach the click-counting logic
  • Matches the intent of the original OrigUI implementation

Fixes #2539

De-bounce guard was present in OrigUI but lost during the NewUI /
MomentaryButton refactor. Adds a 50ms edge filter (_last_edge_ms)
inside check() to suppress electrical noise before the multi-click
window logic runs. Fixes meshcore-dev#2539.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant