Pages

Monday, January 3, 2022

Extended button debounce library

I've previously introduced my debounce library here: http://davidegironi.blogspot.com/2018/10/switch-debounce-library.html

This post is about an expansion to that library.

In brief, this library try to solve the contact bounce issue (ref. https://en.wikipedia.org/wiki/Switch#Contact_bounce), implenting the Jack Ganssle's article "A Guide to Debouncing" idea. As my previous library, this too is based upon the Trent Cleghorn work, you can find here https://github.com/tcleg/Button_Debouncer

This version of the library implements the long press and other function too, let's list it all:

  • currentpressed: check if button is currently pressed
  • pressed: check if a buttons were immediately pressed
  • pressedchange: check if a button were pressed since the last request
  • released: check if a buttons were immediately released
  • releasedchange: check if a button were released since the last request
  • continuouspressed: checks if a button were continuous pressed
  • longpressedchange: check if a button were long pressed since the last request
  • longreleasedchange: check if a button were long released since the last request

Those functions covers most of the requirements you may have handling buttons.

The buttondebouncer.h file contains all the parameters such as the constant value that defines how many step the debouncer will take to get a long pressed button state.

The library has been developed on a ATmega running @ 1Mhz, but it can easly ported to other microcontroller.


Code

Notes
  • read risk disclaimer
  • excuse my bad english

No comments:

Post a Comment