当前位置:网站首页>Confused SCM matrix keys
Confused SCM matrix keys
2022-07-28 00:44:00 【*Black heart radish three bars*】
In the process of learning SCM , Matrix keys are essential modules , Next, let Xiaobian take you into the SCM matrix button !
One 、 Scanning of matrix keys
The matrix key is composed of sixteen keys , When we judge the position of the matrix key , We use the state machine , Row and column scanning method is also used . Don't talk much , Now let's take a look at the composition of matrix keys !

In the state machine , We set four states , That is, the key is not pressed 、 Key press status 、 Press the key to pop up and turn 、 Shielding status ; The row and column scanning method we use , In fact, it is to determine the unique matrix key position according to the position of rows and columns .
Two 、 Design implementation
1. Define the global variables used :
#define kbd_io P3
#define state_0 0 // Whether to press
#define state_1 1 // Is it jitter
#define state_2 2 // Judge whether it bounces
#define kbd_maskrow 0x0f // Shield unwanted IO
unsigned int key_num=16;2. Specific implementation functions :
void scankbd()
{
static char kbd_state = 0;// Used to judge the state
unsigned char kbd_press;
char row;
switch(kbd_state){
case state_0: // Whether to press
kbd_io=0x0f; P42=0; P44=0;
kbd_press =kbd_io;
if(kbd_press != kbd_maskrow)
kbd_state = state_1;
//break;
case state_1: // Is it jitter kbd_io-P3
kbd_press =kbd_io;
if(kbd_press != kbd_maskrow)
{
if((kbd_io&0x08)==0) row=0; //P30 Column
if((kbd_io&0x04)==0) row=1; //P31 Column
if((kbd_io&0x02)==0) row=2; //P32 Column
if((kbd_io&0x01)==0) row=3; //P33 Column
kbd_io=0xf0; P42=1;P44=1;
if(P44==0) key_num=row; //p44 That's ok
if(P42==0) key_num=row+4; //p42 That's ok
if((kbd_io&0x20)==0) key_num=row+8; //P35 That's ok
if((kbd_io&0x10)==0) key_num=row+12; //p34 That's ok
kbd_state = state_2;
}
else
kbd_state = state_0;
break;
case state_2: // Judge whether it bounces
kbd_io=0x0f; P42=0; P44=0;
kbd_press =kbd_io;
if(kbd_press == 0x0f) kbd_state = state_0;
break;
default: // Shield unwanted IO
break;
}
}边栏推荐
- 小程序助力智能家居生态平台
- mysql数据库的基本操作(一)-——基于数据库
- Leetcode 452. minimum number of arrows to burst balloons (medium)
- A few lines of code can easily realize the real-time reasoning of paddleocr. Come and get!
- 基本初等函数
- In July, a software testing engineer came to the company. He looked like a hairy boy. He didn't expect to be the new generation of roll King
- numpy没有unsqueeze函数
- Leetcode 415. string addition and 43. string multiplication
- FFT 采样频率和采样点数的选取
- 投资80亿!南京华天封测一期项目即将投产!
猜你喜欢

Strong collaboration and common development! Intel and Taiyi IOT held a seminar on AI computing box aggregation services

mysql数据库的基本操作(三)-——基于字段

The second uncle cured my spiritual internal friction and made me angry out of station B

Promoting cloud network integration and building a digital economy: Intel unveiled the 5th Digital China Construction Summit - cloud ecosystem Conference

英特尔携手汉朔、微软,释放“AI + 零售”大招!

Fastjson历史漏洞复现

Ali Er Mian: why do we need to separate databases and tables?

Intel releases open source AI Reference Suite

What are the namespaces and function overloads of + and @ in front of MATLAB folder

Buildforge materials
随机推荐
永州水质检测实验室建设:家具说明
[21 day learning challenge] classmate K invites you to participate in the in-depth learning seminar
Is it amazing to extract text from pictures? Try three steps to realize OCR!
The influence of head zeroing and tail zeroing on FFT output
火狐浏览器 Firefox 103 发布,提升高刷新率显示器下的性能
The Canadian court found Meng Wanzhou guilty of "dual criminality", and the extradition procedure will continue!
Csdn21 day learning challenge
Arm releases the new a78/g78/n78 kernel! There is also a cortex-x Series CPU that supports customization
自动推理的逻辑07–谓词演算
Build Release Blogs
MATLAB | 那些你不得不知道的MATLAB小技巧(二)
Annual comprehensive analysis of China's online video market in 2022
Camera and lidar calibration: gazebo simulation livox_ camera_ lidar_ Calibration ---- external parameter calibration calculation and result verification
Impulse attends the 2022 Forum on safe circulation of data elements Online - a special session in the field of government affairs, and helps the construction and innovative development of big data for
Intensive reading of deep learning papers [gan]: multi-purpose image restoration and processing using depth generation priors
Y79. Chapter IV Prometheus' monitoring system and practice -- Prometheus' service discovery mechanism (10)
MATLAB | 那些你不得不知道的MATLAB小技巧(一)
从第二层到第三层
[must read for new products] valuation analysis of Meishi technology, distributed audio-visual products and Solutions
大众中国豪掷80亿,成国轩高科第一大股东