Remote-processing RPC-52 Manuel d'utilisateur Page 27

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 36
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 26
CHAPTER 9 KEYPAD PORT
Page 25
Figure 9-1 Keypad connector
INTRODUCTION
16, 20, or 24 position keypads are plugged into keypad
port J5. Keys are arranged in a matrix for mat. A key is
recognized when a row and a colum n connect.
RPBASIC-52 scans and debounces the keypad every
debounce time as defined by CONFIG KEYPAD.
Keypad presses are returned as a number from 1 to 24
using the KEYPAD function.
Keypads from Remote Processing simply plug into J5.
The keypad cable length should be limited to less than 5
feet.
PROGRAMMING EXAMPLE
The following example sets up RPBASIC-52 to scan a 16
position keypad. T he results a re echo ' ed when a key is
pressed. C ONF IG KEYPAD is entered in the command
mode. It need be entered only once. Press the 'D' key
to enter.
CONFIG KEYPAD 5
10 STRING 200,20
20 $(0) = "123A456B789C*0#D"
30 P = 1
40 PF = 0
50 PRINT "Enter a number from the keypad",
REM Rest of program continues
REM Scan keypad and update display
200 GOSUB 500
210 IF PF = 0 THEN 200
220 PRINT
230 PRINT "Entered string is: ",$(2)
240 PF = 0
250 GOTO 50
500 A = KEYPAD(0)
510 IF A = 0 THEN 500
520 IF A = 12 THEN 600 : REM Process clear
530 IF A = 16 then 700 : REM process enter
540 A=ASC($(0),A)
550 PRINT CHR(A),
560 ASC($(2),P) = A
570 P = P + 1
580 ASC($(2),P) = 13
590 RETURN
600 REM Clear input string
610 $(2) = ""
620 P = 1
630 RETURN
700 REM Enter processing
710 P = 1
720 PF = 1
730 RETURN
Program explanation
Line 20 defines the keypad legend. Letters may be
redefined as necessary.
Line 30 sets the position counter used to insert characters
into the string.
Line 200 w aits for a key press. The enter ed string is
printed.
Line 500 checks the keypad. If a character is available,
it processes it.
Lines 540-590 update the input string and position. A
< CR> is inserted to mark the end of string.
KEYPAD PORT PI N OUT - 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.
The table below lists J5' s pin out, 82C55 port and bit,
and its intended function.
Pin 82C55 Function
Port/ bit
1 C/0 Row 1
2 C/6 Column 3
3 C/5 Column 2
4 C/1 Row 2
5 C/2 Row 3
6 C/4 Column 1
7 C/7 Column 4
8 C/3 Row 4
9 B/0 Column 5
10 B/1 Column 6
COMMANDS
The following is a list of RPBASIC-52 commands for
the keypad.
Command Function
CONFIG
KEYPAD Sets keypad parameters
KEYPAD(n) Returns last key from keypad
port
Vue de la page 26
1 2 ... 22 23 24 25 26 27 28 29 30 31 32 ... 35 36

Commentaires sur ces manuels

Pas de commentaire