Shop OBEX P1 Docs P2 Docs Learn Events
VKEY DEMO - A full keypad using only 4 keys and 1 or 2 fingers — Parallax Forums

VKEY DEMO - A full keypad using only 4 keys and 1 or 2 fingers

Peter JakackiPeter Jakacki Posts: 10,193
edited 2008-03-16 00:49 in Propeller 1
There are times when I design a piece of equipment which needs a numeric keypad plus function keys for operator entry. This creates problems with mounting, I/O lines, and space constraints. I came up with this idea the other day of using 4 keys in quasi-binary fashion except no more than 2 fingers (V) are used to select a code. I built up a keypad and tried it all out and it is very easy to use. The basic idea is to have buttons labeled (4)+(2)+(1)+(0) where you can tap out these values plus combinations of them. Unlike a pure binary input this has a "0" key plus it uses the "0" key as a modifier to directly enter the digits 7,8, and 9.

Function keys are selected by holding down the key for around half a second where the keypad will timeout and generate a function code.

The actual code to "scan" the keys is very simple and reliable. Each key is connected to a port pin with a 10K pullup and the other end is grounded. This is something that I will be building into some industrial and commercial designs where full keypad input is desired but not practical.

You will find a four function calculator demo attached that outputs to an ANSI terminal like Teraterm or Hyperterminal. It's a bit rough but try it out.

Here's the actual VKEY encoder routine.
' return with key code or 0 if no key   
pub vkey : key | latch
  if timeout == 0
    repeat while (ina[noparse][[/noparse]s4..s0] ^ $0f) & $0F
  latch := 0
  timeout := fnctime
  repeat
    key := (ina[noparse][[/noparse]s4..s0] ^ $0f) & $0F 
    latch |= key
    timeout--
  until key == 0 or timeout == 0
                           '0   1   1+0 2   2+0 2+1 210 4   4+0 41  410 42  420 421 4210    
  key := lookupz(latch: 0, "0","1","7","2","8","3","9","4","9","5",$0B,"6",$0C,"7",$0F)
  if timeout == 0
    key |= $80            ' encode timeout keys with msb set




*Peter*

Post Edited (Peter Jakacki) : 3/16/2008 12:37:19 AM GMT

Comments

Sign In or Register to comment.