📄 get-key.h
字号:
#include"sys-head.H"
/******************************************
**行列式键盘扫描:
行:P0.7-P0.4
列:P0.3-P0.0
**bingbing
******************************************/
char getkey(void)
{
//程序起初置行
Uchar key_temp;
key_temp =0xf0;
P1 =key_temp;
if((P1&0xf0)!=0xf0)
{
//按键去抖
Delay5Ms();
Delay5Ms();
Delay5Ms();
Delay5Ms();
//如果检测状态还在,那么判断为有效按键
if((P1&0xf0)!=0xf0)
{
//在判断行后,置位列,去判断哪一行被按下确定按键的准确位置
if(!(P1&0x80))
{
//第1行有键按下
P1 =0x0f;
if(!(P1&0x08))
{
return 0;
}
else if(!(P1&0x04))
{
return 1;
}
else if(!(P1&0x02))
{
return 2;
}
else if(!(P1&0x01))
{
return 3;
}
}
else if(!(P1&0x40))
{
//第2行有键按下
P1 =0x0f;
if(!(P1&0x08))
{
return 4;
}
else if(!(P1&0x04))
{
return 5;
}
else if(!(P1&0x02))
{
return 6;
}
else if(!(P1&0x01))
{
return 7;
}
}
else if(!(P1&0x20))
{
//第3行有键按下
P1 =0x0f;
if(!(P1&0x08))
{
return 8;
}
else if(!(P1&0x04))
{
return 9;
}
else if(!(P1&0x02))
{
return 10;
}
else if(!(P1&0x01))
{
return 11;
}
}
else if(!(P1&0x10))
{
//第4行有键按下
P1 =0x0f;
if(!(P1&0x08))
{
return 12;
}
else if(!(P1&0x04))
{
return 13;
}
else if(!(P1&0x02))
{
return 14;
}
else if(!(P1&0x01))
{
return 15;
}
}
else
return -1;
}
else
return -1;
}
else
return -1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -