第10节:一个用来学习C语言的模板程序
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[GucDigShow1];
dig_hc595_drive(SucDigShowTemp,0xfe);
break;
case 2:
SucDigShowTemp=dig_table[GucDigShow2];
dig_hc595_drive(SucDigShowTemp,0xfd);
break;
case 3:
SucDigShowTemp=dig_table[GucDigShow3];
dig_hc595_drive(SucDigShowTemp,0xfb);
break;
case 4:
SucDigShowTemp=dig_table[GucDigShow4];
dig_hc595_drive(SucDigShowTemp,0xf7);
break;
case 5:
SucDigShowTemp=dig_table[GucDigShow5];
dig_hc595_drive(SucDigShowTemp,0xef);
break;
case 6:
SucDigShowTemp=dig_table[GucDigShow6];
dig_hc595_drive(SucDigShowTemp,0xdf);
break;
case 7:
SucDigShowTemp=dig_table[GucDigShow7];
dig_hc595_drive(SucDigShowTemp,0xbf);
break;
case 8:
SucDigShowTemp=dig_table[GucDigShow8];
dig_hc595_drive(SucDigShowTemp,0x7f);
break;
}
SucDisplayDriveStep++;
if(SucDisplayDriveStep>8)
{
SucDisplayDriveStep=1;
}
}
void dig_hc595_drive(unsigned char ucDigStatusTemp16_09,unsigned char ucDigStatusTemp08_01)
{
unsigned char i;
unsigned char ucTempData;
dig_hc595_sh_dr=0;
dig_hc595_st_dr=0;
ucTempData=ucDigStatusTemp16_09;
for(i=0;i<8;i++)
{
if(ucTempData>=0x80)dig_hc595_ds_dr=1;
else dig_hc595_ds_dr=0;
dig_hc595_sh_dr=0;
delay_short(1);
dig_hc595_sh_dr=1;
delay_short(1);
ucTempData=ucTempData<1;
}
ucTempData=ucDigStatusTemp08_01;
for(i=0;i<8;i++)
{
if(ucTempData>=0x80)dig_hc595_ds_dr=1;
else
C语言模板程序单片 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)