Difference between revisions of "Example getkey"

From wiki.emacinc.com
Jump to: navigation, search
(Using getkey)
(Using getkey)
Line 43: Line 43:
 
===Using getkey===
 
===Using getkey===
  
The '''getkey''' program is controlled from the console via command line parameters. It has 4 functions. You can specify the keypad device node, specify the keypad matrix file (see '''Note on the keypad matrix file''', below), display the current matrix in the console and test individual character-key associations.
+
The '''getkey''' program is controlled from the console via command line parameters. You can specify the keypad device node, specify the keypad matrix file (see '''Note on the keypad matrix file''', below), display the current matrix in the console and test individual character-key associations.
  
 
  <code>./getkey [-d device -b -g -s file]</code>  
 
  <code>./getkey [-d device -b -g -s file]</code>  

Revision as of 11:32, 21 November 2013

TODO: {{#todo:InProgress(11.14.13-11:41->JG+);(11.14.13-15:30->MD-);(11.20.13-15:35->JG+)|Jgreene|oe 4,oe 5,jg,md,Review}}

This is a guide to the getkey C example project included in the EMAC OE SDK. It maps a character matrix to a keypad and provides various functions for inspecting and testing the associations between characters and keys.

Opening, Building and Uploading the Project Files

1. Open the C/C++ editing perspective.

stub

2. Open the getkey project files.

stub

3. Build the getkey project.

stub

4. Upload the getkey binary to the target machine.

stub

Usage and Behavior

Necessary Hardware

To use the getkey program you will need 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

Make sure that you line up pin 0 of the keypad's ribbon cable with pin 2 of the header.
Example getkey howtopluginthekeypad 1.png

Using getkey

The getkey program is controlled from the console via command line parameters. You can specify the keypad device node, specify the keypad matrix file (see Note on the keypad matrix file, below), display the current matrix in the console and test individual character-key associations.

./getkey [-d device -b -g -s file] 
d
Specify the keypad device node. The default is /dev/keypad
b
Test an individual key-character association (via "read blocking"). The program will sleep until a key on the keypad is pressed, then output that key's character to the console.
g
Outputs the current keypad matrix (see note on the keypad matrix file, below) to the console.
s
Specify the keypad matrix file. (See note on the keypad matrix file, below). If a keypad matrix file is not specified then the character associated with the last keypad key pressed is returned.

Note on parameter order. Parameters are evaluated in order. If blocking (b) or device specifications (d) are used, they must be declared before the matrix arguments on the command line.

Note on the keypad matrix file. The keypad matrix file specifies which characters are associated with which keypad-keys. A sample matrix file is included with the project: Key-E020-21. This is a standard text file. The character assignments are arranged in a simple grid.

Usage Example. Associating the Specified Keypad Device Node with the Specified Keypad Matrix File

./getkey -d /dev/keypad0 -s /path/to/this/file/Key-E020-21

The program will map the keypad at /dev/keypad0 to the matrix file Key-E020-21. This associates the grid of characters in the matrix file (see Note on the keypad matrix file, above) with the grid of keys on the keypad.

Usage Example. Displaying the Character Presently Associated With a Key on the Keypad

./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 character associated with that pressed key, as specified in the keypad matrix file (see Note on the keypad matrix file, above).

For example:

root@som9g20:/tmp# ./getkey -d /dev/keypad0 -b
5
root@som9g20:/tmp#

In this case I pressed the 5 key on the keypad.

Usage Example. Displaying the Character Matrix Presently Associated with the Keypad

./getkey -d /dev/keypad0 -g

The program will display the character matrix (see Note on the keypad matrix file, above) presently associated with the keypad at /dev/keypad0.

root@som9g20:/tmp# ./getkey -d /dev/keypad0 -g
1 2 3 C   
4 5 6 D   
7 8 9 E   
A 0 B F   
root@som9g20:/tmp#

The character matrix displayed here is that of the Key-E020-21 file.