Closed fraser125 closed 7 years ago
Looks like I figured out how to make a pull request on Github :)
After merging your latest pull request I've applied another change which should achieve the same result without impacting the library performances.
Will you be so kind to double check it works for you?
Thanks
UPDATE Forget about it, my improvement doesn't work and I have already reverted it.
I'm using a fairly common LCD + Button shield designed by DFRobot and available many other places. It has 5 buttons on A0 analog pin.
The problem I seem to be having is with the Right button not firing it's press or hold functions. I believe the problem is because the right button has an ADC reading of 0 (ZERO). When it gets to the following line:
if (reading >= buttons[i].value - margin && reading <= buttons[i].value + margin) {
The comparison fails with the following values being tested reading:0 buttons[i].value - margin : 65526 buttons[i].value + margin : 10 By changing a couple of variable definitions to support unsigned integers seems to fix it.Change the following lines, sorry I don't know how to make a pull request :(
to
int16_t reading = analogRead(pin);
AND
to
int16_t value;
I got the following values which fixed my problem. reading:0 buttons[i].value - margin : -10 buttons[i].value + margin : 10 I'm interested in feedback on this code change, since I'm not much of a C programmer.