Skip to content

St3p40/EMFButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EasyMultiFunctionalButton

License Tests Tests arduino-library-badge PlatformIO Registry

Button Press Handling Library

  • Works with normal open and closed buttons with pull-down and pull-up connection
  • Has own debounce that can be configured and deactivated
  • Pressing, multiclicking (up to 15 clicks), holding, releasing handling
  • Works with callbacks
  • Changing functions for reading button (for using faster analog, use it without Arduino library or using virtual button)

Comands

// button initialization
EMFButton btn (pin);
EMFButton btn (pin, pinmode);
EMFButton btn (pin, pinmode, normstate);
// reading button state
void tick();                             // obligatory function(reading button state)
// button pressing usage
bool isPressed();                        // returns true if button is pressed
bool isClicked();                        // returns true if button is clicked
bool isReleased();                       // returns true if button is released
bool isHeld();                           // is true with hold timer trigger
bool isHold();                           // returns true if button is still pressed after hold timer timeout
// basic multiclicking
bool hasSingle();                        // returns true if button was clicked once
bool hasDouble();                        // returns true if button was clicked twice
bool hasTriple();                        // returns true if button was clicked three times
// advanced multiclicking and holding
uint8_t hasClicks();                     // returns clicks after click strike is end
uint8_t hasClicksNow();                  // returns clicks during clicking
uint8_t hasClicksWithHeld();             // returns clicks during isHeld
uint8_t hasClicksWithHold();             // returns clicks with isHold
// advanced holding
uint16_t holdInMillis();                 // returns whole press time after releasing (ms)
uint16_t holdingTime();                  // returns press time (ms)
//callbacks
void attach(action, function);           // attaching function for this action
void detach(action);                     // detaching function for this action

Options with defines

//Use these defines BEFORE including the library

// use this if you don't use Arduino framework or if you use alternative of these functions
#define EMFB_SETUP_FUNC(pin, pinmode) pinMode(pin, (pinmode) ? INPUT : INPUT_PULLUP);
#define EMFB_READ_FUNC(pin, pinmode) digitalRead(pin) == (pinmode) ? HIGH : LOW
#define EMFB_MILLIS_FUNC millis()
// timers
#define EMFB_DEB_TIMER 50
#define EMFB_HOLD_TIMER 500
#define EMFB_RELEASE_TIMER 500
// aditional options
#define EMFB_USE_CALLBACKS
#define EMFB_WITHOUT_DEBOUNCE

This library is discontinued

It was decided to stop adding new features to this library, there will be only bugfixes

Anyways you can try https://github.com/St3p40/EmbButton as an alternative

About

Easy MultiFunctional Button Library

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages