📄 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 _NONE_KEY_MASK 0x00
#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 _ENTER_KEY_MASK 0x20
//#define _KEY5_MASK 0x20
#define _KEY6_MASK 0x40
#define _IR_KEY_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 0x00
#define _RIGHT_KEY_MESSAGE 0x01
#define _LEFT_KEY_MESSAGE 0x02
#define _EXIT_KEY_MESSAGE 0x03
#define _5_KEY_MESSAGE 0x04
#define _6_KEY_MESSAGE 0x05
#define _7_KEY_MESSAGE 0x06
#define _IR_KEY_MESSAGE 0x07
#define _NONE_KEY_MESSAGE 0x08
#define _LEFT_RIGHT_KEY_MESSAGE 0x09
#define _IR_POWER_KEY_MESSAGE 0x10
#define _IR_SOURCE_KEY_MESSAGE 0x11
#define _IR_UP_KEY_MESSAGE 0x12
#define _IR_DOWN_KEY_MESSAGE 0x13
#define _IR_LEFT_KEY_MESSAGE 0x14
#define _IR_RIGHT_KEY_MESSAGE 0x15
#define _IR_MENU_KEY_MESSAGE 0x16
#define _IR_ENTER_KEY_MESSAGE 0x17
#define _IR_VOLINC_KEY_MESSAGE 0x18
#define _IR_VOLDEC_KEY_MESSAGE 0x19
#define _IR_CHINC_KEY_MESSAGE 0x1a
#define _IR_CHDEC_KEY_MESSAGE 0x1b
#define _IR_DISPLAY_KEY_MESSAGE 0x1c
#define _IR_MUTE_KEY_MESSAGE 0x1d
#define _IR_SOUND_KEY_MESSAGE 0x1e
#define _IR_TVTYPE_KEY_MESSAGE 0x1f
#define _IR_RETURN_KEY_MESSAGE 0x20
#define _IR_INPUTCH_KEY_MESSAGE 0x21
#define _IR_NUM0_KEY_MESSAGE 0x30
#define _IR_NUM1_KEY_MESSAGE 0x31
#define _IR_NUM2_KEY_MESSAGE 0x32
#define _IR_NUM3_KEY_MESSAGE 0x33
#define _IR_NUM4_KEY_MESSAGE 0x34
#define _IR_NUM5_KEY_MESSAGE 0x35
#define _IR_NUM6_KEY_MESSAGE 0x36
#define _IR_NUM7_KEY_MESSAGE 0x37
#define _IR_NUM8_KEY_MESSAGE 0x38
#define _IR_NUM9_KEY_MESSAGE 0x39
#define _ENTER_KEY_MESSAGE 0X40
#define _KEY_AMOUNT 4
//----------------------------------------------------------------------------------------------------
#ifdef __KEY__
//--------------------------------------------------
// Global Variables
//--------------------------------------------------
BYTE idata ucKeyControl;
BYTE idata ucKeyMessage;
BYTE idata ucKeyStatePrev;
BYTE idata ucKeyStateCurr;
//bit bBurnIn = 0;
//--------------------------------------------------
// 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);
#if(_KEY_TYPE == _KEY_ADC) // MTV512 & STK6021 ADC Key
unsigned char CheckLRKey1();
#endif
#else
//--------------------------------------------------
// Extern Global Variables
//--------------------------------------------------
extern BYTE idata ucKeyControl;
extern BYTE idata ucKeyMessage;
//extern bit bBurnIn;
//--------------------------------------------------
// 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 + -