OneButton icon indicating copy to clipboard operation
OneButton copied to clipboard

Feature request to supplement the callback model with an explicit call model.

Open 6v6gt-duino opened this issue 2 years ago • 0 comments

Feature request to supplement the callback model with an explicit call model. The callback model as implemented in this library is useful in that it allows the user specifies a custom function to be called on an button event. However, a direct call model such as: if ( button1.wasPressed() ) { /* do something*/} would also be useful. Of course, the user could implement such features in his/her own code using the existing library mechanism by specifying a call back function which sets a global variable, say bool button1_pressed, and a matching function, say button1_wasPressed() which returns the value of button1_pressed and also resets it. But this is clumsy, does not scale up well and it would be better (and easy to do) if this were implemented in the library itself. Minor additional feature request. Replace int with int16_t (or something smaller if possible), to minimise storage use especially on platforms where int is actually 4 bytes. BTW the state machine used in this library is very nicely presented here: https://www.mathertel.de/Arduino/OneButtonLibrary.aspx

6v6gt-duino avatar Jul 25 '22 08:07 6v6gt-duino