get_keys.h

来自「LCD12864上显示波形.rar」· C头文件 代码 · 共 55 行

H
55
字号
#define TRUE  1
#define FAULSE   0

uchar key=0;
uchar scan;

/**********************delay*********************************/

void delay(void)
{
 int l;
 char m;
 for (l=0;l<10;l++)
 for (m=0;m<1;m++);
 }

/****************check if any key pressed*********************/

bit CheckState(void)
{
	bit state=0;
		P3=0x0F;                   //scan key					
	if(P3!=0x0F)state=TRUE;    //check if any key pressed
	else state=FAULSE;
	return(state);
	}

/****************** check which key pressed*****************/

uchar GetKeys(void)
{
	uchar column,line;

	scan=0xFE;

	while((scan&0x10)!=0)
	  {
		P3=scan;
		
		if((P3&0xF0)!=0xF0)                  //current line have key pressed
	  	{
	  	 column=~(P3|0x0F);
		 line=~(scan|0xF0);
		 key=column+line;
		 
		 return(key);                       //return the location of the 
		 									//key which is pressed
			}
		else scan=(scan<<1)|0x01;			//if the pressed key is not on the
											//current line, scan next line
     	 }
	return(0);
	}
	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?