📄 key display.c
字号:
#include <reg52.h>
#include <lcd.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[18]={"0123456789abcdef0"};
void delay(uint k)
{
uint a,b;
for(a=0;a<k;a++)
for(b=0;b<125;b++)
{
}
}
uchar keyword(void)
{
uchar row,queue,key=16,sccode=0;
P1=0xf0;
if((P1&0xf0)!=0xf0)
{
delay(10);
if((P1&0xf0)!=0xf0)
{
row=0xfe;
while((row&0x10)!=0)
{
P1=row;
if((P1&0xf0)!=0xf0)
{
queue=P1&0xf0;
switch(queue)
{
case 0xe0: key=0+sccode;break;
case 0xd0: key=1+sccode;break;
case 0xb0: key=2+sccode;break;
case 0x70: key=3+sccode;break;
}
return(key);
}
else
row=(row<<1)|0x01;
sccode+=4;
}
}
}
return(key);
}
void main(void)
{
uchar t,c[2];
uchar temp;
lcd_initial();
delay(1); // 用这个delay,是消除因gotoxy函数没有执行完而print函数就开始执行从而//
gotoxy(15); // 在液晶屏起始位置出现0字的现象//
print("0");
while(1)
{
t=keyword();
c[0]=table[t];
if(t!=16)
{
temp=P1;
temp=temp&0xf0;
gotoxy(15);
print(c);
while((temp&0xf0)!=0xf0) // 这里要特别注意:不能引用lcd-write函数将数据写进去//
{ // 可能是主函数没有将其调入进去 //
temp=P1;
temp=temp&0xf0;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -