
CHAPTER 9 KEYPAD PORT
RPC-30 Page 29
Figure 9-1 Keypad connector
INTRODUCTION
16 to 24 position keypads are plugged into keypad port
J5. Keys are arranged in a 4 x 4 to 4 x 6 matrix form at.
A key is recognized when a r ow and a c olumn connect.
CAM BASIC automatically scans and debounces the
keypad every debounce time. D ebounce time is fixed at
80 ms. Keypad presses m ay be return ed either as a
number from 1 to 24 or as an ASCII character. The
ASCII character returned corresponds to those on
Remote Processing's KP-1 keypad. Character
assignments are changed using the SYS(8) function.
Keypads from Remote Processing simply plug into J5.
The keypad cable length should be limited to less than 5
feet.
If the keypad port is not used, it may be used as a
general purpose digital I/O port.
PROGRAMMING EXAMPLE
The following example sets up CAMBASIC to scan a 16
position keypad. The results are echo'ed to the display
and the speaker is sounded when a key is pressed.
20 'Optionally change keypad character 'B'
30 ' to the letter 'M'
40 POKE SYS(8)+7,77
50 CONFIG DISPLAY &50,7,1
60 ON KEYPAD$ GOSUB 500
70 DISPLAY (0,0)"Enter a number"
80 DISPLAY (1,0)
100 'loop for this example
110 GOTO 100
500 A$ = KEYPAD$(0)
510 IF A$ = "C" THEN ..clear_beep
520 IF A$ = "#" THEN ..enter
530 DISPLAY A$;
540 B$ = B$+A$
550 SOUND 600,.2
560 RETURN
600 ..clear_beep
610 B$=""
620 SOUND 600,.2
630 DELAY .4
640 SOUND 600,.2
650 DISPLAY (1,0) " ";
660 RETURN
700 ..enter
710 FL = 1
720 SOUND 800,.5
730 RETURN
Program explanation
Lines 10-80 set up the parameters for the keypad and
display. Line 80 positions the cursor on the next line.
Lines 500 to 730 process the key press. If a "C " or "#"
is pressed, it is an exception and is handled that way.
Otherwise, the character is displayed and stored. A beep
indicates it was saved.
Lines 600 to 660 send a double beep w hen data is
cleared. The buffer (B$) is cleared as is the display.
Lines 700 to 730 process the "enter" key. A longer beep
is sounded and the enter flag, F L, is set to a 1 to indicate
to another part of the program that B$ has complete
data.
The KEYPAD$(0) function returns a single character
string that has been assigned to a particular key. Keypad
positions 17-24 do not have a character assigned to them.
These positions are assigned using the SYS(8) statement.
KEYPAD PORT PI NOUT - J5
The keypad port uses ports B and C from an 82C55.
Lower port C is configured as an input. Upper port C
and port B bits 0 and 1 are outputs. Port B bits are used
only when a 20 or 24 position keypad is installed.
Commenti su questo manuale