_nop_(); e=1; _nop_(); _nop_(); e=0; }
/************向液晶片写数据***************/ void lcd_wrdata( uchar lcddata) {
while(lcd_busy()); lcd_bus=lcddata; rs=1; rw=0; _nop_(); e=1; _nop_(); _nop_(); e=0; }
void lcd_ini(void) {
lcd_wrcmd(0x38); delay(100);
lcd_wrcmd(0x0c); delay(100);
lcd_wrcmd(0x06); delay(100);
lcd_wrcmd(0x01); delay(100); }
uchar key() {
uchar keycode=0xff,temp,i; key_bus=0x0f; temp=key_bus&0x0f;
if(temp!=0x0f) //有键按下 { key_bus=0x7f; for(i=0;i<4;i++) { temp=key_bus&0x0f; if(temp==0x07) { keycode=i*4; break; } else if(temp==0x0b) { keycode=i*4+1; break; }
else if(temp==0x0d) { keycode=i*4+2; break; }
else if(temp==0x0e) { keycode=i*4+3; break; } key_bus=(key_bus>>1)|0x80; } while((key_bus&0x0f)!=0x0f) //等待释放 { key_bus=0x0f; } } return keycode; }
void display(uchar cmd,uchar code *str) {
uchar i=0; lcd_wrcmd(cmd);
while(str[i]!='\\0') { lcd_wrdata(str[i]); i++; } }
main() {
uint i; uchar tt;
uchar code str[]=\ en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=Rom[i]; ce=1; lcd_ini();
temp = sin1[1]; lcd_wrcmd(0xc0); lcd_wrdata(0x30+temp/100); lcd_wrdata(0x30+temp/10); lcd_wrdata(0x30+temp); temp=sin1[44]; lcd_wrcmd(0xc4); lcd_wrdata(0x30+temp/100); lcd_wrdata(0x30+temp/10); lcd_wrdata(0x30+temp); display(0x80,str); en=1; while(1) { tt=key(); if(tt==0) { en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=Rom1[i]; ce=1;en=1; } else if(tt==1) { en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=Rom[i]; ce=1; en=1;
} else if(tt==2) { en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=(Rom[i]/2+Rom1[i]/2); ce=1; en=1; } else if(tt==3) { en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=Rom[i]*Rom1[i]; ce=1; en=1; } else if(tt==4) { en=0;ce=0; for(i=0;i<2048;i++) sin1[i]=Rom[i]-Rom1[i]; ce=1; en=1; } } }