📄 key.h
字号:
//----------------------------------------------------------------------------------------------------
// ID Code : Key.h No.0000
// Update Note :
//
//----------------------------------------------------------------------------------------------------
//--------------------------------------------------
// Definitions of Key Repeat Start Time (Unit in sec)
//--------------------------------------------------
#define _KEY_REPEAT_START_TIME 0.5
//--------------------------------------------------
// Definitions of Key Mask
//--------------------------------------------------
#define _POWER_KEY_MASK 0x01
#define _MENU_KEY_MASK 0x02
#define _RIGHT_KEY_MASK 0x04
#define _LEFT_KEY_MASK 0x08
#define _EXIT_KEY_MASK 0x10
#define _KEY5_MASK 0x20
#define _KEY6_MASK 0x40
#define _KEY7_MASK 0x80
#define _POWER_RIGHT_KEY_MASK (_POWER_KEY_MASK | _RIGHT_KEY_MASK)
#define _POWER_MENU_KEY_MASK (_POWER_KEY_MASK | _MENU_KEY_MASK)
#define _POWER_LEFT_RIGHT_KEY_MASK (_POWER_KEY_MASK | _LEFT_KEY_MASK | _RIGHT_KEY_MASK)
//--------------------------------------------------
// Definitions of Key Message
//--------------------------------------------------
#define _MENU_KEY_MESSAGE 0
#define _RIGHT_KEY_MESSAGE 1
#define _LEFT_KEY_MESSAGE 2
#define _EXIT_KEY_MESSAGE 3
#define _5_KEY_MESSAGE 4
#define _6_KEY_MESSAGE 5
#define _7_KEY_MESSAGE 6
#define _NONE_KEY_MESSAGE 7
#define _KEY_AMOUNT 4
//----------------------------------------------------------------------------------------------------
#ifdef __KEY__
//--------------------------------------------------
// Global Variables
//--------------------------------------------------
BYTE idata ucKeyControl;
BYTE idata ucKeyMessage;
BYTE idata ucKeyStatePrev;
BYTE idata ucKeyStateCurr;
//--------------------------------------------------
// Function Prototypes
//--------------------------------------------------
void CKeyHandler(void);
void CKeyCheckPowerKey(void);
void CKeyInitial(void);
bit CKeyScanReady(void);
void CKeyScanReadyTimerEvent(void);
void CKeyRepeatEnableTimerEvent(void);
void CKeyMessageConvert(BYTE ucKeyMask, BYTE ucKeyMsg);
BYTE CKeyScan(void);
void CKeyPowerKeyMix(void);
bit CKeyPowerKeyProc(void);
void CKeyMessageProc(void);
#else
//--------------------------------------------------
// Extern Global Variables
//--------------------------------------------------
extern BYTE idata ucKeyControl;
extern BYTE idata ucKeyMessage;
//--------------------------------------------------
// Extern Function Prototypes
//--------------------------------------------------
extern void CKeyHandler(void);
extern void CKeyCheckPowerKey(void);
extern void CKeyInitial(void);
#endif
//----------------------------------------------------------------------------------------------------
//--------------------------------------------------
// Macro of Key Scan Ready Flag
//--------------------------------------------------
#define GET_KEYSCANREADY() ((bit)(ucKeyControl & _BIT0))
#define SET_KEYSCANREADY() (ucKeyControl |= _BIT0)
#define CLR_KEYSCANREADY() (ucKeyControl &= ~_BIT0)
//--------------------------------------------------
// Macro of Key Scan Start Flag
//--------------------------------------------------
#define GET_KEYSCANSTART() ((bit)(ucKeyControl & _BIT1))
#define SET_KEYSCANSTART() (ucKeyControl |= _BIT1)
#define CLR_KEYSCANSTART() (ucKeyControl &= ~_BIT1)
//--------------------------------------------------
// Macro of Key Repeat Start
//--------------------------------------------------
#define GET_KEYREPEATSTART() (bit)(ucKeyControl & _BIT2)
#define SET_KEYREPEATSTART() ucKeyControl |= _BIT2
#define CLR_KEYREPEATSTART() ucKeyControl &= ~_BIT2
//--------------------------------------------------
// Macro of Key Repeat Function Enable
// If you want to use repeat function, please set this flag. If not, please clear it.
//--------------------------------------------------
#define GET_KEYREPEATENABLE() (bit)(ucKeyControl & _BIT3)
#define SET_KEYREPEATENABLE() ucKeyControl |= _BIT3
#define CLR_KEYREPEATENABLE() ucKeyControl &= ~_BIT3
//----------------------------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -