版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、一個實際使用的LCD漢字顯示多屏多層菜單#include #include #include #define INPUTSET256; #define DEBUG 0 /0:運行,1:調(diào)試 #define ENABLE_INTERRUPT 1/1:中斷允許,0:中斷禁止 /定義8155地址 #define I8155A0x7000 #define I8155B0x7200 #definePA1 #define PB2 #define PC3 /定義25045地址 #define OUTNUMBER 0x01a1 #define INNUMBER 0x01a2
2、 #define PASSWORD_ADDR 0x01a3 #define HIDE_PASSWORD_ADDR 0x01af /定義鍵盤掃描碼 #defineBUTTON_START0x28 #define BUTTON_STOP0x48 #define BUTTON_SET0x84 #define BUTTON_OK0x88 #define BUTTON_SLAVE0x81 /0,1,2,3,4,5,6,7,8,9 unsigned char code keyscancode=0x82,0x11,0x12,0x14,0x21,0x22,0x24,0x41,0x42,0x44; #inclu
3、de #include /new var unsigned char bdata bitvar; sbit keypush=bitvar0; sbit rrtime_flag=bitvar1;/讀取運行參數(shù)標志 sbit showflag=bitvar2; unsigned char keycode,tempkey,i,j; unsigned char menuitem=0x00; unsigned int runtime32; unsigned int xdata starttime36; unsigned int xdata stoptime32; unsigned int x
4、data betweentime32; unsigned char xdata runno136; unsigned char xdata linkrun4; unsigned char xdata linkrunno14; unsigned char xdata submenuitem=0; unsigned long xdata i8155out; unsigned char xdata main_temp,outputnumber,inputnumber; unsigned int xdata tempvar9; char xdata showstr5="
5、; " /new var end /定義DS12887地址 #define P12887SEC 0x7f00/12887秒地址 #define P12887SEC_ALM 0x7f01/12887秒報警地址 #define P12887MIN 0x7f02/12887分地址 #define P12887MIN_ALM 0x7f03/12
6、887分報警地址 #define P12887HOUR 0x7f04/12887時地址 #define P12887HOUR_ALM 0x7f05/12887時報警地址 #define P12887WEEK 0x7f06/12887星期地址 #define P12887DAY 0x7f07/12887日期地址 #define P12887MONTH
7、; 0x7f08/12887月地址 #define P12887YEAR 0x7f09/12887年地址 #define P12887MCA 0x7f0a/寄存器a地址 #define P12887MCB 0x7f0b/寄存器a地址 #define P12887MCC 0x7f0c/寄存器a地址 #
8、define P12887MCD 0x7f0d/寄存器a地址 #define P12887RAM 0x7f0e/12887不掉電RAM起始地址 void init_12887();
9、 /DS12887初始化程序 void gettime_12887(); /取DS12887時間子程序(年月日時分) void settime_12887(); /設置DS12887時間子程序 void i8155_
10、init(unsigned int memaddress,unsigned char command); /intel 8155 端口輸出 /memaddress:8155基址; /portnum:端口號(1:PA、2:PB、3:PC) /portstatu:端口輸出字 void i8155_outport(unsigned int memaddress,unsigned char portnum,unsigned char portstatu); /intel 8155 端口輸入 /memaddress:8155基址; /portnum:端口號(1:PA、2:PB、3:PC) /返回值:端口
11、狀態(tài) unsigned char i8155_inport(unsigned int memaddress,unsigned char portnum); void showinitscreen(); void init(); void timer0() interrupt 1 using 1 unsigned char temp; /晶振為 11.0592MHZ 時計數(shù) 9216(0xdb00) 次為 10ms TH0=0xd8; TL0=0x00; temp=(XBYTE0x7e00&0x0f);/有鍵按下時 !=0x0f if(temp!=0x0f)/是否有鍵按下 if(keyp
12、ush=1) keycode=temp; if(XBYTE0x7ee0&0x0f)!=0x0f) keycode=keycode&0x1f; else if(XBYTE0x7ed0&0x0f)!=0x0f) keycode=keycode&0x2f; else if(XBYTE0x7eb0&0x0f)!=0x0f) keycode=keycode&0x4f; else if(XBYTE0x7e30&0x0f)!=0x0f) keycode=keycode&0x8f; else keypush=1; keycode=0; else
13、keypush=0; void ds12887_int1() interrupt 2 using 2 rrtime_flag=0; ACC=XBYTEP12887MCC; /讀寄存器C 清除中斷請求標志IRQF /* / /主程序 / /* void main() i8155out=0x00; x25045_disable(); outputnumber=x25045_readbyte(OUTNUMBER); for(i=0;i runtime=(int)0x00; runn
14、o1=0x00; starttime=x25045_readword(i*7); stoptime=x25045_readword(i*7+2); betweentime=x25045_readword(i*7+4); x25045_init(); init(); TH0=0xd8; TL0=0x00; /初始化變量 while(1) init_12887(); /* #if DEBUG x25045_disable(); #else x25045_init(); #endif /* TMOD=0x01; ET0=1; TR0=1; #if ENABLE_INTERRUPT EX1=1; PX
15、1=1; PT0=0; #endif EA=1; /* /加入限時運行功能 if(x25045_readbyte(0x01bb)=1)&&(menuitem!=0x20)&&(menuitem!=0x1b) tempkey=0; gettime_12887(); for(i=0;i<3;i+) if(tempvar<=x25045_readbyte(0x01b5-3+i) tempkey+; else break; if(tempkey<3) if(menuitem!=0x20) showflag=0; menuitem=0x20; else
16、menuitem=0; tempkey=0x50; i=0; /* /主循環(huán)開始 tm12864_reset(); x25045_resetwatchdog(); /鍵盤處理程序 if(keycode!=0)&&(keypush=0) i=0; while(i<10) if(keycode=keyscancode) tempkey=i; br
17、eak; else tempkey=keycode; i+; else tempkey=0x50; keycode=0; /屏幕顯示處理 switch(menuitem)
18、 case 0x00:/自動運行狀態(tài) tm12864_reset(); if(showflag=0) tm12864_fillscreen(0x00); showflag=1; showinitscreen(); tm12864_writestr(0,0," ",0); tm12864_writestr(12,0," ",0); tm12864_writestr(0,4,"
19、 ",0); tm12864_writestr(0,6," ",0); tm12864_writehz(4,6,zzyx,0); tm12864_writestr(12,6," ",0); if(tempkey=BUTTON_STOP)/進入“設置確認”菜單 j=0; menuitem=0x01; showf
20、lag=0; tempkey=0x50; break; case 0x01:/設置確認菜單 tm12864_reset(); if(showflag=0) tm12864_fillscreen(0x00); tm12864_writestr(4,6," ",1); tm12864_writehz(0,6,mm,0)
21、; showflag=1; showinitscreen(); if(j<6)&&(tempkey<0x0a) tm12864_writehz(0,6,mm,0); tm12864_writestr(j+4),6,"*",1); tempvarj=tempkey; j+; if(j=6) for(j=0;j<6;j+) if(tempvarj!=x25045_readbyte(PASSWORD_ADDR+j) j=0; showflag=0; menuitem=0x00; break; tm12864_writestr(0,6,"
22、 ",0); tm12864_writestr(6,6," ",0); tm12864_writehz(2,6,set,1); tm12864_writehz(10,6,yunxing,0); if(tempkey=BUTTON_OK) menuitem=0x03; j=0; submenuitem
23、=0; showflag=0; tempvar0=1; submenuitem=0; if(tempkey=BUTTON_START)
24、0; menuitem=0x00; showflag=0; tempkey=0x50; break; case 0x02:/運行確認菜單 tm12864_reset(); if(showflag=0) tm12864_fill
25、screen(0x00); showflag=1; showinitscreen(); switch(submenuitem) case 0x00: tm12864_writehz(2,6,set,0); tm12864_writehz(10,6,yunxing,1); switch(tempkey) case BUTTON_OK: menuitem=0x00; showflag=0; while(1); brea
26、k; case BUTTON_STOP: case BUTTON_SLAVE: submenuitem=0x01; showflag=0; break; break; case 0x01: tm12864_writehz(2,6,set,1); tm12864_writehz(10,6,yunxing,0); switch(tempkey) case BUTTON_OK: menuitem=0x03;
27、 showflag=0; submenuitem=0x00; break; case BUTTON_START: case BUTTON_SLAVE: submenuitem=0; showflag=0; break; break; tempkey=0x50; break;
28、160; case 0x03:/設置菜單 tm12864_reset(); if(showflag=0) tm12864_fillscreen(0x00); showflag=1; j=0; x25045_writestatu(0x00); / * /加入隱蔽菜單功能 if(j<6)&&(tempkey<0
29、x0a) tempvarj=tempkey; j+; showstr0=j+0x30; showstr1='0' tm12864_writestr(15,7,showstr,0); tempkey=0x50; if(j=6) for(j=0;j<6;j+) #if DEBUG tempvarj=x25045_readbyte(0x01a9+j); #else if(tempvarj!=x25045_readbyte(0x01a9+j) j=0; break; #endif if(tempkey=BU
30、TTON_SET) menuitem=0x1b; j=0; submenuitem=0; showflag=0; tempvar0=1;
31、60; / * switch(submenuitem) case 0x00: tm12864_writestr(0,0,"1 ",1); tm12864_writehz(2,0,scsd,1); tm12864_writestr(0,2,"2 ",0);
32、tm12864_writehz(2,2,srsd,0); tm12864_writestr(0,4,"3 ",0); tm12864_writehz(2,4,lssd,0); tm12864_writestr(0,6,"4 ",0); tm12864_writehz(2,6,xtcs,0); break; case 0x01: tm12864_writestr(0,0,&qu
33、ot;1 ",0); tm12864_writehz(2,0,scsd,0); tm12864_writestr(0,2,"2 ",1); tm12864_writehz(2,2,srsd,1); tm12864_writestr(0,4,"3 ",0); tm12864_writehz(2,4,lssd,0); tm12864_writestr(0,6,"4 ",0);
34、 tm12864_writehz(2,6,xtcs,0); break; case 0x02: tm12864_writestr(0,0,"1 ",0); tm12864_writehz(2,0,scsd,0); tm12864_writestr(0,2,"2 ",0); tm12864_writehz(2,2,srsd,0); tm12864_wr
35、itestr(0,4,"3 ",1); tm12864_writehz(2,4,lssd,1); tm12864_writestr(0,6,"4 ",0); tm12864_writehz(2,6,xtcs,0); break; case 0x03: tm12864_writestr(0,0,"1 ",0); tm12864_writehz(2,0,scs
36、d,0); tm12864_writestr(0,2,"2 ",0); tm12864_writehz(2,2,srsd,0); tm12864_writestr(0,4,"3 ",0); tm12864_writehz(2,4,lssd,0); tm12864_writestr(0,6,"4 ",1); tm12864_writehz(2,6,xtcs,1);
37、60; break; switch(tempkey) case BUTTON_START: menuitem=0x02; submenuitem=0; showflag=0; break; case BUTTON_SLAVE: if(submenuitem<0x03) submen
38、uitem+; else submenuitem=0x00; break; case BUTTON_OK: menuitem=0x04+submenuitem; /如果密碼與隱蔽選單密碼相符則進入隱蔽選單 /* if(check_password(HIDEMENU)
39、0; menuitem=0x20; */ submenuitem=0x00; tempvar0=0x00; showflag=0; break; tempkey=0x50; break; case 0x04:/輸出設定菜單 tm12864_reset(); if(showflag=0)
40、tm12864_fillscreen(0x00); showflag=1; tm12864_writehz(0,0,xzhlh,0); tm12864_writestr(10,0," ",0); tm12864_writehz(14,0,hao,0); tm12864_writehz(0,2,gz,0); tm12864_writehz(10,2,fen,0); tm12864_writehz(14,2,miao,0); tm12864_writehz(0,4,tz,0); tm12864_writehz(14,4,miao,0); tm12864_writeh
41、z(0,6,jg,0);/漢字“間隔”尚未建立 tm12864_writehz(14,6,miao,0); if(submenuitem!=7) tm12864_writehz(10,4,fen,0); tm12864_writehz(10,6,fen,0); switch(tempkey) case BUTTON_SLAVE: if(submenuitem<7) submenuitem+; else showflag=0; submenuitem=0; tempvar0=0; if(tempvar0>32)|(tempvar0=0) submenuitem=0; tempvar0
42、=0; else if(tempvar2>59) submenuitem=2; tempvar2=0; else if(tempvar4>59) submenuitem=4; tempvar4=0; else if(tempvar6>59) submenuitem=6; tempvar6=0; j=0; break; case BUTTON_STOP: submenuitem=0x00; menuitem=0x03; showflag=0; tempvar0=0; j=0; break; switch(submenuitem) case 0:/獲取回路號 if(j<2)
43、&&(tempkey<0x0a) tempvar0=tempvar0*0x0a+tempkey; j+; showstr0=(tempvar0/0x0a+0x30); showstr1=(tempvar0%0x0a+0x30); showstr2='0' tm12864_writestr(12,0,showstr,1); break; case 1:/獲取工作時間-分 showstr0=(tempvar0/0x0a+0x30); showstr1=(tempvar0%0x0a+0x30); showstr2='0' tm12864_writ
44、estr(12,0,showstr,0); if(j=0) if(tempvar0!=0) tempvar1=x25045_readword(tempvar0*7-7); tempvar2=tempvar1%60; tempvar1=tempvar1/60; tempvar3=x25045_readword(tempvar0*7-5); tempvar4=tempvar3%60; tempvar3=tempvar3/60; tempvar5=x25045_readword(tempvar0*7-3); tempvar6=tempvar5%60; tempvar5=tempvar5/60; sh
45、owstr0=(tempvar2/10+0x30); showstr1=(tempvar2%10+0x30); showstr2='0' tm12864_writestr(12,2,showstr,0); showstr0=(tempvar3/1000+0x30); showstr1=(tempvar3%1000)/100+0x30); showstr2=(tempvar3%100)/10+0x30); showstr3=(tempvar3%10+0x30); showstr4='0' tm12864_writestr(6,4,showstr,0); shows
46、tr0=(tempvar4/10+0x30); showstr1=(tempvar4%10+0x30); showstr2='0' tm12864_writestr(12,4,showstr,0); showstr0=(tempvar5/1000+0x30); showstr1=(tempvar5%1000)/100+0x30); showstr2=(tempvar5%100)/10+0x30); showstr3=(tempvar5%10+0x30); showstr4='0' tm12864_writestr(6,6,showstr,0); showstr0
47、=(tempvar6/10+0x30); showstr1=(tempvar6%10+0x30); showstr2='0' tm12864_writestr(12,6,showstr,0); else tempvar1=0x00; tempvar2=0x00; tempvar3=0x00; tempvar4=0x00; tempvar5=0x00; tempvar6=0x00; if(j<4)&&(tempkey<0x0a) if(j=0) tempvar1=0; tempvar1=(tempvar1*0x0a)+(int)tempkey); j+
48、; showstr0=(tempvar1/1000+0x30); showstr1=(tempvar1%1000)/100+0x30); showstr2=(tempvar1%100)/10+0x30); showstr3=(tempvar1%10+0x30); showstr4='0' tm12864_writestr(6,2,showstr,1); break; case 2:/獲取工作時間-秒 showstr0=(tempvar1/1000+0x30); showstr1=(tempvar1%1000)/100+0x30); showstr2=(tempvar1%100)
49、/10+0x30); showstr3=(tempvar1%10+0x30); showstr4='0' tm12864_writestr(6,2,showstr,0); if(j<2)&&(tempkey<0x0a) if(j=0) tempvar2=0; tempvar2=tempvar2*0x0a+tempkey; j+; showstr0=(tempvar2/10+0x30); showstr1=(tempvar2%10+0x30); showstr2='0' tm12864_writestr(12,2,showstr,1);
50、 break; case 3:/獲取停止時間-分 showstr0=(tempvar2/10+0x30); showstr1=(tempvar2%10+0x30); showstr2='0' tm12864_writestr(12,2,showstr,0); if(j<4)&&(tempkey<0x0a) if(j=0) tempvar3=0; tempvar3=tempvar3*0x0a+tempkey; j+; showstr0=(tempvar3/1000+0x30); showstr1=(tempvar3%1000)/100+0x30); s
51、howstr2=(tempvar3%100)/10+0x30); showstr3=(tempvar3%10+0x30); showstr4='0' tm12864_writestr(6,4,showstr,1); break; case 4:/獲取停止時間-秒 showstr0=(tempvar3/1000+0x30); showstr1=(tempvar3%1000)/100+0x30); showstr2=(tempvar3%100)/10+0x30); showstr3=(tempvar3%10+0x30); showstr4='0' tm12864_w
52、ritestr(6,4,showstr,0); if(j<2)&&(tempkey<0x0a) if(j=0) tempvar4=0; tempvar4=tempvar4*0x0a+tempkey; j+; showstr0=(tempvar4/10+0x30); showstr1=(tempvar4%10+0x30); showstr2='0' tm12864_writestr(12,4,showstr,1); break; case 5:/獲取間隔時間-分 showstr0=(tempvar4/10+0x30); showstr1=(tempva
53、r4%10+0x30); showstr2='0' tm12864_writestr(12,4,showstr,0); if(j<4)&&(tempkey<0x0a) if(j=0) tempvar5=0; tempvar5=tempvar5*0x0a+tempkey; j+; showstr0=(tempvar5/1000+0x30); showstr1=(tempvar5%1000)/100+0x30); showstr2=(tempvar5%100)/10+0x30); showstr3=(tempvar5%10+0x30); showstr4
54、='0' tm12864_writestr(6,6,showstr,1); break; case 6:/獲取間隔時間-秒 showstr0=(tempvar5/1000+0x30); showstr1=(tempvar5%1000)/100+0x30); showstr2=(tempvar5%100)/10+0x30); showstr3=(tempvar5%10+0x30); showstr4='0' tm12864_writestr(6,6,showstr,0); if(j<2)&&(tempkey<0x0a) if(j=0)
55、tempvar6=0; tempvar6=tempvar6*0x0a+tempkey; j+; showstr0=(tempvar6/10+0x30); showstr1=(tempvar6%10+0x30); showstr2='0' tm12864_writestr(12,6,showstr,1); break; case 7:/確認存儲菜單 tm12864_writestr(12,6,showstr,0); tm12864_writehz(4,5,bmp1,0); if(tempkey=BUTTON_OK) tempvar1=tempvar1*60; tempvar1=t
56、empvar1+tempvar2; tempvar3=tempvar3*60; tempvar3=tempvar3+tempvar4; tempvar5=tempvar5*60; tempvar5=tempvar5+tempvar6; x25045_init(); /保存工作時間 x25045_writeenable(); x25045_writeword(tempvar1,(tempvar0*7-7); /保存停止時間 x25045_writeenable(); x25045_writeword(tempvar3,(tempvar0*7-5); /保存間隔時間 x2
57、5045_writeenable(); x25045_writeword(tempvar5,(tempvar0*7-3); submenuitem=0; showflag=0; tempvar0=0x00; j=0; break; tempkey=0x50; break; case 0x05:/設置輸入回路 tm12864_reset(); if(showflag=0) tm12864_fil
58、lscreen(0x00); showflag=1; tm12864_writehz(2,0,sdsrhl,0); tm12864_writehz(0,2,xzhlh,0); tm12864_writehz(14,2,hao,0); tm12864_writehz(0,4,lj,0);/連接 if(submenuitem!=0x03) tm12864_writehz(6,4,hschl,0);/號回路 tm12864_writehz(0,6,gn,0);/功能 tm12864_writestr(4,6,": ",0); switch(tempkey) case BUTTON
59、_SLAVE: if(submenuitem<3) submenuitem+; else submenuitem=0; showflag=0; tm12864_writehz(6,4,hschl,0); tm12864_writestr(4,6,": ",0); tempvar0=0; if(tempvar0=0)|(tempvar0>76) tempvar0=0; submenuitem=0; else if(tempvar1=0)|(tempvar1&
60、gt;36)&&(tempvar1!=99) tempvar1=0; submenuitem=1; j=0; break; case BUTTON_STOP: menuitem=0x03; submenuitem=0x01; showflag=0; tempvar0=0; j=0; break; switch(submenuitem) case 0:/獲取回路號 if(j<2)&&(tempkey<0x0a) tempvar0=tempvar0*0x0a+tempkey; j+; showstr0=(tempvar0/0x0a+0x30); show
61、str1=(tempvar0%0x0a+0x30); showstr2='0' tm12864_writestr(12,2,showstr,1); break; case 1:/獲取輸出回路號 showstr0=(tempvar0/0x0a+0x30); showstr1=(tempvar0%0x0a+0x30); showstr2='0' tm12864_writestr(12,2,showstr,0); if(j=0) if(tempvar0!=0) tempvar1=x25045_readbyte(tempvar0*2-2+0x100); tempvar2
62、=x25045_readbyte(tempvar0*2-1+0x100); if(tempvar2=1) tm12864_writehz(6,6,qdsc,0); else tm12864_writehz(6,6,tzsc,0); else tempvar1=0x00; tempvar2=0x00; if(j<4)&&(tempkey<0x0a) if(j=0) tempvar1=0; tempvar1=tempvar1*0x0a+tempkey; j+; showstr0=(tempvar1/10+0x30); showstr1=(tempvar1%10+0x30); showstr2='0' tm12864_writestr(4,4,showstr,1); break; case 2:/獲取功能 tm12864_writestr(4,4,showstr,0); if(tempvar2=1) tm12864_writehz(6,6,qdsc,1); else tm12
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 競爭對手戰(zhàn)略詳述
- 和諧春運交通安全
- 冬季防溺水主題教育
- 山東省泰安市肥城市2024-2025學年(五四學制)八年級上學期末考試道德與法治試題(含答案)
- 10萬噸電池余料回收循環(huán)利用項目可行性研究報告模板-立項備案
- 人教版歷史與社會八下8.2《洋務運動與近代民族工業(yè)的發(fā)展》說課稿
- 河南省漯河市第三高級中學2025屆高三上學期12月階段性測試語文試卷(含答案)
- 海南省三亞市(2024年-2025年小學六年級語文)部編版課后作業(yè)(上學期)試卷及答案
- 陜西省咸陽市(2024年-2025年小學六年級語文)統(tǒng)編版階段練習(上學期)試卷及答案
- 貴州盛華職業(yè)學院《化學分析實驗》2023-2024學年第一學期期末試卷
- GB/T 40537-2021航天產(chǎn)品裕度設計指南
- 政協(xié)個人簡歷模板12篇
- 木工工具及使用方法課件
- 節(jié)能減排獎懲制度(5篇)
- 部編六年級語文上冊 讀音易錯字
- 全國醫(yī)學博士英語統(tǒng)一考試詞匯表(10000詞全) - 打印版
- COPD(慢性阻塞性肺病)診治指南(2023年中文版)
- 氣相色譜儀作業(yè)指導書
- ?中醫(yī)院醫(yī)院等級復評實施方案
- 跨高速橋梁施工保通專項方案
- 鐵路貨車主要輪對型式和基本尺寸
評論
0/150
提交評論