acksen / AcksenButton

Button input library for Arduino
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

onPressed() for ACKSEN_BUTTON_MODE_ACCELERATE mode does not account for INPUT_PULLUP resistor mode set #1

Open zapphyre opened 1 year ago

zapphyre commented 1 year ago

in my trials ACKSEN_BUTTON_MODE_ACCELERATE does not work with INPUT_PULLUP mode. what that means is .onPressed() gets called all the time like it's reacting to the HIGH pin value, but in this case the logic should be inverted and it should react only on LOW as internal pull-up was activated.

ACKSEN_BUTTON_MODE_NORMAL seems to act as expected

arduino MKR1000 arduino ide v.2.0

reanzi commented 10 months ago

I saw that too, I had to remove that INPUT_PULLUP. otherwise this library is good. I found it just today and it really simplifies a lot :)

jdotedot commented 2 months ago

This is an easy fix. If the button is initialized in INPUT_PULLUP mode, invert the state of the button in both places where DigitalRead is called.

mark5612 commented 5 days ago

A simple fix is change the 1st line of checkDebounceStatus() to: bool bNewButtonState = digitalRead(uiButtonPin) ^ bQuiescentButtonState;

and then up the top of the file, set the logic polarity... // Initialise internal variables ulLastStatusUpdate_MS = millis(); bQuiescentButtonState = digitalRead(uiButtonPin); bDebouncedButtonState = false;