#includereg52.h>#define uchar unsigned char#define uint unsigned int#define ulint unsigned long intulint m=0,m1=0;ulint m2;uchar xdata flag=1,flag1=1,flag2=0,flag3=0,flag4=0,flag5=0;uchar flag6=0,flag7=0,flag8;uchar data Mi0,Mi,Mi1,Mi2,Mi3,Mi4,Mi5,num,temp,key1,k,j=0,j1=0;sbit rs=P2^6;sbit rw=P2^5;sbit en=P2^7;sbit psb=P2^2;uchar dat_Shuru_1[8]={0,0,0,0,0,0,0,0};uchar dat_Shuru_2[8]={0,0,0,0,0,0,0,0};uchar data table_Ts_1[]="15:運(yùn)算輸入!14:確定輸入!13:重輸輸入!12:返回輸入!輸入:結(jié)果:";void delay(uchar z){uchar x,y;for(x=z;x>0;x--)for(y=110;y>0;y--);}uchar key(){P3=0xfe;temp=P3;temp=temp0xf0;while(temp!=0xf0){delay(10);temp=P3;temp=temp0xf0;while(temp!=0xf0){temp=P3;switch(temp){case 0xee:num=0;Mi=1;break;case 0xde:num=1;Mi=1;break;case 0xbe:num=2;Mi=1;break;case 0x7e:num=3;Mi=1;break;}while(temp!=0xf0){temp=P3;temp=temp0xf0;// k=0;}}}P3=0xfd;temp=P3;temp=temp0xf0;while(temp!=0xf0){delay(10);temp=P3;temp=temp0xf0;while(temp!=0xf0){temp=P3;switch(temp){case 0xed:num=4;Mi=1;break;case 0xdd:num=5;Mi=1;break;case 0xbd:num=6;Mi=1;break;case 0x7d:num=7;Mi=1;break;}while(temp!=0xf0){temp=P3;temp=temp0xf0;}}}P3=0xfb;temp=P3;temp=temp0xf0;while(temp!=0xf0){delay(10);temp=P3;temp=temp0xf0;while(temp!=0xf0){temp=P3;switch(temp){case 0xeb:num=8;Mi=1;break;case 0xdb:num=9;Mi1=1;Mi0=1;break;case 0xbb:num=10;Mi1=1;Mi2=1;break;case 0x7b:num=11;Mi1=1;Mi3=1;break;}// k=1;while(temp!=0xf0){temp=P3;temp=temp0xf0;}}}P3=0xf7;temp=P3;temp=temp0xf0;while(temp!=0xf0){delay(10);temp=P3;temp=temp0xf0;while(temp!=0xf0){temp=P3;switch(temp){case 0xe7:num=12;Mi1=1;Mi4=1;break;case 0xd7:num=13;Mi1=1;Mi5=1;break;case 0xb7:num=14;Mi1=1;break;case 0x77:num=15;Mi1=1;break;}// k=1;while(temp!=0xf0){temp=P3;temp=temp0xf0;}}}return num;}void write_com(uchar com){rs=0;rw=0;P0=com;delay(5);en=1;delay(5);en=0;}void write_data(uchar dat){rs=1;rw=0;P0=dat;delay(5);en=1;delay(5);en=0;}void write_Yunsuan(uchar add,ulint Jg){uchar xdata gw,sw,bw,qw,ww,ws,wb,wq;{gw=Jg%10;sw=Jg/10%10;bw=Jg/100%10;qw=Jg/1000%10;ww=Jg/10000%10;ws=Jg/100000%10;wb=Jg/1000000%10;wq=Jg/10000000%10;write_com(0x88+add);if(wq!=0){write_data(0x30+wq);}if(wq!=0||wb!=0){write_data(0x30+wb);}if(wq!=0||wb!=0||ws!=0){write_data(0x30+ws);}if(wq!=0||wb!=0||ws!=0||ww!=0){write_data(0x30+ww);}if(wq!=0||wb!=0||ws!=0||ww!=0||qw!=0){write_data(0x30+qw);}if(wq!=0||wb!=0||ws!=0||ww!=0||qw!=0||bw!=0){write_data(0x30+bw);}if(wq!=0||wb!=0||ws!=0||ww!=0||qw!=0||bw!=0||sw!=0){write_data(0x30+sw);} write_data(0x30+gw);}}void Tishi_Huanying(uchar add,uchar i1,uchar i2){uchar i;write_com(add);for(i=i1;ii2;i++){write_data(table_Ts_1[i]);}}void write_Xianshi_Shuru_1(uchar add){uchar i;write_com(0x80+add);for(i=0;ij;i++){write_data(0x30+dat_Shuru_1[i]);}}void write_Xianshi_Shuru_2(uchar add){uchar i;write_com(0x90+add);for(i=0;ij1;i++){write_data(0x30+dat_Shuru_2[i]);}}void enter_Shuru_1(){//key1=key();if(key19Mi==1){dat_Shuru_1[j]=key1;j++;Mi=0;m=m*10+dat_Shuru_1[j-1]; }write_Xianshi_Shuru_1(0x03);}void enter_Shuru_2(){//key1=key();if(key19Mi==1){dat_Shuru_2[j1]=key1;j1++;Mi=0;m1=m1*10+dat_Shuru_2[j1-1]; }write_Xianshi_Shuru_2(0x03);}void Xianshi_Jiafa(){if(flag3==1Mi5==1){write_com(0x01);Tishi_Huanying(0x80,52,58);enter_Shuru_1();Tishi_Huanying(0x90,52,58);Tishi_Huanying(0x88,58,64);m2=m+m1;Mi5=0;m=m2;}write_Yunsuan(0x03,m2);}void Xianshi_Qianfa(){if(flag4==1Mi4==1){ write_com(0x01);Tishi_Huanying(0x80,52,58);enter_Shuru_1();Tishi_Huanying(0x90,52,58);Tishi_Huanying(0x88,58,64);m2=m-m1;Mi4=0;m=m2;}write_Yunsuan(0x03,m2);}void Xianshi_Shengfa(){if(flag5==1Mi3==1){write_com(0x01);Tishi_Huanying(0x80,52,58);enter_Shuru_1();Tishi_Huanying(0x90,52,58);Tishi_Huanying(0x88,58,64);m2=m*m1;Mi3=0;m=m2;}write_Yunsuan(0x03,m2);}void Xianshi_Chufa(){if(flag6==1Mi2==1){write_com(0x01);enter_Shuru_1();Tishi_Huanying(0x80,52,58);Tishi_Huanying(0x90,52,58);Tishi_Huanying(0x88,58,64);m2=m/m1;Mi2=0;m=m2;}write_Yunsuan(0x03,m2);}void init(){psb=1;write_com(0x30);write_com(0x0e);write_com(0x01);write_com(0x80);}void Huanyingjiemian(){Tishi_Huanying(0x80,0,13);Tishi_Huanying(0x90,13,26);Tishi_Huanying(0x88,26,39);Tishi_Huanying(0x98,39,52);}void Anjian(){key1=key();if(key1==15Mi1==1){flag1=0;Mi1=0;}if(flag1==0){if(key1==14Mi1==1){flag2=1;//flag3=1;Mi1=0;}if(key1==13Mi1==1){flag3=1;Mi1=0;}if(key1==12Mi1==1){flag4=1;Mi1=0;}if(key1==11Mi1==1){flag5=1;Mi1=0;}if(key1==10Mi1==1){flag6=1;Mi1=0;}if(key1==9Mi1==1){flag8=1;Mi1=0;}}}void main(){init();while(1){Anjian();if(flag8==1Mi0==1){write_com(0x01);flag8=0; m=0;Mi0=0;m1=0;m2=0;j=0;j1=0;flag=1;flag1=1;flag2=0;flag3=0;flag4=0;flag5=0;flag6=0;flag7=0;//flag8=0;}if(flag==1flag1==1){Huanyingjiemian();}if(flag==1flag1==0){write_com(0x01);flag=0;}if(flag==0flag1==0){ if(flag7==0){Tishi_Huanying(0x80,52,58); enter_Shuru_1();}if(flag7==1){ Tishi_Huanying(0x90,52,58);enter_Shuru_2();if(flag3==1){Xianshi_Jiafa();}if(flag4==1){Xianshi_Qianfa();}if(flag5==1){Xianshi_Shengfa();}if(flag6==1){Xianshi_Chufa();}}}if(flag2==1){flag2=0;flag7=1; //flag4=1;}} }
評(píng)論