1、); write_com(0x80); while(1) while(key_scan()=0xff); TR0=1; if(first=0) first=1; write_com(0x01); Key_num=key_scan(); switch(key_scan() case 1: if(last_key_num!=Key_num) write_Dat(ln ln=1; break; case 2:si Sin=1; case 3:co Cos=1; case 4:ta Tan=1; case 5: flag=5; case 6:write_Dat(7num=7;break; case 7
2、:8num=8; case 8:9num=9; case 9:+ flag=1; case 10:T flag=6; case 11:4num=4; case 12:5num=5; case 13:6num=6; case 14:- flag=2; case 15: if(equal_flag=1) write_com(0x01); write_com(0x80); write_Dat(A= save_result=result; else if(Key_num!=1&Key_num!=2&=3&=4&=22&=23&=25) write_Dat( if(flag=0) num1=save_r
3、esult; first_num=1; else num2=save_result; second_num=1; break; case 16:1num=1; case 17:2num=2; case 18:3num=3; case 19:* flag=3; case 21:num=0; case 22: if(flag=0) minus1+; if(minus1=1) minus2+; if(minus2=1) break; case 23: dot1+; if(dot1=1). dot2+; if(dot2=1) case 24: if(last_key_num!/ flag=4; cas
4、e 25: write_Dat( equal_flag=1; break; if(Key_num!=15&=25) /第一个数 if(flag=0) num1=num1*10+num; num=0; if(dot1!=0) dot1_num+; first_num=1; if(flag! num2=num2*10+num; if(dot2! dot2_num+; second_num=1; if(equal_flag=1&first_num=1) if(dot1! num1=num1/pow(10,dot1_num); dot1=0; if(dot2! num2=num2/pow(10,dot
5、2_num); dot2=0; if(minus1! num1=num1*(-1); if(minus2! num2=num2*(-1); if(second_num! switch(flag) case 1:result=num1+num2; case 2:result=num1-num2; case 3:result=num1*num2; case 4: if(num2! result=num1/num2; else write_com(0x80+0x40+10); for(i=0;i0) result=log(num1)+0.005; write_com(0x80+0x40+10); f
6、or(i=0; write_Dat(table2i); error=1; if(error!=1) display(result); if(Key_num=20) /清零 num1=num2=result=0; flag=equal_flag=0; error=0;first=0; dot1_num=dot2_num=0; minus1=0;minus2=0; first_num=0,second_num=0; Sin=Cos=Tan=ln=0; write_com(0x80+0x40+15); write_Dat( last_key_num=Key_num; while(key_scan()
7、!=0xff); void time0() interrupt 1 TH0=(65536-600)/256; TL0=(65536-600)%256; count+; speek=!speek; if(count50) TR0=0; count=0;void delay(uint x) uchar y; while(x-) for(y=0;y120;y+);void write_com(unsigned char c) RS=0; RW=0; EN=1; delay(5); P0=c; EN=0;void write_Dat(unsigned char c) RS=1;void InitLcd
8、()write_com(0x38); /display mode write_com(0x06); /显示光标移动位置 write_com(0x0c); /显示开及光标设置 write_com(0x01); /显示清屏uchar key_scan() uchar key_num=0xff; uint temp; P3=0x03; P1=0xe0; temp=(P38)|P1; if(temp&0x03e0)!=0x03e0) delay(10); if(temp& P3=0x03; /第一行 P1=0xfe; temp=(P3 switch(temp) case 0x03de:key_num=
9、1; break; case 0x03be:key_num=2; case 0x037e:key_num=3; case 0x02fe:key_num=4; case 0x01fe:key_num=5; /第二行 P1=0xfd; case 0x03dd:key_num=6; case 0x03bd:key_num=7; case 0x037d:key_num=8; case 0x02fd:key_num=9; case 0x01fd:key_num=10; /第三行 P1=0xfb; case 0x03db:key_num=11; case 0x03bb:key_num=12; case 0
10、x037b:key_num=13; case 0x02fb:key_num=14; case 0x01fb:key_num=15; /第四行 P1=0xf7; case 0x03d7:key_num=16; case 0x03b7:key_num=17; case 0x0377:key_num=18; case 0x02f7:key_num=19; case 0x01f7:key_num=20; /第五行 P1=0xef; case 0x03cf:key_num=21; case 0x03af:key_num=22; case 0x036f:key_num=23; case 0x02ef:ke
11、y_num=24; case 0x01ef:key_num=25; return key_num;void display(double Data) uchar xs=0,fs=0,i; if(Data(long)Data) xs=1;10) /09 if(xs=1) Data=Data*100; write_com(0x80+0x40+11); if(fs=1) else write_Dat(long)Data/100+ write_Dat(long)Data/10%10+ write_Dat(long)Data%10+ else if(xs=0) write_com(0x80+0x40+14); write_Dat(long)Data+ else if(Data100) /1099 write_com(0x80+0x40+10); write_Dat(long)Data/1000+ write_Dat(long)Data/100%10+ write_com(0x80+0x40+13); write_Dat(long)Data/10+1000) /100999 write_com(0x80+0x40+9); write_Dat(long)Data/10000+ write_Dat(long)Data/1000%10 + write_com(0x80+0x40+12); els
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1