Skip to content

Add debounce support to MomentaryButton class#1607

Open
RichardPar wants to merge 1 commit intomeshcore-dev:mainfrom
RichardPar:Buttons_Debouncer
Open

Add debounce support to MomentaryButton class#1607
RichardPar wants to merge 1 commit intomeshcore-dev:mainfrom
RichardPar:Buttons_Debouncer

Conversation

@RichardPar
Copy link

Problem - One button press on an external tact-switch resulted in a very erratic menu navigation. Using a Heltec Wireless paper, but should be applicable for all momentary button presses.

  • Updated constructors to include debounce_ms parameter with default value.
  • Implemented debounce logic in the check method to improve button press reliability.
  • Added setDebounceMs and getDebounceMs methods for debounce configuration.

LOG -
One Button press resulted in

BLE: writeBytes: sz=148, hdr=3
[MomentaryButton] Button pressed down
BLE: writeBytes: sz=148, hdr=3
[MomentaryButton] Button released
[MomentaryButton] Button pressed down
[MomentaryButton] Button released
[MomentaryButton] Button pressed down
[MomentaryButton] Button released
[MomentaryButton] Button pressed down
[MomentaryButton] Button released
[MomentaryButton] Button pressed down
BLE: writeBytes: sz=148, hdr=3
BLE: writeBytes: sz=148, hdr=3
[MomentaryButton] Button released
[MomentaryButton] Button pressed down
[MomentaryButton] Button released
[MomentaryButton] Button pressed down
[MomentaryButton] Button released
[MomentaryButton] Button pressed down
[MomentaryButton] Button released
BLE: writeBytes: sz=148, hdr=3
BLE: writeBytes: sz=148, hdr=3
BLE: writeBytes: sz=148, hdr=3
BLE: writeBytes: sz=148, hdr=3
BLE: writeBytes: sz=148, hdr=3
[MomentaryButton] Event: MULTI_CLICK (8 clicks)
BLE: writeBytes: sz=148, hdr=3  

- Updated constructors to include debounce_ms parameter with default value.
- Implemented debounce logic in the check method to improve button press reliability.
- Added setDebounceMs and getDebounceMs methods for debounce configuration.
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