neu-rah / ArduinoMenu

Arduino generic menu/interactivity system
GNU Lesser General Public License v2.1
929 stars 189 forks source link

Debouncing Buttons #434

Closed mikejr83 closed 5 months ago

mikejr83 commented 5 months ago

I'm working through the ajoy example with what I assume is a similar joystick, it has a two potentiometers and a switch that can be activated when pressing down on the assembly.

I've gotten the example working well with an Adafruit OLED display using the appropriate GFX library example. However, I'm having difficulty with "clicks" within the menu. It seems like the click is getting registered multiple times. It's like it needs to be debounced. Is there a way to accomplish this?

The analogAxis type specifies a "buffer size" but it doesn't appear that those two items are linked. The button is set up through the keyMap with its own pin. It would be helpful if there was some sort of way to apply a debounce in its definition.

neu-rah commented 5 months ago

you can directly read your inputs and do the necessary debouncing and then call commands on the menu, see this example pls https://github.com/neu-rah/ArduinoMenu/blob/master/examples/codeCtrl/codeCtrl/codeCtrl.ino