Example keypad simple matrix
This is a guide to the keypad_simple_matrix
C example project included in the EMAC OE SDK.
The keypad_simple_matrix
example C project demonstrates how to use a keypad with a SoM150ES carrier board. It provides examples of how to specify, inspect and test associations between character-data and keypad-keys.
The keypad_simple_matrix
C example project creates one executable: keypad_matrix
. The project also uses one configuration file: keypad_matrix.conf
Contents
Background
In order to use this example with Qt Creator, select the keypad_simple_matrix
project from the list of EMAC examples. Choose a build directory outside of the EMAC SDK, run CMake, and build the project. The project can now be deployed to a target SoM-150 based system.
If Qt Creator is not being used, please refer to Getting Started with the EMAC OE SDK.
General Information
To use the keypad_simple_matrix
program requires the following hardware.
- A SOM-150ES carrier board (Available from EMAC).
- A compatible SoM for that carrier board (SOM-9G20M, SoM-9g25, SOM-9X25, and SoM-A5D35 are all compatible and available from EMAC).
- A compatible keypad (Available from EMAC, refer to item# E20-21 or E020-25. Datasheet).
SOM-150ES carrier board with keypad
Plugging the Keypad into the SOM-150ES Carrier Board
Plug the keypad into the HDR5 KEYPAD header of the SOM-150ES Carrier Board.
Ensure that pin 0 of the keypad's ribbon cable is lined up with pin 2 on the header.
The Keypad Matrix File
The keypad matrix file specifies associations between keypad-keys and characters. An example is shown below:
# INPUT_CODE|OUTPUT_CHARACTER|
0x02|1|
0x03|2|
0x04|3|
0x05|4|
0x06|5|
0x07|6|
0x08|7|
0x09|8|
0x0a|9|
0x0b|0|
0x1e|*|
0x30|\n|
0x2e|A|
0x20|B|
0x12|C|
0x21|D|
# Keycode translation that comes
# from the default keypad mapping
# in the EMAC driver.
# ---------------------------------
# | 0,0 | 0,1 | 0,2 | 0,3 |
# | KEY_1 | KEY_2 | KEY_3 | KEY_C |
# | 0x02 | 0x03 | 0x04 | 0x2e |
# ---------------------------------
# | 1,0 | 1,1 | 1,2 | 1,3 |
# | KEY_4 | KEY_5 | KEY_6 | KEY_D |
# | 0x05 | 0x06 | 0x07 | 0x20 |
# ---------------------------------
# | 2,0 | 2,1 | 2,2 | 2,3 |
# | KEY_7 | KEY_8 | KEY_9 | KEY_E |
# | 0x08 | 0x09 | 0x0a | 0x12 |
# ---------------------------------
# | 3,0 | 3,1 | 3,2 | 3,3 |
# | KEY_A | KEY_0 | KEY_B | KEY_F |
# | 0x1e | 0x0b | 0x30 | 0x21 |
# ---------------------------------
The default location for this file is the same directory as the executable.
Examples
An example of the keypad_simple_matrix
program being used is shown below:
root
@
soma5d35
:
~
#
./keypad_matrix
1234567890*ABCD
root
@
soma5d35
:
~
#
The program will continue until a key with the value of '\n' is pressed. If no key has that value, the program will not exit.
Conclusion
The keypad_simple_matrix
example C project demonstrates how to use a keypad with a SoM150ES carrier board.