evert-arias / EasyButton

Arduino library for debouncing momentary contact switches, detect press, release, long press and sequences with event definitions and callbacks.
https://easybtn.earias.me
MIT License
447 stars 62 forks source link

Joystick / ThumbPad support, where button can have both low and high values #44

Open shafr opened 4 years ago

shafr commented 4 years ago

Hi, I was woundering how to use your library to work with joystick buttons. They have basically x2 10K resistors, so values from analog read goes something like this:

Left Middle Right
0 1850-1900 4096
Pressed Default
0 800-1300

I've tried both Pull_down and Pull_up for the corresponding pins, but values are the same.

Is there any way how I can define (ideally with interrupts) buttons that have both high and low values ? Or define max/min value ?

I'm using ESP32 DEV and Joystick Like this

Thank you.

evert-arias commented 4 years ago

Hi @shafr At the moment the library does not support this type of control but you have definitely pointed out an interesting feature to be implemented.

We appreciate your feedback.

shafr commented 4 years ago

@evert-arias thanks for comment!

I've found something similar that is already implemented here. It has calibration (3.3v and 5v) value detection and implementation itself. (Beerware license)

Maybe there can be a class that is EasyJoystick instead that would extend EasyButton and would have:

evert-arias commented 4 years ago

Hi @shafr It looks good to me 👍. It is a feature that I will take into account to work on in the future.

saikek commented 4 years ago

@evert-arias Awesome. Thank you.