logo资料库

基于51单片机的12864液晶显示C语言源程序.doc

第1页 / 共7页
第2页 / 共7页
第3页 / 共7页
第4页 / 共7页
第5页 / 共7页
第6页 / 共7页
第7页 / 共7页
资料共7页,全文预览结束
12864 液晶 C 程序+电路+图片 (控制器 KS0108) 电路:
/*********************************************************************/ //显示 /*****************/ /* */ /* 12864lcd */ /* /* */ /*****************/ */ #include #include #include #include #include #include
//Master chip enable //Slave chip enable //Data or Instrument Select /* Define the register command code */ #define Disp_On 0x3f #define Disp_Off 0x3e #define Col_Add 0x40 #define Page_Add 0xb8 #define Start_Line 0xc0 #define Lcd_Bus P0 //MCU P1 LCM /*sbit Mcs="P2"^3; sbit Scs="P2"^4; sbit Enable="P2"^0; //6800 mode Enable single sbit Di="P2"^5; sbit RW="P2"^6; sbit Lcd_Rst=P2^2; //Lcm reset sbit Test_Key=P2^1;*/ sbit Mcs="P2"^3; sbit Scs="P2"^4; sbit Enable="P2"^2; //6800 mode Enable single sbit Di="P2"^0; sbit RW="P2"^1; sbit Lcd_Rst=P2^5; //Lcm reset sbit Test_Key=P1^0; //;**************************************************************** /*;RS REG ;R/W REG ;E ;CS1 REG ;CS2 REG ;RSTB REG //Master chip enable //Slave chip enable //Data or Instrument Select P2.0 P2.1 P2.3 P2.4 P2.5 REG P2.2 //Write or Read //Write or Read DEFINE LCM DATA/INSTRUCTION PIN DEFINE LCM READ/WRITE PIN DEFINE LCM CHIP ENABLE PIN DEFINE LCM CHIP 1 SELECT PIN DEFINE LCM CHIP 2 SELECT PIN DEFINE LCM /RESET PIN*/ char code SHU1[]={ /*-- 文字: 1 --*/ /*-- 宋体 12; 此字体下对应的点阵为:宽 x 高=8x16 --*/ 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20, 0x00,0x00 }; char code SHU2[]={ /*-- 文字: 2 --*/
/*-- 宋体 12; 此字体下对应的点阵为:宽 x 高=8x16 --*/ 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21, 0x30,0x00 }; char code SHU8[]={ /*-- 文字: 8 --*/ /*-- 宋体 12; 此字体下对应的点阵为:宽 x 高=8x16 --*/ 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22, 0x1C,0x00 }; char code SHU6[]={ /*-- 文字: 6 --*/ /*-- 宋体 12; 此字体下对应的点阵为:宽 x 高=8x16 --*/ 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11, 0x0E,0x00 }; char code SHU4[]={ /*-- 文字: 4 --*/ /*-- 宋体 12; 此字体下对应的点阵为:宽 x 高=8x16 --*/ 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F, 0x24,0x00 }; char code L[]={ /*-- 文字: L --*/ /*-- 宋体 12; 此字体下对应的点阵为:宽 x 高=8x16 --*/ 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20, 0x30,0x00 }; char code C[]={ /*-- 文字: C --*/ /*-- 宋体 12; 此字体下对应的点阵为:宽 x 高=8x16 --*/ 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10, 0x08,0x00 }; char code D[]={ /*-- 文字: D --*/ /*-- 宋体 12; 此字体下对应的点阵为:宽 x 高=8x16 --*/ 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,
0x0F,0x00 }; */ */ */ 12864LCD */ /*****************/ /* /* /* /* /*****************/ /*------------------延时子程序-----------------------------*/ void delay(unsigned int t) { unsigned int i,j; for(i=0;i
Lcd_Bus=Dispdata; delay(0); Enable=1; delay(0); Enable=0; } /*-------------------读 LCD 数据----------------------------*/ unsigned char read_data() { unsigned char tmpin; Di=1; RW=1; delay(0); Enable=1; delay(0); Enable=0; tmpin=Lcd_Bus; return tmpin; } /*------------------清除内存---------------*/ void Clr_Scr() { unsigned char j,k; Mcs=1;Scs=1; write_com(Page_Add+0); write_com(Col_Add+0); for(k=0;k<8;k++){ write_com(Page_Add+k); for(j=0;j<64;j++)write_data(0x00); } } /*---------------------指定位置显示字符 8*16-----------------------*/ void hz_disp816(unsigned char pag,unsigned char col, unsigned char code *hzk)
{ unsigned char j="0",i=0; for(j=0;j<2;j++){ write_com(Page_Add+pag+j); write_com(Col_Add+col); for(i=0;i<8;i++) write_data(hzk[8*j+i]); } }
分享到:
收藏