PC style Autorepeat for keypad connected to BS2
Nav
Posts: 23
I've got a 12-key matrixed keypad connected to my BS2 via a MM74C922 16-key encoder.
The code I've written goes round in a loop monitoring the keypad for activity.· It does this by checking the Data Available pin of the MM74C922 which is connected to P10.· When a key has been pressed, the 4-bit value of the key is input through P0 to P3.
My code works fine as it is, but I'd like to have an Autorepeat as on a PC keyboard.· In more detail;
* For instance, if 4 is pressed and held down, a 4 should appear, followed by a reasonable delay (Repeat delay), followed by an endless stream of 4s each seperated by a tiny delay (Repeat Rate).
* If 4 is pressed and released a 4 should appear followed by a 4 for each subsequent press and release.
* If 4 is pressed and held down, and 5 is pressed at the same time, a 4 should appear followed immediately by a 5 regardless of whether the Repeat Delay has timed out or not.· (The MM74C922 Datasheet indicates that it has a two-key roll-over and indeed that works fine in my single-press code).
The above is, as I understand it, how Autorepeat works on a PC keyboard.
I thought this would be easy to do but after several failed attempts, decided to throw it open to bigger brains than mine !· My code, tested and working, albeit without autorepeat, is attached.
I would be grateful for any help !
The code I've written goes round in a loop monitoring the keypad for activity.· It does this by checking the Data Available pin of the MM74C922 which is connected to P10.· When a key has been pressed, the 4-bit value of the key is input through P0 to P3.
My code works fine as it is, but I'd like to have an Autorepeat as on a PC keyboard.· In more detail;
* For instance, if 4 is pressed and held down, a 4 should appear, followed by a reasonable delay (Repeat delay), followed by an endless stream of 4s each seperated by a tiny delay (Repeat Rate).
* If 4 is pressed and released a 4 should appear followed by a 4 for each subsequent press and release.
* If 4 is pressed and held down, and 5 is pressed at the same time, a 4 should appear followed immediately by a 5 regardless of whether the Repeat Delay has timed out or not.· (The MM74C922 Datasheet indicates that it has a two-key roll-over and indeed that works fine in my single-press code).
The above is, as I understand it, how Autorepeat works on a PC keyboard.
I thought this would be easy to do but after several failed attempts, decided to throw it open to bigger brains than mine !· My code, tested and working, albeit without autorepeat, is attached.
I would be grateful for any help !
Comments
The easiest and most effective way to provide keypad auto-repeat is through the keypad encoder. The EDE-1144 at $ 7.00 (plus postage) will give you auto-repeat and other features as well. As I remember this is even less of a cost than the MM74C9222. Here is a link to the E-Labs web site. Click on the EDE modules for more details:
http://www.elabinc.com/
Regards,
Bruce Bates
·· This is one of the reasons I use the EDE1144 instead of the 74C922.· For one the 74C922 is an active scan chip, in that it is constantly scanning the keys (If memory serves).· The EDE1144 waits for a change, and then performs a scan, which is how it should be done.· But more importantly, it has automatic key repeat after delay.· It also has the same basic interface as the one you're using, or alternately you can save I/O pins and use the serial line instead of 4-bit parallel.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Chris, your memory does serve you well; the 74C922 is an active scan chip and is constantly scanning the keys.· However, it does have a Data Available pin which goes high when a key is pressed.· By watching for the·pin to go low and high again one can determine when a new keypress occurs.· This change can easily be·monitored in code which, in effective, gives it the same functionality as the EDE-114, doesn't it ?· To be perfectly honest, I am very curious to see if/how autorepeat can be acheived in code !!· Anyway, having said all that, if it is too difficult to achieve in code, I'll get hold of the EDE-114.
Thank you both for your feedback.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com