12232液晶顯示程序_第1頁(yè)
12232液晶顯示程序_第2頁(yè)
12232液晶顯示程序_第3頁(yè)
12232液晶顯示程序_第4頁(yè)
12232液晶顯示程序_第5頁(yè)
已閱讀5頁(yè),還剩5頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、/*=功能:使用12232液晶顯示圖片演示硬件:TG12232B(122*32)模擬口線接線方式連接線圖:|DB0-P0.0DB4-P0.4|RWP1.1A0P1.0|DB1-P0.1DB5-P0.5|RSP2.1V0接1K電阻到GND|DB2-P0.2|DB6-P0.6|E1P1.3|DB3-P0.3|DB7-P0.7|E2P1.2|本程序源碼只供學(xué)習(xí)參考,如有需要請(qǐng)聯(lián)系作者。注:AT89x52使用22.1184M或11.0592M晶振,實(shí)測(cè)使用22.1184M或11.0592都可以編譯平臺(tái):KeiluV27.08,當(dāng)/可能看起來有點(diǎn)亂,不過效果還是不錯(cuò)的,顯示圖形總的來說比顯示漢字要簡(jiǎn)單然

2、顯示漢字也不難。希望此程序能給你一些幫助。=*/#include#defineucharunsignedchar#defineuintunsignedint#defineE1P1_3/塊1左邊#defineE2P1_2/塊2右邊#defineRWP1_1#defineA0P1_0/A0為1時(shí)是數(shù)據(jù),0時(shí)為指令數(shù)據(jù)#defineDATAP0/數(shù)據(jù)externunsignedcharcodeBmpt1;externunsignedcharcodeBmpt2;externunsignedcharcodeBmpt3;externunsignedcharcodeBmpt4;externunsignedc

3、harcodeBmpt5;externunsignedcharcodeBmpt6;externunsignedcharcodeBmpt7;externunsignedcharcodeBmptc;externunsignedcharcodebmp001;externunsignedcharcodeBmp08;externunsignedcharcodeBmp07;externunsignedcharcodeBmp06;externunsignedcharcodeBmp05;externunsignedcharcodeBmp04;externunsignedcharcodeBmp03;extern

4、unsignedcharcodeBmp02;externunsignedcharcodeBmp01;externunsignedcharcodeBmp012;externunsignedcharcodeBmp003;externunsignedcharcodeBmp002;/延時(shí)voiddelay(unsignedinti)unsignedchark=200;while(i0)i-;while(k1)k-;/左頁(yè)/發(fā)送數(shù)據(jù)voidOUTMD(unsignedchari)A0=1;/寫數(shù)據(jù)/delay(5);E1=1;/delay(10);DATA=i;/delay(5);E1=0;/左頁(yè)/發(fā)送

5、命令voidOUTMI(unsignedchari)A0=0;/寫指令/delay(5);E1=1;/delay(10);DATA=i;/delay(5);E1=0;/右頁(yè)/發(fā)送數(shù)據(jù)voidOUTSD(unsignedchari)A0=1;/寫數(shù)據(jù)/delay(5);E2=1;/delay(10);DATA=i;/delay(5);E2=0;/右頁(yè)/發(fā)送命令voidOUTSI(unsignedchari)A0=0;/寫指令/delay(5);E2=1;/delay(10);DATA=i;/delay(5);E2=0;/初始化voidlcdini(void)RW=0;OUTMI(0XE2);0U

6、TSI(0XE2);/復(fù)位OUTMI(0XAE);OUTSI(0XAE);/POWERSAVEOUTMI(0XA4);0UTSI(0XA4);/動(dòng)態(tài)驅(qū)動(dòng)OUTMI(0XA9);OUTSI(0XA9);/1/32占空比OUTMI(0XA0);OUTSI(OXAO);/時(shí)鐘線輸出OUTMI(0XEE);OUTSI(OXEE);/寫模式OUTMI(0X00);OUTMI(0XC0);OUTSI(0X00);OUTSI(0XC0);OUTMI(0XAF);OUTSI(0XAF);/*函數(shù)說明:同時(shí)設(shè)置主從顯示頁(yè)為03頁(yè)。(內(nèi)函數(shù),私有,用戶不直接調(diào)用)*/voidSetPage(ucharpage0,

7、ucharpage1)OUTMI(0 xB8|page1);OUTSI(0 xB8|page0);/*函數(shù)說明:同時(shí)設(shè)置主從列地址為0121。(內(nèi)函數(shù),私有,用戶不直接調(diào)用)*/voidSetAddress(ucharaddress0,ucharaddress1)OUTMI(address1);OUTSI(address0);/*調(diào)用方式:voidPutChar0(ucharch)函數(shù)說明:在右頁(yè)當(dāng)前地址畫一個(gè)字節(jié)8個(gè)點(diǎn)。(內(nèi)函數(shù),私有,用戶不直接調(diào)用)-*/voidPutCharR(ucharch)OUTSD(ch);/*調(diào)用方式:voidPutChar1(ucharch)函數(shù)說明:在左頁(yè)當(dāng)

8、前地址畫一個(gè)字節(jié)8個(gè)點(diǎn)。(內(nèi)函數(shù),私有,用戶不直接調(diào)用)-*/voidPutCharL(ucharch)OUTMD(ch);/*調(diào)用方式:voidDrawBmp(bitlayer,ucharwidth,uchar*bmp)函數(shù)說明:畫一個(gè)圖,layer表示上下層,width是圖形的寬,高都是16,bmp是圖形指針使用zimo3軟件,縱向取模,字節(jié)倒序/240字節(jié)-*/voidDrawBmp(bitlayer,ucharwidth,uchar*bmp)ucharx,address,i=O;/address表示顯存的物理地址ucharpage=0;/page表示上下兩頁(yè)bitwindow=0;/w

9、indow表示左右兩頁(yè)/putcharR/右邊/putcharL/左邊f(xié)or(x=width;x1;x-)if(i60)window=1;address=i%61;elseaddress=i;if(layer=0)/顯示一行八個(gè)字SetPage(0,0);SetAddress(address,address);if(window=1)PutCharR(bmp);elsePutCharL(bmp);SetPage(1,1);SetAddress(address,address);if(window=1)PutCharR(bmpi+width);elsePutCharL(bmpi+width);e

10、lse/顯示第二行八個(gè)漢字SetPage(2,2);SetAddress(address,address);if(window=1)PutCharR(bmp);elsePutCharL(bmp);SetPage(3,3);SetAddress(address,address);if(window=1)PutCharR(bmpi+width);elsePutCharL(bmpi+width);i+;/*調(diào)用方式:voidclrscr(void)函數(shù)說明:清屏-*/voidclrscr(void)uchari;ucharpage;for(page=0;page4;page+)SetPage(pag

11、e,page);SetAddress(0,0);for(i=0;i1;x-)if(x_add60)window=1;address=x_add%61;elseaddress=x_add;SetPage(0,0);SetAddress(address,address);if(window=1)PutCharR(bmp);elsePutCharL(bmp);SetPage(1,1);SetAddress(address,address);if(window=1)PutCharR(bmpi+width);elsePutCharL(bmpi+width);SetPage(2,2);SetAddress

12、(address,address);if(window=1)PutCharR(bmpi+width+width);elsePutCharL(bmpi+width+width);SetPage(3,3);SetAddress(address,address);if(window=1)PutCharR(bmpi+width+width+width);elsePutCharL(bmpi+width+width+width);i+;x_add+;/采用zimo2顯示漢字,以漢字的顯示方式/voidDraw_word(uchard_where,uintx_add,bitlayer,ucharwidth)

13、/d_where表示在碼表中第幾個(gè)漢字,x_add橫坐標(biāo)位置,layer顯示的層,widthDO的寬度。/voidDraw_word(uchard_where,uintx_add,bitlayer,ucharwidth)ucharx,i=O,address;/address表示顯存的物理地址ucharpage=0;/page表示上下兩頁(yè)bitwindow=0;/window表示左右兩頁(yè)/putcharR/右邊/putcharL/左邊d_where=d_where*32;for(x=width;x1;x-)if(x_add60)window=1;address=x_add%61;elseaddr

14、ess=x_add;if(layer=0)/顯示一行八個(gè)字SetPage(0,0);SetAddress(address,address);if(window=l)PutCharR(bmp001d_where);/l邊elsePutCharL(bmp001d_where);/J邊SetPage(1,1);SetAddress(address,address);if(window=1)PutCharR(bmp001d_where+width);elsePutCharL(bmp001d_where+width);else/顯示第二行八個(gè)漢字SetPage(2,2);SetAddress(addre

15、ss,address);if(window=l)PutCharR(bmp001d_where);/右邊elsePutCharL(bmp001d_where);/左邊SetPage(3,3);SetAddress(address,address);if(window=1)PutCharR(bmp001d_where+width);elsePutCharL(bmp001d_where+width);x_add+;d_where+;/*/字模2顯示一個(gè)漢字/縱向取模,字節(jié)倒序voiddisp_one(bittop_low,bitwidows,ucharaddress,ucharwidth,uchar

16、*bmp)if(top_low=0)SetPage(0,0);SetAddress(address,address);if(window=1)PutCharR(bmp001next);elsePutCharL(bmp001next);SetPage(1,1);SetAddress(address,address);if(window=1)PutCharR(bmp001nexti+width);elsePutCharL(bmp001nexti+width);elseSetPage(0,0);SetAddress(address,address);if(window=1)PutCharR(bmp0

17、01next);elsePutCharL(bmp001next);SetPage(1,1);SetAddress(address,address);if(window=1)PutCharR(bmp001nexti+width);elsePutCharL(bmp001nexti+width);*/液晶顯示規(guī)則/M(左)S(右)/pagepage/0|0/1|1/2|2/3|3voiddelay1s(unsignedchari)while(i1)i-;delay(65530);/顯示動(dòng)態(tài)的等待圖標(biāo)voidwait1(unsignedchari)for(;i1;i-)delay1s(2);clrsc

18、r();/DrawBmp1(0,60,Bmptc);/DrawBmp1(76,19,Bmpt1);/delay1s(2);clrscr();/DrawBmp1(0,60,Bmptc);/DrawBmp1(76,19,Bmpt2);/delay1s(2);clrscr();/DrawBmp1(0,60,Bmptc);/DrawBmp1(76,19,Bmpt3);/delay1s(2);clrscr();/DrawBmp1(0,60,Bmptc);/DrawBmp1(76,19,Bmpt4);/delay1s(2);clrscr();/DrawBmp1(0,60,Bmptc);/DrawBmp1(76,19,Bmpt5);/delay1s(2);clrscr();/DrawBmp1(0,60,Bmptc);/DrawBmp1(76,19,Bmpt6);/delay1s(2);clrscr();/DrawBmp1(0,60,Bmptc);/DrawBmp1(76,19,Bmpt7);/演示程序voidmain()lcdini();/resetclrscr();/clrDraw_word(0,0,0,16);/Draw_word(1,16,0,16

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論