4 x 4 Keypad with Buffer Object (To celebrate 100th post)
Duane Degn
Posts: 10,588
This will be my first contribution to the OBEX if nothing major is wrong with this object.
This object uses a cog to monitor a 16 key (4 x 4 matrix) keypad and hold the key presses (as ASCII characters) in a buffer until the calling method requests a character.
I didn't want the key presses stored indefinitely since I figure I'll accidentally hit some keys when I don't need the keypad. I wanted the buffer to drop key presses that expire (default expiration time is 10 seconds with maximum of 26.8 seconds (half a roll over) (this assume 80MHz)).
There is a little bit of Beau's original object left (a few lines). I still use his capacitive method (although I have to add 0.1 uF caps to the columns).
I'll post this to the OBEX tomorrow as version 1.0, if no one finds any corrections to make. I hope some of you have time (and the hardware) to test this.
I've included a demo program that tests out the object. Make use and try the "Spacebar" mode. In this mode the key presses are stored in the buffer until the spacebar is pressed. Depending on how soon you press the spacebar the key presses may or may not expire. (I like the expiring key presses part. I wanted to write an object like this about a year ago but it was still a bit beyond me.)
This is also my first (successful) attempt at a circular buffer. I had to use a lock (also a first for me) to keep the buffer uncorrupted. The object doesn't check to make sure there are locks available.
Thanks,
Duane
PS Hey, I'm I a "Senior Member" with 100 posts?
Edit(3/11/15): Warning, the code attached is an old version. There are likely better options available.
I plan to upload this program or an improved version to my GitHub account
If there isn't code similar to what is attached here on my on GitHub, send me a message and I'll make and check for any improved versions of the code.
This object uses a cog to monitor a 16 key (4 x 4 matrix) keypad and hold the key presses (as ASCII characters) in a buffer until the calling method requests a character.
I didn't want the key presses stored indefinitely since I figure I'll accidentally hit some keys when I don't need the keypad. I wanted the buffer to drop key presses that expire (default expiration time is 10 seconds with maximum of 26.8 seconds (half a roll over) (this assume 80MHz)).
There is a little bit of Beau's original object left (a few lines). I still use his capacitive method (although I have to add 0.1 uF caps to the columns).
I'll post this to the OBEX tomorrow as version 1.0, if no one finds any corrections to make. I hope some of you have time (and the hardware) to test this.
I've included a demo program that tests out the object. Make use and try the "Spacebar" mode. In this mode the key presses are stored in the buffer until the spacebar is pressed. Depending on how soon you press the spacebar the key presses may or may not expire. (I like the expiring key presses part. I wanted to write an object like this about a year ago but it was still a bit beyond me.)
This is also my first (successful) attempt at a circular buffer. I had to use a lock (also a first for me) to keep the buffer uncorrupted. The object doesn't check to make sure there are locks available.
Thanks,
Duane
PS Hey, I'm I a "Senior Member" with 100 posts?
Edit(3/11/15): Warning, the code attached is an old version. There are likely better options available.
I plan to upload this program or an improved version to my GitHub account
If there isn't code similar to what is attached here on my on GitHub, send me a message and I'll make and check for any improved versions of the code.
Comments