alextaujenis / RBD_Button

Arduino Button Library - Read and debounce buttons and switches without delay or interrupts.
https://robotsbigdata.com/docs-arduino-button.html
MIT License
32 stars 9 forks source link

Using RBD_Button after interrupt awake from sleep #13

Open Bwanna opened 4 years ago

Bwanna commented 4 years ago

Hi, Description:

Seeking:

Question: In reviewing your .h & .cpp files, it's unclear what the state of the _temp_state variable and the debounce_timer() would be coming out of sleep and already having the button pressed, it's not clear if these two states would be properly set to do the comparisons of the button status and _debounce_timer.isExpired().

Idea: In the situation coming out of sleep, would it work to include in the ISR the following:

My skills in Arduino are still just avg and not sure how to test this idea. That is, to do this in the sketch. Attempts have resulted in errors, I think because these are identified as private class in your library.

Thanks,

Bwanna commented 4 years ago

ISSUE: When a button activates Interrupt, debounce timer needs to be restarted to account for the period beginning when the INT occurs. RECOMMENDATION:

RBD_Button_Restart.zip

(Note: This is the first time I'm suggesting a change on GITHUB. Please let me know if this was done in the correct manner. Thanks!)