Difference between revisions of "Example getkey"

From wiki.emacinc.com
Jump to: navigation, search
Line 13: Line 13:
 
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.
 
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:'''<br />                                
+
'''Usage for getkey:'''
 +
                                
 
getkey [-d device -b -g -s file]<br />
 
getkey [-d device -b -g -s file]<br />
 
d: specify the device node, default is ''/dev/keypad''<br />
 
d: specify the device node, default is ''/dev/keypad''<br />
 
b: read blocking, sleep until a key is pressed.<br />     
 
b: read blocking, sleep until a key is pressed.<br />     
g: get matrix returns the current keypad matrix.<br />         
+
g: returns the current keypad matrix.<br />         
 
s: sets the keypad matrix to the matrix specified in file (see project for example file ''Key-E020-21'').<br />
 
s: sets the keypad matrix to the matrix specified in file (see project for example file ''Key-E020-21'').<br />
 
If a matrix operation is not specified then the last key pressed is returned.<br />
 
If a matrix operation is not specified then the last key pressed is returned.<br />
Note:<br />
+
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.
Arguments are evaluated in order. If blocking or device specifications are used, they must be declared before the matrix arguments on the command line.
 
  
i.e. : ./getkey -d /dev/keypad0 -b
+
'''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.

Revision as of 12:40, 14 November 2013

TODO: {{#todo:InProgress(11.14.13-11:04->JG+)|Jgreene|oe 4,oe 5,ky,md,InProgress}}

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.

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.