⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 key.h

📁 LV4137显示驱动,自己做的,比较简单,但很实用,MCU用的是Myson MTV512,Keil下编译
💻 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 _KEY1_MASK		0x01
#define _KEY2_MASK		0x02
#define _KEY3_MASK		0x03

//--------------------------------------------------
// Definitions of Key Message
//--------------------------------------------------
#define _NONE_KEY_MESSAGE	0x00
#define _KEY1_MESSAGE		0x01
#define _KEY2_MESSAGE		0x02
#define _KEY3_MESSAGE		0x03



//----------------------------------------------------------------------------------------------------

#ifdef __KEY__

//--------------------------------------------------
// Global Variables
//--------------------------------------------------
BYTE idata ucKeyControl;	//V334
BYTE idata ucKeyMessage;
BYTE idata ucKeyStatePrev;
BYTE idata ucKeyStateCurr;

//--------------------------------------------------
// Function Prototypes
//--------------------------------------------------
void CKeyHandler(void);
void CKeyInitial(void);
bit CKeyScanReady(void);
void CKeyScanReadyTimerEvent(void);
void CKeyRepeatEnableTimerEvent(void);
void CKeyMessageConvert(BYTE ucKeyMask, BYTE ucKeyMsg);
BYTE CKeyScan(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 CKeyInitial(void);
extern BYTE CKeyScan(void);
extern bit CKeyScanReady(void);
extern void CKeyScanReadyTimerEvent(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 + -