Example keypad simple matrix

From wiki.emacinc.com
Jump to: navigation, search
TODO: {{#todo: In Progress (04.12.2016-11:43->KY+)|Klint Youngmeyer|OE 5.0,KY,InProgress}}

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

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.

Som150 with keypad.JPG
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.
Example getkey howtopluginthekeypad 0.png

Ensure that pin 0 of the keypad's ribbon cable is lined up with pin 2 on the header.
Example getkey howtopluginthekeypad 1.png

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.

Pages with Related Content