新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 12864無字庫液晶顯示

12864無字庫液晶顯示

作者: 時間:2012-08-04 來源:網絡 收藏

點擊瀏覽下一頁

這篇文章主要來寫一下液晶顯示的程序,至于一些的設置,和液晶的資料介紹,大家可以參看液晶的datesheet,上面一般都很全面,一些具體注意事項請大家參看:http://hi.baidu.com/echoas 他的空間里面介紹的比較清楚,我在這里也沒必要浪費時間重復了。

我在這里直接貼出程序,程序注釋比較清楚,相信大家對照dateshee可以看明白。

/************************************程序功能:無字庫12864液晶的顯示編譯環(huán)境:keil4運行環(huán)境:proteus7.7整理人:張家越  QQ:435835181整理時間:2011-04-28取模軟件使用的是:ZM201***********************************/#includereg52.h>#define uchar unsigned char#define uint unsigned int#define port P0  //DB0~DB7數(shù)據口sbit e=P2^0;//使能sbit rw=P2^1;//讀寫sbit rs=P2^2;//數(shù)據/命令sbit cs2=P2^3;//片選sbit cs1=P2^4;sbit busy=P0^7;//檢測忙uchar code hz[][32]={/*--  文字:  書  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x00,0x00,0x10,0x10,0x10,0xFF,0x88,0x88,0xFA,0x82,0x84,0x8C,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x7F,0x00,0x00,0x08,0x10,0x0C,0x03,0x00,0x00,0x00},/*--  文字:  山  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x20,0x20,0x20,0x1F,0x10,0x10,0x10,0x10,0x3F,0x00,0x00,0x00},/*--  文字:  有  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x10,0x10,0x90,0x50,0xF0,0x4C,0x4B,0x28,0x28,0x28,0xE8,0x08,0x08,0x00,0x00,0x00,0x02,0x01,0x00,0x00,0x7F,0x0A,0x0A,0x05,0x05,0x20,0x7F,0x00,0x00,0x00,0x00},/*--  文字:  路  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x00,0x3C,0x24,0xE2,0x9E,0x20,0x18,0x97,0x64,0x54,0x8C,0x00,0x00,0x00,0x00,0x00,0x10,0x1F,0x08,0x0F,0x04,0x02,0x7D,0x24,0x22,0x12,0x1E,0x01,0x01,0x01,0x00},/*--  文字:  勤  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x08,0x88,0xBF,0xE4,0x54,0x5F,0xC4,0x44,0xC0,0x3F,0x20,0xE0,0x00,0x00,0x00,0x00,0x20,0x2B,0x2A,0x1F,0x15,0x55,0x31,0x0C,0x23,0x40,0x30,0x0F,0x00,0x00,0x00},/*--  文字:  為  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x00,0x00,0x40,0x44,0x58,0xC0,0x38,0x27,0x20,0x20,0xE0,0x00,0x00,0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x06,0x01,0x10,0x21,0x46,0x30,0x0F,0x00,0x00,0x00,0x00},/*--  文字:  徑  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x10,0x88,0xC4,0x33,0x40,0x44,0x24,0x22,0x12,0x9A,0xA6,0xA0,0x40,0x00,0x00,0x02,0x01,0x00,0x7F,0x00,0x20,0x21,0x21,0x21,0x1F,0x10,0x10,0x10,0x10,0x00,0x00},/*--  文字:  ,  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*--  文字:  學  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x60,0x20,0xA0,0xA2,0xAC,0x51,0x56,0xD0,0x5C,0x13,0x10,0x30,0x10,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x24,0x44,0x3F,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00},/*--  文字:  海  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x20,0x40,0x04,0xC8,0x20,0x10,0xCC,0x4B,0xA8,0x28,0x24,0xE4,0x04,0x00,0x00,0x00,0x00,0x10,0x3E,0x01,0x02,0x1A,0x17,0x12,0x2E,0x49,0x39,0x0F,0x09,0x01,0x00,0x00},/*--  文字:  無  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x00,0x40,0x44,0x44,0x44,0xC4,0x3C,0xE2,0x22,0x22,0x22,0x20,0x00,0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x06,0x01,0x00,0x1F,0x20,0x20,0x20,0x20,0x3C,0x00,0x00},/*--  文字:  涯  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x20,0x40,0x02,0xC4,0x00,0xFC,0x24,0x24,0xFC,0x92,0x92,0x82,0x00,0x00,0x00,0x00,0x10,0x3C,0x43,0x30,0x4E,0x41,0x49,0x49,0x3F,0x24,0x24,0x20,0x20,0x00,0x00},/*--  文字:  苦  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x80,0x88,0x88,0x88,0x9E,0x84,0xE4,0x44,0x5F,0x44,0x44,0x44,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x44,0x44,0x23,0x22,0x22,0x3E,0x00,0x00,0x00,0x00,0x00},/*--  文字:  作  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x80,0x40,0x20,0xF8,0x07,0x40,0x30,0x1C,0xF3,0x90,0x90,0x48,0x48,0x08,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x7F,0x04,0x04,0x02,0x02,0x02,0x00,0x00},/*--  文字:  舟  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x00,0x00,0x00,0xF8,0x88,0x8C,0x9B,0xA4,0x84,0xFC,0x40,0x40,0x40,0x00,0x00,0x01,0x41,0x21,0x19,0x07,0x00,0x02,0x04,0x10,0x20,0x7F,0x00,0x00,0x00,0x00,0x00},/*--  文字:  。  --*//*--  仿宋_GB231212;  此字體下對應的點陣為:寬x高=16x16   --*/{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x24,0x24,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x02,0xFE,0x92,0x92,0x92,0xFE,0x12,0x11,0x12,0x1C,0xF0,0x18,0x17,0x12,0x10,0x00,0x08,0x1F,0x08,0x08,0x04,0xFF,0x05,0x81,0x41,0x31,0x0F,0x11,0x21,0xC1,0x41,0x00},//"聯(lián)",14{0x00,0x00,0x02,0x22,0xB2,0xAA,0x66,0x62,0x22,0x11,0x4D,0x81,0x01,0x01,0x00,0x00,0x00,0x40,0x21,0x13,0x09,0x05,0x41,0x81,0x7F,0x01,0x05,0x09,0x13,0x62,0x00,0x00},//"系",15{0x08,0x08,0x08,0x08,0x08,0x08,0xF9,0x4A,0x4C,0x48,0x48,0xC8,0x08,0x08,0x08,0x00,0x40,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x20,0x40,0x40,0x3F,0x00,0x00,0x00,0x00},//"方",16{0x00,0x08,0x88,0x88,0x88,0x88,0x88,0x08,0xFF,0x08,0x09,0x0E,0x0A,0x08,0x00,0x00,0x00,0x20,0x60,0x30,0x1F,0x10,0x08,0x08,0x00,0x07,0x18,0x20,0x40,0x80,0x70,0x00},//"式",17};uchar code num[][16]={{0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00},//"0",0{0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},//"1",1{0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00},//"2",2{0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00},//"3",3{0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00},//"4",4{0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00},//"5",5{0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00},//"6",6{0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00},//"7",7{0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00},//"8",8{0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00} //"9",9};uchar code sign[][16]={{0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00},//"!",0{0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00},//":",1{0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00}//"Q",2};//延時void delay(uint n){uint i;for(;n>0;n--)for(i=200;i>0;i--);}//判斷是否忙void check(){rs=0;  rw=1;   //讀 e=1;port=0x00;e=1; while(busy);e=0;}//寫指令void sendcommand(uchar command){check();rs=0;  //指令rw=0;  //寫 e=0;port=command;e=1;e=0; //寫入指令}//寫數(shù)據void writedata(uchar dat){check();rs=1;    //數(shù)據rw=0;port=dat;e=1;e=0;}//選屏幕 0--全屏,1--左屏,2--右屏;void select(uint n){switch(n){case 0:cs1=0;cs2=0;break;   //低電平選中case 1:cs1=0;cs2=1;break;   //cs1左屏case 2:cs1=1;cs2=0;break;   //cs2右屏}  }//頁void setpage(uchar page){page=page0x07;page=page|0xb8;sendcommand(page);}//列void setcolumn(uchar column){column=column0x3f;column=column|0x40;sendcommand(column);}//起始行void setline(uchar line){line=line0x3f;line=line|0xc0;sendcommand(line);}//屏幕開關顯示 0--關,1--開;void seton(uint n){n=n|0x3e;sendcommand(n);}//清屏 0--全屏,1--左屏,2--右屏;void clear(uint n){uchar i,j;select(n);for(i=0;i8;i++){setpage(i);setcolumn(0);for(j=0;j64;j++)writedata(0);  //置0清空}}//初始化void init(uchar i){check();seton(1);select(0);//clear(0);setline(i);}//顯示漢字 16*16顯示void show16(uchar page,uchar column,uchar screen,uchar method,uchar *str)  //頁,列,{uchar i,j;select(screen);j=0;setpage(page);setcolumn(column);for(i=0;i16;i++){  if(method==1)   writedata(~str[j++]); //method為顯示方式。當?shù)扔?時,反白。else            writedata(str[j++]);     }setpage(page+1);setcolumn(column);for(i=0;i16;i++){  if(method==1)   writedata(~str[j++]);else            writedata(str[j++]);     }} //顯示數(shù)字 8*16顯示void show8(uchar page,uchar column,uchar screen,uchar method,uchar *str){uchar i,j;select(screen);j=0;setpage(page);setcolumn(column);for(i=0;i8;i++){  if(method==1)   writedata(~str[j++]);else            writedata(str[j++]);     }setpage(page+1);setcolumn(column);for(i=0;i8;i++){  if(method==1)   writedata(~str[j++]);else            writedata(str[j++]);     }}void welcome(){uint i=0,j;for(j=0;j3;j++,j++)for(i=0;i4;i++){  show16(j,16*i,1,0,hz[i+j*4]);    //寫左屏數(shù)據//    if(i+4+j*416)show16(j,16*i,2,0,hz[i+4+j*4]);   //寫右屏數(shù)據}//  show8(2,32,2,0,sign[0]); //!for(i=0;i4;i++){show16(4,16*i,1,0,hz[16+i]);}show8(4,0,2,0,sign[1]); //:show8(6,0,1,0,sign[2]); //Qshow8(6,8,1,0,sign[2]); //Qshow8(6,16,1,0,sign[1]); //://以下數(shù)字均為反白顯示。show8(6,32,1,1,num[4]); //4show8(6,40,1,1,num[3]);  //3show8(6,48,1,1,num[5]); //5show8(6,56,1,1,num[8]); //8show8(6,0,2,1,num[3]);   //3show8(6,8,2,1,num[5]); //5show8(6,16,2,1,num[1]); //1show8(6,24,2,1,num[8]); //8show8(6,32,2,1,num[1]); //1}void main(){uchar j;clear(0);while(1){for(j=0;j63;){j=j+16;if(j>60)j=0;init(j);//   delay(200);welcome();delay(500);}}}


評論


相關推薦

技術專區(qū)

關閉