新型会客系统设计.docx
- 文档编号:7804827
- 上传时间:2023-01-26
- 格式:DOCX
- 页数:33
- 大小:20.07KB
新型会客系统设计.docx
《新型会客系统设计.docx》由会员分享,可在线阅读,更多相关《新型会客系统设计.docx(33页珍藏版)》请在冰豆网上搜索。
新型会客系统设计
#include
#include
#defineucharunsignedchar
#defineuintunsignedint
sbitRS=P2^7;
sbitRW=P2^6;
sbitE=P2^5;
sbitSCLK=P2^4;
sbitINT=P2^3;
sbitSS=P2^2;
sbitMOSI=P2^1;
sbitMISO=P2^0;
sbitmod=P3^0;
sbitsp=P3^1;
sbitLED1=P3^2;
sbitLED2=P3^3;
sbits1=P3^5;
sbits2=P3^6;
sbits3=P3^4;
sbitPR=P3^4;
sbitAN=P3^5;
sbitGY=P3^7;
sbitdb1=P1^4;
sbitdb2=P1^5;
sbitdb3=P1^6;
sbitdb4=P1^7;
unsignedcharps[]={1,2,3,4,5};//程序中设好密码,更保险,防丢失,更不容易被破解。
unsignedchardispcount;
unsignedcharflashcount;
unsignedchartemp;
unsignedcharkey;
unsignedcharkeycount,keycount1;
unsignedcharpslen=5;
unsignedchargetps[6];
bitkeyoverflag;
biterrorflag;
bitrightflag;
unsignedintsecond3;
unsignedintaa,bb,cc;
bitokflag;
bitalarmflag;
bithibitflag;
unsignedcharoka,okb;
xdataucharcount,s1num,i,j;
bitkeyoverflag,errorflag,rightflag,okflag,alarmflag,hibitflag;
uintsecond3;
xdataucharcount,s1num;
//unsignedcharpslen=5,getps[6];
intmiao,shi,fen,ri,yue,miao1,shi1,fen1,ri1,yue1,ren1,ren2;
ucharcodetable2[]="访问:
有";
ucharcodetable3[]="人";
ucharcodetable4[]="留言:
第";
ucharcodetable5[]="条";
voiddelayms(uintz){uintx,y;for(x=z;x>0;x--)for(y=110;y>0;y--);}
voiddi(){LED1=0;delayms(100);LED1=1;}
voidwritecom(ucharcom){RS=0;E=0;RW=0;P0=com;delayms(5);E=1;delayms(5);E=0;}
voidwritedate(uchardate){RS=1;RW=0;E=0;P0=date;delayms(5);E=1;delayms(5);E=0;}
voidwritesfm(ucharadd,uchardate){ucharshi,ge;shi=date/10;ge=date%10;writecom(0x80+add);writedate(0x30+shi);writedate(0x30+ge);}
voidwritesfm1(ucharadd,uchardate){ucharshi,ge;shi=date/10;ge=date%10;writecom(0x98+add);writedate(0x30+shi);writedate(0x30+ge);}
voidwriteren1(ucharadd,uchardate){ucharshi,ge;shi=date/10;ge=date%10;writecom(0x90+add);writedate(0x30+shi);writedate(0x30+ge);}
voidwriteren2(ucharadd,uchardate){ucharshi,ge;shi=date/10;ge=date%10;writecom(0x88+add);writedate(0x30+shi);writedate(0x30+ge);}
voidinit(){ucharnum;E=0;fen=0;miao=0;shi=0;ri=1;yue=4;fen1=0;miao1=0;shi=0;ri1=1;yue1=4;ren1=0;ren2=0;count=0;s1num=0;writecom(0x30);writecom(0x0c);writecom(0x06);writecom(0x01);writecom(0x90);for(num=0;num<8;num++){writedate(table2[num]);delayms(5);}writecom(0x97);for(num=0;num<2;num++){writedate(table3[num]);delayms(5);}writecom(0x88);for(num=0;num<8;num++){writedate(table4[num]);delayms(5);}writecom(0x8f);for(num=0;num<2;num++){writedate(table5[num]);delayms(5);}writecom(0x84);writedate(':
');delayms(5);writecom(0x86);writedate(':
');delayms(5);writecom(0x9c);writedate(':
');delayms(5);writecom(0x9e);writedate(':
');delayms(5);writesfm(7,miao);writesfm(5,fen);writesfm(3,shi);writesfm(1,ri);writesfm(0,yue);writesfm1(7,miao1);writesfm1(5,fen1);writesfm1(3,shi1);writesfm1(1,ri1);writesfm1(0,yue1);writeren1(5,ren1);writeren2(5,ren2);TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;TR0=1;}
voiddelay(unsignedinttime){while(time!
=0){time--;}}
voidsend(unsignedcharisdx){unsignedcharcounter;SS=0;SCLK=0;for(counter=0;counter<8;counter++){if((isdx&0x01)==1)MOSI=1;elseMOSI=0;isdx=isdx>>1;SCLK=1;delay
(2);SCLK=0;delay
(2);}}
voidstop(){delay(10);send(0x30);SS=1;delayms(50);}
voidpowerup(){delay(10);SS=0;send(0x20);SS=1;delayms(50);}
voidstopwrdn(){delay(10);send(0x10);SS=1;delayms(50);}
voidplay(){send(0xf0);SS=1;}
voidrec(){send(0xb0);SS=1;}
voidmc(){stop();send(0xf8);SS=1;delayms(50);}
voidsetplay(unsignedcharadl,unsignedcharadh){delayms
(1);send(adl);delay
(2);send(adh);delay
(2);send(0xe0);SS=1;}
voidsetrec(unsignedcharadl,unsignedcharadh){delayms
(1);send(adl);delay
(2);send(adh);delay
(2);send(0xa0);SS=1;}
unsignedcharchk_ovf(){SS=0;delay
(2);SCLK=0;delay
(2);SCLK=1;SCLK=0;delay
(2);if(MISO==1){SCLK=0;SS=1;stop();return1;}else{SCLK=0;SS=1;stop();return0;}}
voidrecord(unsignedcharadl,unsignedcharadh){while(s2==1){;}if(s2==0){powerup();stopwrdn();powerup();LED1=0;delayms(500);setrec(adl,adh);rec();while(s2==0){;}if(INT==0)return;LED1=1;stop();}}
voidaudio(unsignedcharadl,unsignedcharadh){unsignedcharovflog;while(s3==1){;}if(s3==0){powerup();stopwrdn();powerup();LED1=1;while(s3==0){;}setplay(adl,adh);play();delay(20);while(INT==1){;}}LED1=1;stop();if(ovflog=chk_ovf())return;}
voidautoaudio(unsignedcharadl,unsignedcharadh){unsignedcharovflog;powerup();stopwrdn();powerup();LED1=1;setplay(adl,adh);play();delay(20);while(INT==1){;}/*LED=1;*/stop();if(ovflog=chk_ovf())return;}
uintad(){uinty,newaddr;SS=0;MOSI=0;SCLK=0;for(y=0;y<8;y++){SCLK=0;if((0x20>>y)&0x01)MOSI=1;elseMOSI=0;_nop_();_nop_();_nop_();SCLK=1;_nop_();_nop_();_nop_();}SS=1;delayms(50);SS=0;MOSI=0;SCLK=0;for(y=0;y<16;y++){SCLK=1;_nop_();SCLK=0;_nop_();_nop_();if(MISO==0)newaddr&=0x7fff;elsenewaddr|=0x8000;newaddr>>=1;_nop_();_nop_();_nop_();}SS=1;return(newaddr);}
ucharrec3(uintadd){uinty;SS=0;MOSI=0;SCLK=0;for(y=0;y<8;y++){SCLK=0;if((0x20>>y)&0x01)MOSI=1;elseMOSI=0;_nop_();_nop_();_nop_();SCLK=1;_nop_();_nop_();_nop_();}SS=1;delayms(50);SS=0;MOSI=0;SCLK=0;for(y=0;y<16;y++){SCLK=0;if((add>>y)&0x01)MOSI=1;elseMOSI=0;_nop_();_nop_();_nop_();SCLK=1;_nop_();_nop_();_nop_();}MOSI=0;SCLK=0;for(y=0;y<8;y++){SCLK=0;if((0xa0>>y)&0x01)MOSI=1;elseMOSI=0;_nop_();_nop_();_nop_();SCLK=1;_nop_();_nop_();_nop_();}SS=1;return
(2);}
ucharplay1(uintadd){uinty;SS=0;MOSI=0;SCLK=0;for(y=0;y<8;y++){SCLK=0;if((0x20>>y)&0x01)MOSI=1;elseMOSI=0;_nop_();_nop_();_nop_();SCLK=1;_nop_();_nop_();_nop_();}SS=1;delayms(50);SS=0;MOSI=0;SCLK=0;for(y=0;y<16;y++){SCLK=0;if((add>>y)&0x01)MOSI=1;elseMOSI=0;_nop_();_nop_();_nop_();SCLK=1;_nop_();_nop_();_nop_();}MOSI=0;SCLK=0;for(y=0;y<8;y++){SCLK=0;if((0xe0>>y)&0x01)MOSI=1;elseMOSI=0;_nop_();_nop_();_nop_();SCLK=1;_nop_();_nop_();_nop_();}SS=1;return
(1);}
voidmain(void)
{
ucharren1=0,ren2=0,modnum=0;uinti,add0,add1,addrec,add=0;
xdatainta[20],b[20],c[20],d[20],e[20],f[20];
init();
P1=0Xff;
P3=0x7f;
while
(1)
{
if(GY==1)
{
delayms(15);
if(GY==1)
{
autoaudio(0x00,0x04);
while(GY==1)
{
if(key==12){
if(keycount>0)
{
keycount--;
getps[keycount]=0;
}
key=19;
autoaudio(0x93,0x04);}
if(key==10)//A不一定要在GY里面.不能用while(GY==1)循环,因为键盘要实时扫描,需要下面的扫描程序。
{
autoaudio(0x28,0x04);
if(keycount>0)
{
keycount--;
getps[keycount]=0;
}
key=16;
}
if(key==11)//B
{
key=17;
ren1++;
i=ren1;
b[i]=miao;
c[i]=fen;
d[i]=shi;
e[i]=ri;
f[i]=yue;
writeren1(5,ren1);
writecom(0x95);
autoaudio(0x59,0x04);
if(ren1==1)addrec=0;
LED1=0;
rec3(addrec);
delayms(3000);
LED1=1;
stop();
for(i=0;i<3;i++)
{
if(s1==0)
gotoc;
autoaudio(0x66,0x04);
delayms(50);
play1(addrec);
while(INT==1){;}
}
add0=ad();
addrec=add0-1;
LED1=1;
autoaudio(0x73,0x04);
while(s1==1);
delayms(15);
while(s1==1);
while(s1==0);
delayms(15);
while(s1==0);
LED1=0;
rec3(addrec);
while(s1==1);
delayms(15);
while(s1==1);
LED1=1;
stop();
add1=ad();
addrec=add1+1;
i=ren1;
a[i]=addrec;
autoaudio(0x83,0x04);
//delayms(10000);
//while(GY==1);
}
P1=0xef;
temp=P1;
temp=temp&0x0f;
if(temp!
=0x0f)
{
for(i=10;i>0;i--)
for(j=248;j>0;j--);
temp=P1;
temp=temp&0x0f;
if(temp!
=0x0f)
{
temp=P1;
temp=temp&0x0f;
switch(temp)
{
case0x0e:
key=1;break;
case0x0d:
key=4;break;
case0x0b:
key=7;break;
case0x07:
key=14;break;
}
temp=P1;
LED1=~LED1;//P1.0?
?
?
if((key>=0)&&(key<10))
{
if(keycount<6)
{
getps[keycount]=key;
//dispbuf[keycount+2]=19;//全显8.
}
keycount++;
if(keycount==6)
{
keycount=6;
}
elseif(keycount>6)
{
keycount=6;
keyoverflag=1;//keyoverflow
}
}
elseif(key==14)//重新输入
{
if(keycount>0)
{
keycount1=keycount;
for(i=0;i { keycount--; getps[keycount]=0; } } } elseif(key==15)//enterkey { if(keycount! =pslen) { LED1=0; autoaudio(0x40,0x04);//对不起,密码错误,请重新输入 LED1=1; errorflag=1; rightflag=0; second3=0; } else { for(i=0;i { if(getps[i]! =ps[i]) { i=keycount;//直接给密码个数。 让其立刻跳出for语句。 LED1=0; autoaudio(0x40,0x04);//对不起,密码错误,请重新输入 LED1=1; errorflag=1; rightflag=0; second3=0; gotoa; } } for(i=0;i<3;i++) { LED2=0; autoaudio(0x38,0x04);//您好,请进 delayms(1000); } LED2=1; errorflag=0; rightflag=1; a: i=keycount;//? } } temp=temp&0x0f; while(temp! =0x0f) { temp=P1; temp=temp&0x0f; } keyoverflag=0; } } P1=0xdf; temp=P1; temp=temp&0x0f; if(temp! =0x0f) { for(i=10;i>0;i--) for(j=248;j>0;j--); temp=P1; temp=temp&0x0f; if(temp! =0x0f) { temp=P1; temp=temp&0x0f; switch(temp) { case0x0e: key=2;break; case0x0d: key=5;break; case0x0b: key=8;break; case0x07: key=0;break; } temp=P1; LED1=~LED1; if((key>=0)&&(key<10)) { if(keycount<6) { getps[keycount]=key; //dispbuf[keycount+2]=19; } keycount++; if(keycount==6) { keycount=6; } elseif(keycount>6) { keycount=6; keyoverflag=1;//keyoverflow } } elseif(key==14)//deletekey { if(keycount>0) { keycount--; getps[keycount]=0; //dispbuf[keycount+2]=16; } else { keyoverflag=1; } } elseif(key==15)//enterkey { if(keycount! =pslen) { LED1=0; LED1=0; autoaudio(0x40,0x04);//对不起,密码错误,请重新输入 LED1=1; LED1=1; errorflag=1; rightflag=0; second3=0; } else { for(i=0;i
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 新型 会客 系统 设计