微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 第10节:一个用来学习C语言的模板程序

第10节:一个用来学习C语言的模板程序

时间:11-22 来源:互联网 点击:

------------------------------------------------------------------------*/

GuiWdData0=10; //把10这个数值放到窗口变量0里面显示

GuiWdData1=11; //把11这个数值放到窗口变量1里面显示

GuiWdData2=12; //把12这个数值放到窗口变量2里面显示

GuiWdData3=13; //把13这个数值放到窗口变量3里面显示

GuiWdData4=14; //把14这个数值放到窗口变量4里面显示

GuiWdData5=15; //把15这个数值放到窗口变量5里面显示

GuiWdData6=16; //把16这个数值放到窗口变量6里面显示

GuiWdData7=17; //把17这个数值放到窗口变量7里面显示

GuiWdData8=18; //把18这个数值放到窗口变量8里面显示

GuiWdData9=19; //把19这个数值放到窗口变量9里面显示

/*---C语言学习区域的结束---------------------------------------------------------------------------*/

while(1)

{

initial();

key_service();

display_service();

}

}

void display_service(void)

{

static unsigned char SucLedStatus16_09=0;

static unsigned char SucLedStatus08_01=0;

static unsigned int SinWdDataTemp=0;

if(1==GucDisplayUpdate)

{

GucDisplayUpdate=0;

switch(GucWd)

{

case 0:

GucDigShow8=0;

SinWdDataTemp=GuiWdData0;

break;

case 1:

GucDigShow8=1;

SinWdDataTemp=GuiWdData1;

break;

case 2:

GucDigShow8=2;

SinWdDataTemp=GuiWdData2;

break;

case 3:

GucDigShow8=3;

SinWdDataTemp=GuiWdData3;

break;

case 4:

GucDigShow8=4;

SinWdDataTemp=GuiWdData4;

break;

case 5:

GucDigShow8=5;

SinWdDataTemp=GuiWdData5;

break;

case 6:

GucDigShow8=6;

SinWdDataTemp=GuiWdData6;

break;

case 7:

GucDigShow8=7;

SinWdDataTemp=GuiWdData7;

break;

case 8:

GucDigShow8=8;

SinWdDataTemp=GuiWdData8;

break;

case 9:

GucDigShow8=9;

SinWdDataTemp=GuiWdData9;

break;

}

GucDigShow7=17;

GucDigShow6=16;

if(1==GucKey3Sr)

{

if(SinWdDataTemp>=10000)

{

GucDigShow5=SinWdDataTemp/10000;

}

else

{

GucDigShow5=16;

}

if(SinWdDataTemp>=1000)

{

GucDigShow4=SinWdDataTemp%10000/1000;

}

else

{

GucDigShow4=16;

}

if(SinWdDataTemp>=100)

{

GucDigShow3=SinWdDataTemp%1000/100;

}

else

{

GucDigShow3=16;

}

if(SinWdDataTemp>=10)

{

GucDigShow2=SinWdDataTemp%100/10;

}

else

{

GucDigShow2=16;

}

GucDigShow1=SinWdDataTemp%10;

}

else

{

GucDigShow5=16;

if(SinWdDataTemp>=0x1000)

{

GucDigShow4=SinWdDataTemp/0x1000;

}

else

{

GucDigShow4=16;

}

if(SinWdDataTemp>=0x0100)

{

GucDigShow3=SinWdDataTemp%0x1000/0x0100;

}

else

{

GucDigShow3=16;

}

if(SinWdDataTemp>=0x0010)

{

GucDigShow2=SinWdDataTemp%0x0100/0x0010;

}

else

{

GucDigShow2=16;

}

GucDigShow1=SinWdDataTemp%0x0010;

}

SucLedStatus16_09=SinWdDataTemp>>8;

SucLedStatus08_01=SinWdDataTemp;

hc595_drive(SucLedStatus16_09,SucLedStatus08_01);

}

}

void key_scan(void)

{

static unsigned int SuiKeyTimeCnt1=0;

static unsigned char SucKeyLock1=0;

static unsigned int SuiKeyTimeCnt2=0;

static unsigned char SucKeyLock2=0;

static unsigned int SuiKey3Cnt1=0;

static unsigned int SuiKey3Cnt2=0;

if(1==key_sr1)

{

SucKeyLock1=0;

SuiKeyTimeCnt1=0;

}

else if(0==SucKeyLock1)

{

SuiKeyTimeCnt1++;

if(SuiKeyTimeCnt1>const_key_time1)

{

SuiKeyTimeCnt1=0;

SucKeyLock1=1;

GucKeySec=1;

}

}

if(1==key_sr2)

{

SucKeyLock2=0;

SuiKeyTimeCnt2=0;

}

else if(0==SucKeyLock2)

{

SuiKeyTimeCnt2++;

if(SuiKeyTimeCnt2>const_key_time2)

{

SuiKeyTimeCnt2=0;

SucKeyLock2=1;

GucKeySec=2;

}

}

if(1==key_sr3)

{

SuiKey3Cnt1=0;

SuiKey3Cnt2++;

if(SuiKey3Cnt2>const_key_time3)

{

SuiKey3Cnt2=0;

GucKey3Sr=1;

}

}

else

{

SuiKey3Cnt2=0;

SuiKey3Cnt1++;

if(SuiKey3Cnt1>const_key_time3)

{

SuiKey3Cnt1=0;

GucKey3Sr=0;

}

}

}

void key_service(void)

{

static unsigned char SucKey3SrRecord=1;

if(GucKey3Sr!=SucKey3SrRecord)

{

SucKey3SrRecord=GucKey3Sr;

GucDisplayUpdate=1;

}

switch(GucKeySec)

{

case 1:

GucWd++;

if(GucWd>9)

{

GucWd=9;

}

GucDisplayUpdate=1;

GuiVoiceCnt=const_voice_short;

GucVoiceStart=1;

GucKeySec=0;

break;

case 2:

GucWd--;

if(GucWd>9)

{

GucWd=0;

}

GucDisplayUpdate=1;

GuiVoiceCnt=const_voice_short;

GucVoiceStart=1;

GucKeySec=0;

break;

}

}

void display_drive()

{

static unsigned char SucDigShowTemp=0;

static unsigned char SucDisplayDriveStep=1;

switch(SucDisplayDriveStep)

{

case 1:

SucDigShowTemp=dig_table

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top