brettmclean / pad4pi

Interrupt-based matrix keypad library for Raspberry Pi
GNU Lesser General Public License v3.0
51 stars 19 forks source link

wrong key returned when press quickly #18

Open WinBase opened 3 years ago

WinBase commented 3 years ago

Hi

I have found that if i enter numbers quickly (4x4 matrix keypad) it sometimes reports the wrong key pressed, (usually the 1st key in the row, but not always) i.e press key 3 rapidly and it reports a key of '1', sometimes 2, but never 'A'

if i press 'A' in quick succession i can often get 1, 2, or 3 if i press '2' in quick succession i get either 1 or 2, but never 3 or A

def printKey(key): print(key) # wrong number here

i have tried multiple options with repeats and delays to no avail

any idea how to fix this please. sometimes waiting a few seconds between presses still reports the wrong key

thanks

Bob

jakepu commented 3 years ago

I tried to improve this library and saw this issue. The reason why you encounter this behavior (not a bug) is at function getKey(). The program has to check the colVal after determining the rowVal and it takes some time since it is Python and it involves GPIO operations (setting output ports to high takes time). I do not think there is a way to improve it. I hope it answers your question.