2 / 2 6 / 2 0 0 2 2 : 0 6 P M 2 / 2 6 / 2 0 0 2
4 1
N M I Y - 0 0 3 1 P R O G R A M
S E G M E N T S
BASIC
The following example clears and resets the LCD, and then displays the coordinates of the key
press on the matrix keypad. The LCD and key pad interfaces are mapped into external data
memory.
BASIC
uses the XBY() function to access external memory. Memory mapped facilities
such as the built-in LCD and keypad interfaces or an NMIL add-on board can be accessed using
XBY(adr, [data]). The keypad is addressed at 0FFFCH and the LCD (up to 4x20 display) is
addressed at 0FFF8/9H as detailed below. A 4 line by 40 character LCD will require addresses
0FFFA/BH also, for the second control processor on the LCD.
The LCD will display the coordinates of the last key pressed on the keypad when the following
code is executed. The code is organized to show the distinct functions necessary to initialize and
control the LCD and keypad. First, the keypad, LCD, and string array are initialized. Then a
keypad scan is executed until a key press is detected. The specific coordinates are then
determined and written to the next line on the LCD. The keypad scan is then resumed until
another key is pressed.
NEW
10 STRING 22,20
:REM Allocate string space
20 I = 0
22 ROW = 0
:REM Initialize row and column indices
24 COL = 0
REM Constants
30 KEYPAD = 0FFFCH
:REM Keypad latch write/read address
32 LCDCMD = 0FFF8H
:REM Display command address
34 LCDDAT = 0FFF9H
:REM Display data address
35 LCDLINE = 20
:REM Display line length
36 NUMROWS = 4
:REM Number of display rows
37 NUMCOLS = 5
:REM Number of display columns
40 DIM B(5)
:REM Declare array
100 GOSUB 1100
:REM Initialize the LCD
REM Start scan loop
110 DO
120 FOR I = 1 TO 5
:REM Scan columns for key press
130 XBY(KEYPAD) = B(I)
:REM Output column data
140 KPDAT = XBY(KEYPAD)
:REM Read row data
REM Save key-press values and exit
150 IF KPDAT <> 0FFH THEN COL = I : ROW = KPDAT : I = 5
160 NEXT I
170 UNTIL ROW <> 0
:REM Loop until key-press
REM De-bounce key-press
200 DO : KPDAT = XBY(KEYPAD) : WHILE (KPDAT = ROW )
REM Convert row value to coordinate
210 FOR I = 1 TO NUMROWS
220 IF B(I) = ROW THEN ROW = I
230 NEXT I
REM Assemble display string
300 ASC($(0), 1) = ROW + 030H
310 ASC($(0), 2) = 02CH
:REM comma
320 ASC($(0), 3) = 020H
:REM space
330 ASC($(0), 4) = COL + 030H
400 GOSUB 1000
:REM Write key position to display
Summary of Contents for NMIY-0031
Page 1: ...2 2 6 2 0 0 2 2 0 6 P M 1 NMIY 0031 Single Board Computer Covers NMIY 0031 V1 0 4 22 96 ...
Page 2: ...2 2 6 2 0 0 2 2 0 6 P M 2 ...
Page 6: ...2 2 6 2 0 0 2 2 0 6 P M 6 ...
Page 8: ...2 2 6 2 0 0 2 2 0 6 P M 8 ...
Page 14: ...2 2 6 2 0 0 2 2 0 6 P M 1 4 ...
Page 30: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 3 0 ...
Page 32: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 3 2 ...
Page 50: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 5 0 ...
Page 52: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 5 2 ...
Page 54: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 5 4 ...
Page 56: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 5 6 ...
Page 58: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 5 8 ...
Page 60: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 6 0 ...
Page 62: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 6 2 ...
Page 68: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 6 8 ...
Page 70: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 7 0 ...
Page 72: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 7 2 ...
Page 76: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 7 6 ...
Page 82: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 8 2 ...
Page 84: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 8 4 ...
Page 86: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 8 6 ...
Page 88: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 8 8 ...
Page 90: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 9 0 ...
Page 102: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 0 2 ...
Page 108: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 0 8 ...
Page 110: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 1 0 ...
Page 114: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 1 4 ...
Page 118: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 1 8 ...
Page 126: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 2 6 ...
Page 128: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 2 8 ...
Page 134: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 3 4 ...
Page 148: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 4 8 ...
Page 150: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 5 0 ...
Page 152: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 5 2 ...
Page 154: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 5 4 ...
Page 156: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 5 6 ...
Page 168: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 6 8 ...
Page 170: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 7 0 ...
Page 172: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 7 2 ...
Page 174: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 7 4 ...
Page 178: ...2 2 6 2 0 0 2 2 0 6 P M 2 2 6 2 0 0 2 1 7 8 ...