📄 key.h
字号:
/*******************检测到的4+4键盘键值(0,1,2......15)********************************************************************************/
unsigned char key;
/****************************************************************************************************************************************/
/******************设置检测到的4+4键盘键值在LCD1602上显示的字符**************************************************************************/
unsigned char getkey,sender,counterOne,counterTwo; //检测到的4+4键盘键值需要在LCD1602上显示的代码地址存放处
unsigned char code keywords[]={0x30,0x31,0x32,0x33, //0,1,2,3, 对应的在LCD1602上的代码地址
0x34,0x35,0x36,0x37, //4,5,6,7,
0x38,0x39,0x41,0x42, //8,9,A,B
0x43,0x44,0x45,0x46};//C,D,E,F
/****************************************************************************************************************************************/
uchar code initialKeyboardCode[] = { 0xef, 0xdf, 0xbf, 0x7f }; //Set the initial keyboard code.
uchar code getKeyboardCode[] = { 0xee, 0xed, 0xeb, 0xe7, 0xde, 0xdd, 0xdb, 0xd7, //When the keyboard pressed
0xbe, 0xbd, 0xbb, 0xb7, 0x7e, 0x7d, 0x7b, 0x77 }; // down ,the mcu will get one of them.
unsigned char i,j,temp;
void searchkey(void) //键值搜索子程序
{
getkey=0;
sender = 0x00;
counterOne = 0x00;
counterTwo = 0x00;
for(counterOne=0x00; counterOne<4; counterOne++)
{
P0 = initialKeyboardCode[counterOne]; //Load the initialKeyboardCode
sender = P0; //Get the keyboardCode when the keyboard press down
for(i=50;i>0;i--)
for(j=200;j>0;j--);//perhaps a delay here.
for(counterTwo=0; counterTwo<16; counterTwo++)
{
if(sender==getKeyboardCode[counterTwo]) //When a geyKeyboardCode equal to the sender '
{
while(sender==P0);
getkey=keywords[counterTwo];//Then load the display code from the theActioncode
//You can write you control functions here too.
}
}
}
}
uchar keyb()
{ getkey=0;
while(getkey==0)
{
searchkey();
}
return(getkey);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -