Skip to content

SMFSW/SeqButton

Repository files navigation

SeqButton

author badge license CodeFactor

platform

doxy re_note

Sequential Button Arduino Library

Handling filtered button press with callbacks for push (with or without repeat) and release, logic, filtering time and sequences.

Usage

  • Declare a SeqButton instance (called sb below)
  • Create callback function(s) of type void func()
  • Initialize instance with sb.init(uint8_t pin, void (*cbckON)(SeqButton*), void (*cbckOFF)(SeqButton*), bool repeat, bool logic=LOW, uint16_t filter=50)
    • pin: pin on which button is connected
    • cbckON: callback function on press (NULL when no callback needed)
    • cbckOFF: callback function on release (NULL when no callback needed)
    • repeat: callback called repeatedly when set to true
    • logic: Button logic: LOW for NO / HIGH for NC (internal pullup for input is enabled)
    • filter: filtering time (in ms)
  • Call the handler in a loop using sb.handler() -> handler returns the current button value (if needed)
  • sb.getState() or sb.getButton() can be used to get current button state at any time
  • sb.getPin() can be used to check pin assigned to instance
  • sb.getHoldTime() can be used on a release callback to get hold duration of button

Examples included

About

Handling filtered button pushes with callbacks for Arduino

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages