Example getkey
This procedure provides an overview of how to compile and run the getkey C example project. It assumes familiarity with the C programming language and is intended to be used by experienced programmers who are looking to learn the EMAC SDK.
Contents
1. Open the C/C++ editing perspective
2. Open the egpc project
3. Build, upload and run
What it does
This is an example program for mapping keypad input to a character matrix using the keypad interface on the SOM-150ES. It requires a SOM-150ES board and the keypad that goes with it.
Usage for getkey:
getkey [-d device -b -g -s file]
d: specify the device node, default is /dev/keypad
b: read blocking, sleep until a key is pressed.
g: returns the current keypad matrix.
s: sets the keypad matrix to the matrix specified in file (see project for example file Key-E020-21).
If a matrix operation is not specified then the last key pressed is returned.
Note: Arguments are evaluated in order. If blocking or device specifications are used, they must be declared before the matrix arguments on the command line.
Usage example #1
./getkey -d /dev/keypad0 -g
The program will display the matrix presently associated with the keypad at /dev/keypad0.
Usage example #2
./getkey -d /dev/keypad0 -s Key-E020-21
The program will map the keypad at /dev/keypad0 to the matrix file Key-E020-21.
Usage example #3
./getkey -d /dev/keypad0 -b
The program will wait until a key is pressed on the keypad. When a key is pressed it will display the corresponding character mapped to that pressed key, as specified in the matrix file.