mathertel / RotaryEncoder

RotaryEncoder Arduino Library
Other
342 stars 107 forks source link

Added push button debounce functionality #16

Closed FelixHauser closed 4 years ago

FelixHauser commented 4 years ago

I added a debounce functionality for the Rotary Encoder's push button so that no other library is needed. The debounce code is adapted from Thomas Frederick's Bounce library (see readme.md). I overloaded the original constructor to accommodate for pin number of the push button as well as the time (in ms) for the debouncing. The original constructor works as per usual, so users updating the library won't have to modify their codes. An example of the use is also added.

Regards, FH

mathertel commented 4 years ago

Hi Felix, I think this is not the way to extend a single-purpose library but you should combine the libraries you need. In my appliances I have often multiple buttons but only one rotary encoder. I suggest you use the OneButton library for all button inputs and the RotaryEncoder library for the turning events. (By combining both libraries the code size will increase in scenarios with multiple buttons)

FelixHauser commented 4 years ago

hi there. Still it can be useful for small project which only need a encoder a single input. For larger projects, I certainly agree. But for small ones I find it practical. Also for larger ones you don't even have to use the debounce functionality or even declare it.

mathertel commented 4 years ago

closed after discussion and clarification. It is not intended to combine multiple features into one library when it can be kept separate. See https://github.com/mathertel/OneButton for a library for the button functionality of a rotary encoder that offers a "push" button.