for testing

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers keys.h Source File

keys.h

00001 #ifndef KEYS_H
00002 #define KEYS_H
00003 
00004 // Possible keys
00005 typedef enum {
00006     KEY_ZERO,
00007     KEY_ONE,
00008     KEY_TWO,
00009     KEY_THREE,
00010     KEY_FOUR,
00011     KEY_FIVE,
00012     KEY_SIX,
00013     KEY_SEVEN,
00014     KEY_EIGHT,
00015     KEY_NINE,
00016     KEY_ASTERISK,
00017     KEY_HASH,
00018     KEY_NONE,
00019     NUM_KEYS,
00020     KEY_END = KEY_NONE,
00021 } Key;
00022 
00023 // Ranges
00024 const Key rangeOne[] = {KEY_ONE, KEY_END};
00025 const Key rangeOneTwo[] = {KEY_ONE, KEY_TWO, KEY_END};
00026 const Key rangeOneSix[] = {KEY_ONE, KEY_TWO, KEY_THREE, KEY_FOUR, KEY_FIVE, KEY_SIX, KEY_END};
00027 const Key rangeSevenOrNine[] = {KEY_SEVEN, KEY_NINE, KEY_END};
00028 const Key rangeAsteriskHash[] = {KEY_ASTERISK, KEY_HASH, KEY_END};  
00029 
00030 /**
00031  * Propagate key press event.
00032  *
00033  * @param byte Received byte of key event.
00034  */
00035 void keyEvent(char byte);
00036 
00037 /**
00038  * Wait key to be pressed.
00039  *
00040  * @return key pressed.
00041  */
00042 Key keyWait(void);
00043 
00044 /**
00045  * Wait key to be pressed.
00046  *
00047  * @param range KEY_END terminated array of keys.
00048  * @return key pressed.
00049  */
00050 Key keyWaitInRange(const Key* range);
00051 
00052 /**
00053  * Get key pressed.
00054  *
00055  * @return key if key is pressed, KEY_NONE - otherwise.
00056  */
00057 Key keyGet(void);
00058 
00059 #endif