pingdynasty / OwlWare

Legacy firmware for the OWL programmable effects pedal, superceded by OpenWare.
GNU General Public License v2.0
109 stars 29 forks source link

PUSHBUTTON debounce is broken #16

Closed giuliomoro closed 8 years ago

giuliomoro commented 8 years ago

When using isButtonPressed(PUSHBUTTON) sometimes the state does not return to false when releasing the button. If the state is "stuck" to true, pressing the button a few times will most likely not toggle the state. Pressing it down for a longer time (say more than 500ms) will most likely revert to the false state (upon release). Also sometimes when stuck in the true state, a quick double press (double click-style) will succesfully revery to the false state. When the state is false and the buttons is not pressed, a very quick press of the button will most likely trigger a "stuck" true state. Long-ish (~1s) button presses will most likely correctly revert to false when released.

@pingdynasty comment was "I suspect it's the button debounce code which is out of kilter. The debounce period is too long, so the button release event is frequently ignored."

giuliomoro commented 8 years ago

Solution should be as simple as this

diff --git a/Source/device.h b/Source/device.h
index 9ddd282..0230723 10064--- a/Source/device.h
+++ b/Source/device.h
@@ -130 +130 @@
-#define PUSHBUTTON_DEBOUNCE          100 // 40Hz
+#define PUSHBUTTON_DEBOUNCE          5 // 40Hz

but I cannot test it as I can't manage to compile the program.

pingdynasty commented 8 years ago

Issue is fixed with updated tick period and the introduction of sample-accurate button timing: 12ab4935845cdb1fdc4fe45c305b800932612506