当前位置:网站首页>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;
}
}边栏推荐
- 【打新必读】魅视科技估值分析,分布式视听产品及解决方案
- 强强协同,共拓发展!英特尔与太一物联举办 AI 计算盒聚合服务研讨会
- Precautions for site selection of Yongzhou clean animal laboratory
- 英特尔携手汉朔、微软,释放“AI + 零售”大招!
- 基于Unittest的ddt+yaml实现数据驱动机制
- 自动推理的逻辑09–自动定理证明
- A few lines of code can easily realize the real-time reasoning of paddleocr. Come and get!
- Promoting cloud network integration and building a digital economy: Intel unveiled the 5th Digital China Construction Summit - cloud ecosystem Conference
- 智能便利店带你解锁未来科技购物体验
- Leetcode 415. string addition and 43. string multiplication
猜你喜欢

OpenVINO整合TensorFlow实现推理加速

A few lines of code can easily realize the real-time reasoning of paddleocr. Come and get!

Is it amazing to extract text from pictures? Try three steps to realize OCR!

Smart convenience store takes you to unlock the future technology shopping experience

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

几行代码轻松实现对于PaddleOCR的实时推理,快来get!

冲量在线出席2022数据要素安全流通论坛—政务领域专场,助力行业政务大数据建设创新发展

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

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

҈ straight ҈ Broadcast ҈ Pre ҈ Report ҈ |҈ In hot summer, let's cross the high temperature and "bake" with nono!
随机推荐
Map set
Build Release Blogs
Smart convenience store takes you to unlock the future technology shopping experience
投资80亿!南京华天封测一期项目即将投产!
LeetCode_位运算_中等_137.只出现一次的数字 II
【打新必读】魅视科技估值分析,分布式视听产品及解决方案
Yangchuanhui, CTO of oceanbase: some HTAP databases are not real htaps
MATLAB | 那些你不得不知道的MATLAB小技巧(一)
MATLAB | 那些你不得不知道的MATLAB小技巧(三)
Basic elementary function
The influence of head zeroing and tail zeroing on FFT output
Current situation of semiconductor testing equipment Market: the localization rate is still less than 10%!
Yongzhou water quality testing laboratory construction: Furniture description
mysql数据库的基本操作(一)-——基于数据库
加拿大法院认定孟晚舟“双重犯罪”成立,引渡程序将继续进行!
Arm发布全新A78/G78/N78内核!还有支持自定义的Cortex-X系列CPU
Matlab | matlab terrain generation: rectangular iteration method, inverse Fourier transform method, fractal Berlin noise method
Diffusion + super-resolution model strong combination, the technology behind Google image generator image
[BRE]软件构建发布自动化
JVM memory model