C interface, 4 rs-232 interface, 5 commands – Matrix Orbital GLK12232-25-WBL User Manual
Page 20

5.3
I
2
C Interface
The keypad is read by I
2
C master read. In short, this means that a read of the module will always return
the first unread key press. A read is initiated by writing to the module with its base address plus 1, then
clocking the module’s return byte after the module releases the SDA line. Much more detail on this basic
I
2
C function can be found in the I
2
C specification by Phillips. A good reference is also available at;
ØØÔ
»»ÛÛÛºÔ
Ò
º
»
¼
½
»
¾
Х
»
¾
Т
Ьº
Ш
С
The module contains a ten key press buffer so that it can be polled for key presses at an infrequent rate
(every 500 to 1000 mS is typical). All returned key presses indicate the presence or absence of additional
logged key presses by the most significant bit (MSB - bit 7). If the user has pressed two keys since the last
poll of the keypad interface, the first read will return the key code with bit 7 set and the second read will
return the key code with bit 7 clear. The application must take into account this bit to keep up with user key
presses. If there are no keypresses detected, the module will return zero (0x00).
5.4
RS-232 Interface
By default on any press of a key, the module will immediately send out the key code at the selected baud
rate. This behavior can be modified using commands found in the next section.
5.5
Commands
5.5.1
Auto repeat mode on (254 126 [mode])
[mode] = 0 gives Resend Key Code mode
[mode] = 1 gives Key down / Key up code mode
Two Modes of auto repeat are available and are set via the same command.
1. Resend Key Code: This mode is similar to the action of a keyboard on a PC. In this mode, when a
key is held down, the key code is transmitted immediately followed by a 1/2 second delay. After this
delay, key codes will be sent via the RS-232 interface at a rate of about 5 codes per second. This mode
has no effect if polling or if using the I
2
C interface.
2. Key down / Key up codes: This mode may be used when the typematic parameters of the Resend Key
code mode are unacceptable or if the unit is being operated in polled mode. The host system detects
the press of a key and simulates an auto repeat inside the host system until the key release is detected.
In this mode, when a key is held down, the key code is transmitted immediately and no other codes will be
sent until the key is released. On the release of the key, the key release code transmitted will be a value equal
to the key down code plus 20 hex. For example, the key code associated with key ’P’ (0x50) is pressed, the
release code is ’p’ (0x70).
In RS-232 polled mode or via the I
2
C interface, the key down / key up codes are used. However, the user
should be careful of timing details. If the poll rate is slower than the simulated auto-repeat it is possible that
polling for a key up code will be delayed long enough for an unwanted key repeat to be generated.
Matrix Orbital
GLK12232-25-WBL
16