?? 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 + -