//顯示一屏漢字 //pageheadaddr:此屏漢字代碼地址區(qū)首地址 void ShowPage(unsigned char pagehead[][16]) { unsigned char i; for(i=0;i<4;i++) ShowLine(i,pagehead[i]); //1行8個(gè)漢字,16字節(jié) } /*----------------------------------------------------------------------------------------------------*/ //讀顯示數(shù)據(jù) unsigned char ReadByte() { unsigned char dat; CheckState(); di=1; rw=1; LCD12864DataPort=0xff; en=1; dat=LCD12864DataPort; en=0; return(dat); } /*----------------------------------------------------------------------------------------------------*/ //反顯一個(gè)8*8字塊 //lin:行(0-3), column: 列(0-7) void ReverseShow88(unsigned char lin,unsigned char column) { unsigned char i; unsigned char tab[8]; if(column<8) SelectScreen(1); //如果列數(shù)<4(0,1,2,3),則寫在第一屏上 else SelectScreen(2); //否則 (4,5,6,7), 寫在第二屏上 //讀上部8列 column=column<<3; //每個(gè)方塊8*8大小 SetLine(lin); SetColumn(column); tab[0]=ReadByte(); //空讀!!!!! //? for(i=0;i<8;i++) tab[i]=~ReadByte(); //寫回 SetLine(lin); SetColumn(column); for(i=0;i<8;i++) WriteByte(tab[i]); } /*----------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------*/ //反顯一個(gè)字符 //lin:行(0-4), column: 列(0-15) void ReverseShowChar(unsigned char lin,unsigned char column) { lin=lin<<1; ReverseShow88(lin ,column); ReverseShow88(lin+1,column); } /*----------------------------------------------------------------------------------------------------*/ //反顯一個(gè)漢字 //lin:行(0-3), column: 列(0-7) ReverseShowHZ(unsigned char lin,unsigned char column) { lin=lin<<1; column=column<<1; ReverseShow88(lin ,column ); ReverseShow88(lin ,column+1); ReverseShow88(lin+1,column ); ReverseShow88(lin+1,column+1); } /*----------------------------------------------------------------------------------------------------*/ //反顯一行漢字 //lin:行 ReverseShow(unsigned char lin) { unsigned char i; for(i=0;i<8;i++) ReverseShowHZ(lin,i); } /*----------------------------------------------------------------------------------------------------*/ void InitLCD() //初始化LCD { unsigned char i=250; //延時(shí) while(i--); //reset=0;//復(fù)位 //reset=1; SelectScreen(0); SetOnOff(0); //關(guān)顯示 ClearScreen(1);//清屏 ClearScreen(2); SelectScreen(0); SetOnOff(1); //開顯示 SelectScreen(0); SetStartLine(0); //開始行:0 } /*----------------------------------------------------------------------------------------------------*/ void Reset() //液晶復(fù)位 { //reset 低復(fù)位 _|- reset=0; _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); reset=1; //全屏 cs1=0; _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); cs2=0; _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); SendCommandToLCD(0x3F); }
|