标题:各位大神麻烦解释一下这个简短的程序 最好是逐行解释
取消只看楼主
konggang
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-7-10
结帖率:0
已结贴  问题点数:20 回复次数:3 
各位大神麻烦解释一下这个简短的程序 最好是逐行解释
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
#define SCANPORT P1
sbit spk=P3^0;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,
                     0x6d,0x7d,0x07,0x7f,0x6f,
                     0x77,0x7c,0x39,0x5e,0x79,
                     0x71};
uchar uca_LineScan[4]={0xEF,0xDF,0xBF,0x7F};
uchar ucKeyScan()
{
    uchar Temp=0;                  
    uchar ucRow=0,ucLine=0;        

    for(ucLine=0;ucLine<4;ucLine++)   
        {
            SCANPORT=uca_LineScan[ucLine];               
            Temp=SCANPORT & 0x0F;                     
            if(Temp!=0x0F)         
                {                                    
                switch(Temp)
                    {
                    case 0x0E: ucRow=10;break;         
                    case 0x0D: ucRow=20;break;
                    case 0x0B: ucRow=30;break;
                    case 0x07: ucRow=40;break;
                    default:   ucRow=50;break;
                    }
                break;
                }
        }

    SCANPORT=0x0F;                     
    return ucRow+ucLine+1;            
}
void vKeyProcess(unsigned char ucKeyCode)
{
        
    switch(ucKeyCode)
        {
        case 11:P0=table[0];spk=1;break;                              //'7'
        case 12:P0=table[1];spk=1;break;                              //'8'
        case 13:P0=table[2];spk=1;break;
        case 14:P0=table[3];spk=1;break;
                              
        case 21:P0=table[4];spk=1;break;                              //'4'
        case 22:P0=table[5];spk=1;break;                              //'5'
        case 23:P0=table[6];spk=1;break;
        case 24:P0=table[7];spk=1;break;
                          
        case 31:P0=table[8];spk=1;break;                              //'1'
        case 32:P0=table[9];spk=1;break;                              //'2'
        case 33:P0=table[10];spk=1;break;
        case 34:P0=table[11];spk=1;break;

        case 41:P0=table[12];spk=1;break;                  //'3'
        case 42:P0=table[13];spk=1;break;
        case 43:P0=table[14];spk=1;break;                          //'0'
        case 44:P0=table[15];spk=1;break;                              //'+'

        default:break;
        }
}
void main()
{
    spk=0;
    P0=0;
   
    while(1)
    {
        vKeyProcess(ucKeyScan());
        spk=0;
    }
}
搜索更多相关主题的帖子: 逐行 table Temp case break 
2017-07-10 13:15
konggang
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-7-10
得分:0 
回复 2楼 grmmylbs
能不能帮我解释一下代码的意思
2017-07-10 14:00
konggang
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-7-10
得分:0 
回复 4楼 grmmylbs
就是这两个循环作用是啥  帮忙解释一下
2017-07-10 14:07
konggang
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-7-10
得分:0 
回复 6楼 grmmylbs
多谢大神指点
2017-07-10 15:00



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-479296-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.086802 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved