当前位置:网站首页>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;
}
}边栏推荐
- Rational and perceptual activities and required skills in programmers' work
- Arm releases the new a78/g78/n78 kernel! There is also a cortex-x Series CPU that supports customization
- 公司7月来了个软件测试工程师,一副毛头小子的样儿,哪想到是新一代卷王...
- Camera and lidar calibration: gazebo simulation livox_ camera_ lidar_ Calibration ---- external parameter calibration calculation and result verification
- Code review tool
- Selection of FFT sampling frequency and sampling points
- The R language uses the hexsticker package to convert the visualized results of ggplot2 package into hexagonal diagrams (hexagonal stickers, hexagonal stickers, ggplot2 plot to hex stickers)
- Server open sensitive port
- map集合
- Matlab | those matlab tips you have to know (I)
猜你喜欢

Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)

从第二层到第三层

LeetCode 415. 字符串相加 和 43. 字符串相乘

Matlab | those matlab tips you have to know (2)

Camera and lidar calibration: gazebo simulation livox_ camera_ lidar_ Calibration ---- external parameter calibration calculation and result verification

这种动态规划你见过吗——状态机动态规划之股票问题(中)

Annual comprehensive analysis of China's online video market in 2022

startUMl
![[must read for new products] valuation analysis of Meishi technology, distributed audio-visual products and Solutions](/img/40/bf3e992e363dbd6600805775058310.jpg)
[must read for new products] valuation analysis of Meishi technology, distributed audio-visual products and Solutions

Set 数据构造函数
随机推荐
A design scheme of Wal
49 times faster, NVIDIA releases quantum hybrid programming platform qoda
头补零和尾补零对FFT输出结果的影响
The influence of head zeroing and tail zeroing on FFT output
[bre] software build release automation
Understand the parental delegation model
程序员工作中的理性与感性活动及所需的技能素养
Application scenario Display of metauniverse
网络设备硬核技术内幕 防火墙与安全网关篇 (小结)
特权更改对现有连接的影响
Matlab | those matlab tips you have to know (3)
Code review tool
JVM memory model
ADB path cannot contain 2 spaces remote could n't create file: is a directory
Intel joins hands with hanshuo and Microsoft to release the "Ai + retail" trick!
Build Release Blogs
网络设备硬核技术内幕 防火墙与安全网关篇 (十二) 零接触办公的奥秘 下
require、loadfile、dofile、load、loadstring
Possible reasons why there is no voltage in the corresponding channel, but the ADC value is changing greatly and is not equal to 0
[BRE]软件构建发布自动化