00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00025 #ifndef HL_KEYS_H
00026 #define HL_KEYS_H
00027
00028
00029 #include <avr/pgmspace.h>
00030
00031 #include "xpal_disp_areas.h"
00032
00034 typedef uint16_t keyscan_t;
00035
00036
00038 #define HL_NOKEY 0
00039
00040 #define HL_KEY_PRESSED 0xFFFF
00041
00042
00047 #define BLD_SC(col, row, row_abc) ((_BV(col)<<8) | (_BV(row_abc)<<8) | _BV(row)) //!< \n
00048
00049
00050 #define HL_SCAN_SOFT1 BLD_SC(HL_KEY_COL0,HL_KEY_ROW0,HL_KEY_ROW_A_ID) //!< Display SOFT1 - up left
00051 #define HL_SCAN_SOFT2 BLD_SC(HL_KEY_COL0,HL_KEY_ROW1,HL_KEY_ROW_A_ID) //!< Display SOFT2
00052 #define HL_SCAN_SOFT3 BLD_SC(HL_KEY_COL0,HL_KEY_ROW2,HL_KEY_ROW_A_ID) //!< Display SOFT3 - bottom left
00053
00054 #define HL_SCAN_SOFT4 BLD_SC(HL_KEY_COL0,HL_KEY_ROW3,HL_KEY_ROW_A_ID) //!< Display SOFT4 - below left
00055 #define HL_SCAN_SOFT5 BLD_SC(HL_KEY_COL0,HL_KEY_ROW4,HL_KEY_ROW_B_ID) //!< Display SOFT5
00056 #define HL_SCAN_SOFT6 BLD_SC(HL_KEY_COL0,HL_KEY_ROW5,HL_KEY_ROW_B_ID) //!< Display SOFT6
00057 #define HL_SCAN_SOFT7 BLD_SC(HL_KEY_COL0,HL_KEY_ROW6,HL_KEY_ROW_B_ID) //!< Display SOFT7
00058 #define HL_SCAN_SOFT8 BLD_SC(HL_KEY_COL0,HL_KEY_ROW7,HL_KEY_ROW_B_ID) //!< Display SOFT8 - below right
00059
00060 #define HL_SCAN_SOFT9 BLD_SC(HL_KEY_COL0,HL_KEY_ROW8,HL_KEY_ROW_B_ID) //!< Display SOFT9 - up right
00061 #define HL_SCAN_SOFT10 BLD_SC(HL_KEY_COL0,HL_KEY_ROW9,HL_KEY_ROW_B_ID) //!< Display SOFT10
00062 #define HL_SCAN_SOFT11 BLD_SC(HL_KEY_COL0,HL_KEY_ROW10,HL_KEY_ROW_B_ID)//!< Display SOFT11 - bottom right\n
00063
00064 #define HL_SCAN_LEFT_II BLD_SC(HL_KEY_COL2,HL_KEY_ROW0,HL_KEY_ROW_A_ID) //!< Left Thumb - II
00065 #define HL_SCAN_LEFT_I BLD_SC(HL_KEY_COL2,HL_KEY_ROW1,HL_KEY_ROW_A_ID) //!< Left Thumb - I
00066 #define HL_SCAN_LEFT_ESC BLD_SC(HL_KEY_COL2,HL_KEY_ROW2,HL_KEY_ROW_A_ID) //!< Left Thumb - ESC
00067 #define HL_SCAN_LEFT_OK BLD_SC(HL_KEY_COL2,HL_KEY_ROW3,HL_KEY_ROW_A_ID) //!< Left Thumb - OK
00068
00069 #define HL_SCAN_RIGHT_II BLD_SC(HL_KEY_COL2,HL_KEY_ROW4,HL_KEY_ROW_B_ID) //!< Right Thumb - II
00070 #define HL_SCAN_RIGHT_I BLD_SC(HL_KEY_COL2,HL_KEY_ROW5,HL_KEY_ROW_B_ID) //!< Right Thumb - I
00071 #define HL_SCAN_RIGHT_ESC BLD_SC(HL_KEY_COL2,HL_KEY_ROW6,HL_KEY_ROW_B_ID) //!< Right Thumb - ESC
00072 #define HL_SCAN_RIGHT_OK BLD_SC(HL_KEY_COL2,HL_KEY_ROW7,HL_KEY_ROW_B_ID) //!< Right Thumb - OK\n
00073
00074 #define HL_SCAN_NUM0 BLD_SC(HL_KEY_COL1,HL_KEY_ROW0,HL_KEY_ROW_A_ID) //!< Number Area 0 - bottom center
00075 #define HL_SCAN_NUM1 BLD_SC(HL_KEY_COL1,HL_KEY_ROW1,HL_KEY_ROW_A_ID) //!< Number Area 1
00076 #define HL_SCAN_NUM2 BLD_SC(HL_KEY_COL1,HL_KEY_ROW2,HL_KEY_ROW_A_ID) //!< Number Area 2
00077 #define HL_SCAN_NUM3 BLD_SC(HL_KEY_COL1,HL_KEY_ROW3,HL_KEY_ROW_A_ID) //!< Number Area 3
00078 #define HL_SCAN_NUM4 BLD_SC(HL_KEY_COL1,HL_KEY_ROW4,HL_KEY_ROW_B_ID) //!< Number Area 4
00079 #define HL_SCAN_NUM5 BLD_SC(HL_KEY_COL1,HL_KEY_ROW5,HL_KEY_ROW_B_ID) //!< Number Area 5
00080 #define HL_SCAN_NUM6 BLD_SC(HL_KEY_COL1,HL_KEY_ROW6,HL_KEY_ROW_B_ID) //!< Number Area 6
00081 #define HL_SCAN_NUM7 BLD_SC(HL_KEY_COL1,HL_KEY_ROW7,HL_KEY_ROW_B_ID) //!< Number Area 7
00082 #define HL_SCAN_NUM8 BLD_SC(HL_KEY_COL1,HL_KEY_ROW8,HL_KEY_ROW_B_ID) //!< Number Area 8
00083 #define HL_SCAN_NUM9 BLD_SC(HL_KEY_COL1,HL_KEY_ROW9,HL_KEY_ROW_B_ID) //!< Number Area 9
00084 #define HL_SCAN_STAR BLD_SC(HL_KEY_COL1,HL_KEY_ROW10,HL_KEY_ROW_B_ID) //!< Number Area *
00085 #define HL_SCAN_POUND BLD_SC(HL_KEY_COL1,HL_KEY_ROW11,HL_KEY_ROW_B_ID) //!< Number Area #\n
00086
00087 #define HL_SCAN_POWER BLD_SC(HL_KEY_COL3,HL_KEY_ROW0,HL_KEY_ROW_A_ID) //!< Power Key
00088
00089
00090 #define HL_KEYSTATE_SAME 0x01 //!< Scan Code is the same as during the last call of hlKeyTmTick()
00091 #define HL_KEYSTATE_OTHER 0x02 //!< Scan Code is different as during the last call of hlKeyTmTick()
00092 #define HL_KEYSTATE_PWR 0x04 //!< Current Scan Code is for Power key
00093 #define HL_KEYSTATE_PREVIOUS 0x08 //!< Scan Code is equal to the last key down
00094
00095
00096
00097 #define HL_KEY_DEBOUNCE_CYCLES 1 //!< Key recognized after n poll cycles
00098 #define HL_KEY_STAY_AKTIVE 4 //!< cycles to stay active after key up
00099 #define HL_KEY_WAIT_ALT_FKT 50 //!< wait for same key again, polls to keep splash screen open
00100 #define HL_KEY_MAX_KEY_FUNCT 3 //!< maximum number of key codes per key
00101 #define HL_KEY_INT_MIN_CYCLE 5 //!< minimum number of timer cycles to run after a key interrupt, max 126.
00102 #define HL_KEY_PWR_ON_SEQUENCE -1 //!< system is debouncing a power on cycle
00103
00104 #define HL_KEY_BUFSZ 8 //!< size of key buffer
00105
00107 typedef enum {
00108 KEY_UP = 0,
00109 ALLOW_SLEEP = 1,
00110 MOVING_DOWN = 2,
00111 KEY_DOWN = 3,
00112 MOVING_UP = 4,
00113 OFF_KEY_UP = 5,
00114 PWR_OFF = 6,
00115 KEY_PROCESSED = 7,
00116 POWER_ON = 8,
00117 } hl_key_DebounceStates;
00118
00119
00120
00121
00122
00123
00124
00129 void hl_Key_Init(void);
00130
00131
00137 uint16_t hlKeyTmTick(void);
00138
00139
00147 uint8_t hlGetKeySc(keyscan_t *Key);
00148
00149
00155 void hlAllKeyWakeup(void);
00156
00157
00163 void hlRow3KeyWakeup(void);
00164
00165
00166 #endif