OP7100
Graphics Programming 81
Keypad Programming
The sample program
KPDEFLT.C
in the Dynamic C
SAMPLES\QVGA
subdi-
rectory demonstrates how to read the keypad. Add the following directives at
the top of the program to make it possible to use the keypad routines.
#use op71l.lib
(landscape orientation) OR
#use op71p.lib
(portrait orientation)
#use op71hw.lib
#use kp_op71.lib
Initialization
To initialize the keypad driver, call
kpDefInit()
. This must be per-
formed before other keypad operations.
Scanning the Keypad
The function
kpScanState()
must be called periodically to scan the
keypad for changes. In a cooperative multitasking (big-loop style), this
function should be called every 25 ms or so. If you are using a real-time
kernel, you can also attach this function to one of the tasks and have it
invoked approximately every 25 ms. Note that this function scans for
changes, but it does not report what was changed.
Reading Keypad Activities
The function
kpDefGetKey()
returns the interpretation of the state
change detected by
kpScanState()
into key activities. The means that
the
kpDefGetKey()
function must be called no less frequently than
kpScanState()
to ensure no key activity is lost. The function
kpDefGetKey()
returns an integer. If the integer is –1, no key activity
was detected. Otherwise, bit 0 to bit 3 indicates the index of the sense line
of the key, and bit 4 to bit 7 indicate the index of the drive line of the key.
Bit 8 indicates whether the key has been "pressed"—the key was pressed if
bit 8 is a 1.
Note that if two key activities occur between two calls to
kpScanState()
,
only one key activity is interpreted by the
kpDefGetKey()
function even
though both activities may be registered by the
kpScanState()
function.
The priority of key interpretation is from drive line 0 (highest priority) to
drive line 7. On the same drive line, the priority is from sense line 0
(highest priority) to sense line 7.
Once a key activity is detected by
kpScanState()
, no further key
activities will be detected by further calls to
kpScanState()
unless
kpDefGetKey()
is called.
Summary of Contents for OP7100
Page 1: ...OP7100 Serial Graphic Display User s Manual 019 0065 070831 O ...
Page 10: ...OP7100 x About This Manual ...
Page 16: ...OP7100 16 Overview ...
Page 74: ...OP7100 74 Software ...
Page 82: ...OP7100 82 Graphics Programming ...
Page 88: ...OP7100 88 Installation ...
Page 98: ...OP7100 98 Specifications ...
Page 108: ...OP7100 108 Memory I O Map and Interrupt Vectors ...
Page 112: ...112 Serial Interface Board 2 OP7100 ...
Page 113: ...OP7100 Backup Battery 113 APPENDIX E BACKUP BATTERY ...
Page 116: ...OP7100 116 Backup Battery ...
Page 124: ...OP7100 124 Index ...
Page 126: ...XX0000 Schematics ...