69 lines
1.4 KiB
C
69 lines
1.4 KiB
C
#ifndef __KEY_SCAN_H
|
|
#define __KEY_SCAN_H
|
|
|
|
//#define KEY_NUM1_DEF //支持一个按键
|
|
#define KEY_NUM2_DEF //支持两个按键
|
|
//#define KEY_NUM3_DEF //支持三个按键
|
|
|
|
|
|
#define IO_KEY_ON P2_7
|
|
#define IO_KEY_LED P3_0
|
|
|
|
|
|
#ifdef KEY_NUM1_DEF //支持一个按键
|
|
#define KEY_1_IO_RD IO_KEY_ON
|
|
#endif
|
|
|
|
#ifdef KEY_NUM2_DEF //支持两个按键
|
|
#define KEY_1_IO_RD IO_KEY_ON
|
|
#define KEY_2_IO_RD IO_KEY_LED
|
|
#endif
|
|
|
|
#ifdef KEY_NUM3_DEF //支持三个按键
|
|
#define KEY_1_IO_RD IO_KEY_ON
|
|
#define KEY_2_IO_RD IO_KEY_LED
|
|
#define KEY_3_IO_RD IO_KEY_LED //用户自定义
|
|
#endif
|
|
|
|
|
|
#define KEY_ON_S 0x01 //第一个按键
|
|
#define KEY_ON_L 0x11
|
|
#define KEY_ON_LC 0x21
|
|
#define KEY_ON_LE 0x41
|
|
|
|
#define KEY_LED_S 0x02 //第二个按键
|
|
#define KEY_LED_L 0x12
|
|
#define KEY_LED_LC 0x22
|
|
#define KEY_LED_LE 0x42
|
|
|
|
#define KEY_3_S 0x03 //预留给第三个按键
|
|
#define KEY_3_L 0x13
|
|
#define KEY_3_LC 0x23
|
|
#define KEY_3_LE 0x43
|
|
|
|
#define KEYVAL_1 0x01
|
|
#define KEYVAL_2 0x02
|
|
#define KEYVAL_3 0x03
|
|
#define KEYVAL_NULL 0x0F
|
|
|
|
#define KEY_STATE_S 0x00
|
|
#define KEY_STATE_L 0x10
|
|
#define KEY_STATE_LC 0x20
|
|
#define KEY_STATE_LE 0x40
|
|
|
|
#define KEY_S_TIME 10 //(2+1)*5ms
|
|
#define KEY_L_TIME 400 //400*5ms
|
|
#define KEY_LC_TIME 1200 //1200*5ms
|
|
|
|
|
|
|
|
extern BOOL bKeyFlg;
|
|
extern U16 data uiKeyValidCnt;
|
|
extern U16 data uiKeyInvalidCnt;
|
|
extern U8 data ucKeyValue;
|
|
extern U8 data ucKeyOldValue;
|
|
extern U8 data ucKeyValueBK;
|
|
|
|
extern void KeyScan(void);
|
|
|
|
#endif |