mathertel / OneButton

An Arduino library for using a single button for multiple purpose input.
http://www.mathertel.de/Arduino/OneButtonLibrary.aspx
Other
920 stars 230 forks source link

Way of using one handler for many OneButtons? #102

Closed matkor closed 2 years ago

matkor commented 2 years ago

Is it possible to use one (click/ press/ etc) handler for many OneButton instances and have pin id or OneButton reference passed to handler function?

mathertel commented 2 years ago

you can attach one handler to multiple events and instances. The attachXXX methods support an additional parameter that can be passed to your handler to distinguish the use cases. This can be anythin (void ) including a integer (casted to void ) or a pointer to some data. - as you like.