📄 key.h
字号:
/********************************************************/
/*文件名: */
/*功能: */
/*编写: */
/*建立时间:
/*修改纪录: */
/********************************************************/
#ifndef __KEY_H__
#define __KEY_H__
#include <reg52.h>
#include <cpudef.h>
#define KeyMaxTest 16 // 设定按键检测次数
#define KeyNumber 8
//extern INT8U KeyCt[KeyNumber];
sbit Key1 = P2^6;
sbit Key2 = P2^7;
sbit Key3 = P3^2;
sbit Key4 = P3^3;
sbit Key5 = P3^4;
sbit Key6 = P3^5;
sbit Key7 = P3^6;
sbit Key8 = P3^7;
extern INT8U KeyCt[KeyNumber+1]; //定义检测按键的计数器
/*读取按键值*/
extern INT8U GetKeyValue() ;
/*按键检测函数 */
//#define KEYSUBEN //选择是否使用函数调用的方式扫描键盘
#ifdef KEYSUBEN
extern void KeyScan();
#else
#define KeyScan() {\
if ((!Key1)&&(KeyCt[1]<KeyMaxTest)) \
{ \
KeyCt[1]++; \
} \
else if ((!Key2)&&(KeyCt[2]<KeyMaxTest)) \
{ \
KeyCt[2]++; \
} \
else if ((!Key3)&&(KeyCt[3]<KeyMaxTest)) \
{ \
KeyCt[3]++; \
} \
else if ((!Key4)&&(KeyCt[4]<KeyMaxTest)) \
{ \
KeyCt[4]++; \
} \
else if ((!Key5)&&(KeyCt[5]<KeyMaxTest)) \
{ \
KeyCt[5]++; \
} \
else if ((!Key6)&&(KeyCt[6]<KeyMaxTest)) \
{ \
KeyCt[6]++; \
} \
else if ((!Key7)&&(KeyCt[7]<KeyMaxTest)) \
{ \
KeyCt[7]++; \
} \
else if ((!Key8)&&(KeyCt[8]<KeyMaxTest)) \
{ \
KeyCt[8]++; \
} \
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -