LCD12864显示程序成功版
lcd12864.h是液晶显示的程序
void clrram_lcd (void)
{
wr_i_lcd(0x30);
wr_i_lcd(0x01);
}
//********************************
//指定要显示字符的坐标
//*******************************
#define uint unsigned int
#define uchar unsigned char
//****************************************
//12864液晶显示部分子程序模块
//****************************************
case 2 : readOldL ^= ( 0x01 << ( 15 - tier_bit ));break ;
default : break ;
}
wr_d_lcd(readOldH);
wr_d_lcd(readOldL);
}
//wr_i_lcd(0x36);
wr_i_lcd(0x30);
}
default : break ;
}
wr_d_lcd( readOldH ) ;
wr_d_lcd( readOldL ) ;
}
else
{
switch(color)
{
case 0 : readOldL &= (~( 0x01 << ( 15 - tier_bit )));break ;
case 1 : readOldL |= ( 0x01 << ( 15 - tier_bit ));break ;
LCD12864显示中文及图片C程序
/****************************************屏幕显示驱动*****************************************/#include "GT23L24T3Y.h"#include "print.h"#include <stdio.h>#include <string.h>#include "bmp_picture.h"#include "lcd_12864.h"#include "..\user\rtc.h"u8 comTable[]={4,5,6,7,3,2,1,0};extern void Setlcd_Addr ( u8 row,u8 column );//外部函数调用声明extern u8 Num_Code[];//字库获得函数extern u8 Big_Num_Code[];//字库获得函数extern u8 Picture_Code[];//字库获得函数extern u8 arrow1[];extern u8 arrow2[];u8 testlcd[]="测试数据";/************************************************************************//显示中文输出//函数名:print_16//功能:显示16x16点阵字符串。
// 函数名:print_16// 功能:显示16点阵字符串// 形参:// row:x轴// column:y轴// *lcd:显示字符串// logic:显示取反// wei.显示位值// len长度*************************************************************************/void _print_15 ( u8 row,u8 column,const char *lcd,u8 logic ,u8 wei,u8 len){u8 w=0,x=0,y=0,l=0,read_data=0;u8 Length=0;GT_cs1;//字库片选至高for ( l=len; l>0; l=l-2 ) //总字节{w=*lcd;if ( w&0x80 ) //为1则为汉字,为0则为ASCII码{GT_cs0; //字库片选选定GT23_Write ( GT23_write_15 ( lcd ) ); //写入字库指令以及文字地址for ( x=0; x<2; x++ ){Setlcd_Addr (row,column);for(y=0;y<16;y++){read_data=GT23_Read();if(logic == true){// read_data = ~read_data;}WriteData(read_data );}row++;}GT_cs1;//字库片选至高row-=2;column+=16;if(column>=128){row+=2;column=0;}lcd=lcd+2;}}}/************************************************************************//描述:显示中文输出//使用:顶层函数调用参数:row 行column 列*lcd 字符串logic 反白*************************************************************************/ void print_15 ( u8 row,u8 column,const char *lcd,u8 logic ){u8 c=strlen ( lcd );_print_15(row,column,lcd,logic,0,c);}/************************************************************************ //描述:显示图片输出//使用:顶层函数调用参数:row 行column 列*lcd 字符串logic 反白*************************************************************************/ void print_array(u16 row,u16 column,u16 size_x,u16 size_y,const u8 *ptr, u8 logic){u8 w=0,x=0,y=0,l=0,read_data=0;u8 Length=0;for( x=0;x<size_x/8;x++){Setlcd_Addr (row,column);for(y=0;y<size_y;y++){read_data=*( ptr + (y+x*size_y) );if(logic == true){read_data = ~read_data;}WriteData1(read_data);// WriteData1(0XFF);}row++;}}u8 OpMgsCode[][10] ={"病人信息","循环播放","房号与床号","从机音量","对比度","广播""恢复","音乐","主机音量","时间"};u8 DayCode[][7]={"星期天","星期一","星期二","星期三","星期四","星期五","星期六"};void PrintMainFace(time mytime,u8 PeopleNum){//待机界面函数u8 Hrd,Ten,One;Lcd_Clr();//清屏print_15 ( 0,16, "月",false );print_15 ( 0,48, "日",false );print_15 ( 0,70, &DayCode[mytime.day][0],false );//显示星期//日期显示Ten=mytime.month/10;One=mytime.month%10;print_array(0 , 0, 16 , 7 , &Num_Code[Ten*14], false);print_array(0 , 8, 16 , 7 , &Num_Code[One*14], false);Ten=mytime.date/10;One=mytime.date%10;print_array(0 , 32, 16 , 7 , &Num_Code[Ten*14], false);print_array(0 , 40, 16 , 7 , &Num_Code[One*14], false);//时间显示Ten=mytime.hour/10;One=mytime.hour%10;print_array(2 , 20, 32 , 21 , &Big_Num_Code[Ten*84], false);print_array(2 , 42, 32 , 21 , &Big_Num_Code[One*84], false);Ten=mytime.minute/10;One=mytime.minute%10;print_array(2 , 68, 32 , 21 , &Big_Num_Code[Ten*84], false);print_array(2 , 90, 32 , 21 , &Big_Num_Code[One*84], false);//住院人数显示print_15 ( 6,32, "住院人数",false );Hrd=PeopleNum/100;PeopleNum=PeopleNum%100;Ten=PeopleNum/10;One=PeopleNum%10;if(Hrd ){print_array(6 , 96, 16 , 7 , &Num_Code[Hrd*14], false);}print_array(6 , 102, 16 , 7 , &Num_Code[Ten*14], false);print_array(6 , 110, 16 , 7 , &Num_Code[One*14], false);}void PrintPictureFace(u8 Index){time mytime;Lcd_Clr();//清屏mytime.month = 10;mytime.date = 16;mytime.hour = 12;mytime.minute = 15;mytime.day =3;PrintMainFace(mytime,96);//print_array(0 , 10, 48 , 8 , arrow1, false);//左箭头显示// print_array(0,38 ,48 ,48 , &Picture_Code[288*Index], false);//图片显示// print_array(0,108, 48 , 8 , arrow2, false); //右箭头显示//print_15 ( 6,33, &OpMgsCode[0][Index],false );//提示信息显示}。
LCD12864驱动程序(带字库的)
{
while(buf--);
}*/
/***********忙检测********************/
void Busy()
{
DataPort=0xFF;
RS=0;
RW=1;
while (1)
{
E =1;
if (P0^7==0) break;
}
E=0;
}
void main(void)
{
TMOD=0x01; ///选择定时器模式
TR0=1; //开中断,并允许T0中断
ET0=1;
EA=1; //总开关
Init_LCቤተ መጻሕፍቲ ባይዱ();
Clear_LCD();
while(1);
}
void t0(void) interrupt 1 using 0
{
//delay(100);
/*void Line_Num(uchar k)
{
//uint l;
if(k>=128&&k<=135)l=1;
if(k>135&&k<=143) l=3;
if(k>143&&k<=151) l=2;
if(k>151&&k<=159) l=4;
}*/
/*******************逐行显示***************************************/
void Write_Data(uchar Data)
{
Busy();
RS=1;
RW=0;
LCD12864显示实时时钟例程可运行
DS1302是美国DALLAS公司推出的一种高性能、低功耗的实时时钟芯片,附加31字节静态RAM,采用SPI三线接口与CPU进行同步通信,并可采用突发方式一次传送多个字节的时钟信号和RAM数据。
实时时钟可提供秒、分、时、日、星期、月和年,一个月小与31天时可以自动调整,且具有闰年补偿功能。
下面是一段12864液晶显示实时时钟的程序:/****************************************************************************** *********时间:2012.11.30晶振:11.0592MHz芯片:STC89C52RC功能描述:在12864上显示年、月、日、星期、时、分和秒等时间信息******************************************************************************* ********/#include<reg52.h>#define uchar unsigned charsbit CLK=P1^4; //DS1302引脚定义sbit IO=P1^5;sbit CE=P1^6;sbit ACC0=ACC^0;sbit ACC7=ACC^7;sbit RS=P2^4; //12864引脚定义数据口为P0sbit RW=P2^5;sbit EN=P2^6;sbit PSB=P2^1;sbit RET=P2^3;void Input_1byte(uchar TD) //DS1302输入一字节数据{uchar i;ACC=TD;for(i=8;i>0;i--){IO=ACC0;CLK=1;CLK=0;ACC=ACC>>1;}}uchar Output_1byte(void) //DS1302输出一字节数据{uchar i;for(i=8;i>0;i--){ACC=ACC>>1;ACC7=IO;CLK=1;CLK=0;}return(ACC);}void Write_DS1302(uchar add,uchar dat)//向DS1302写{CE=0;CLK=0;CE=1;Input_1byte(add);Input_1byte(dat);CE=0;}uchar Read_DS1302(uchar add) //从DS1302读{uchar inf; //信息临时存储变量CE=0;CLK=0;CE=1;Input_1byte(add);inf=Output_1byte();CE=0;return(inf);}/**********************DS1302初始化*****************************/void init_1302(){if(Read_DS1302(0xd1)==0x55) //判断内存单元的内容,是否进行初始化 {return;}else{Write_DS1302(0x8e,0x00); //关闭写保护Write_DS1302(0x90,0x00); //电池充电设置Write_DS1302(0x80,0x00); //秒Write_DS1302(0x82,0x54); //分Write_DS1302(0x84,0x20); //时Write_DS1302(0x86,0x30); //日Write_DS1302(0x88,0x11); //月Write_DS1302(0x8a,0x05); //星期Write_DS1302(0x8c,0x12); //年Write_DS1302(0xd0,0x55); //写RAMWrite_DS1302(0x8e,0x80); //打开写保护}}/**********************延时函数*****************************/ void DelayUs2x(unsigned char t){while(--t);}void DelayMs(unsigned char t){while(t--){//大致延时1mSDelayUs2x(245);DelayUs2x(245);}}/**********************12864判忙*****************************/ void check_busy(){RS=0;RW=1;EN=1;while((P0&0x80)==0x80);EN=0;}/**********************12864写指令*****************************/ void write_com(uchar com){check_busy();RS=0;RW=0;EN=1;P0=com;DelayUs2x(250);EN=0;DelayUs2x(250);}/**********************12864写数据*****************************/void write_data(uchar dat){check_busy();RS=1;RW=0;EN=1;P0=dat;DelayUs2x(250);EN=0;DelayUs2x(250);}/**********************12864初始化函数*****************************/void init(){DelayMs(40); //大于40MS的延时程序PSB=1; //设置为8BIT并口工作模式DelayMs(1); //延时RET=0; //复位DelayMs(1); //延时RET=1; //复位置高DelayMs(200);write_com(0x30); //选择基本指令集DelayUs2x(250); //延时大于100uswrite_com(0x30); //选择8bit数据流DelayUs2x(200); //延时大于37uswrite_com(0x0c); //开显示(无游标、不反白)DelayUs2x(250); //延时大于100uswrite_com(0x01); //清除显示,并且设定地址指针为00HDelayMs(200); //延时大于10mswrite_com(0x06); //指定在资料的读取及写入时,设定游标的移动方向及指定显示的移位,光标从右向左加1位移动DelayUs2x(250); //延时大于100us}/**********************清屏*****************************/void clrscreen(){write_com(0x01);DelayMs(15);}/*********************************************************主函数********************************************************/void main(){uchar sec,sec1,sec2;uchar min,min1,min2;uchar hour,hour1,hour2;uchar date,date1,date2;uchar mon,mon1,mon2;uchar day;uchar year,year1,year2;uchar table1[]="年月日时分秒星期温度摄氏"; //长度24uchar table2[]={0XD2,0XBB, 0XB6,0XFE, 0XC8,0XFD, 0XCB,0XC4, 0XCE,0XE5, 0XCE,0XF9, 0XC8,0XD5}; //长度14 uchar table3[]="0123456789"; //长度10init(); //液晶初始化clrscreen();DelayMs(200);init_1302(); //1302初始化只初始化一下就可以需要下载两次DelayMs(50);write_com(0x80); //显示20write_data('2');write_data('0');write_com(0x82); //显示年write_data(table1[0]);write_data(table1[1]);write_com(0x84); //显示月write_data(table1[2]);write_data(table1[3]);write_com(0x86); //显示日write_data(table1[4]);write_data(table1[5]);write_com(0x91); //显示时write_data(table1[6]);write_data(table1[7]);write_com(0x93); //显示分write_data(table1[8]);write_data(table1[9]);write_com(0x95); //显示秒write_data(table1[10]);write_data(table1[11]);write_com(0x88); //显示星期write_data(table1[12]);write_data(table1[13]);write_data(table1[14]);write_data(table1[15]);while(1){sec=Read_DS1302(0x81); ////读秒sec1=sec&0x0f; //个位sec2=sec>>4; //十位min=Read_DS1302(0x83); ////读分min1=min&0x0f; //个位min2=min>>4; //十位hour=Read_DS1302(0x85); ////读时hour1=hour&0x0f; //个位hour2=hour>>4; //十位date=Read_DS1302(0x87); ////读日date1=date&0x0f; //个位date2=date>>4; //十位mon=Read_DS1302(0x89); ////读月mon1=mon&0x0f; //个位mon2=mon>>4; //十位year=Read_DS1302(0x8d); ////读年year1=year&0x0f; //个位year2=year>>4; //十位day=Read_DS1302(0x8b); ////读星期write_com(0x94); //送显示内容write_data(table3[sec2]); //秒write_data(table3[sec1]);write_com(0x92);write_data(table3[min2]); //分write_data(table3[min1]);write_com(0x90);write_data(table3[hour2]); //时write_data(table3[hour1]);write_com(0x85);write_data(table3[date2]); //日write_data(table3[date1]);write_com(0x83);write_data(table3[mon2]); //月write_data(table3[mon1]);write_com(0x81);write_data(table3[year2]); //年write_data(table3[year1]);write_com(0x8a);write_data(table2[2*day-2]); //星期write_data(table2[2*day-1]);}}(注:范文素材和资料部分来自网络,供参考。
带中文字库的12864lcd显示程序
for(j = 100; j > 0; j--); }
// 检测 LCD是否处于忙状态 , 若忙返回 1, 空闲返回 0 bit checkBusy() { bit busy;
RS = 0; RW = 1; E = 1; delayUs(); busy = (bit)(LCD_DATA&0x80); E = 0; return busy; }
1
文档来源为 :从网络收集整理 .word 版本可编辑 .欢迎下载支持 .
// 等待 LCD到空闲 void wait() {
while(checkBusy()); }
// 写命令 void writeCmd(uchar cmd) {
wait(); RS = 0; RW = 0; E = 0; delayUs(); LCD_DATA = cmd; delayUs(); E = 1; delayUs(); E = 0; }3ຫໍສະໝຸດ delayMs(10); }
void setPosition(uchar x, uchar y) { uchar p;
switch(x%4) {
case 0: p = 0x80; break; // case 1: p = 0x90; break; // case 2: p = 0x88; break; // case 3: p = 0x98; break; // } p += y; writeCmd(p); }
PSB = 1; // 并口方式 writeCmd(0x30); // 基本指令 , 扩充指令为 34H delayMs(10); writeCmd(0x0c); // 显示开 , 关光标 delayMs(10); writeCmd(0x01); // 清屏
LCD12864液晶屏测试程序
/////LCD12864液晶屏测试程序(已通过)//////////////液晶屏型号:HJ12864M-1//////////#include <reg52.h>#define uchar unsigned char#define uint unsigned int//8bit数据接入IO口#define Part P0 //P0接8位数据线//控制数据端sbit LCD_RS=P2^5; //定义12864液晶RS端,寄存器选择信号 H:数据寄存器 L:指令寄存器sbit LCD_RW=P2^6; //定义12864液晶RW端,读/写信号 H:读 L:写sbit LCD_EN=P2^7; //定义12864液晶LCDEN端, 片选信号下降沿触发,锁存数据sbit LCD_PSB=P3^2; //定义12864液晶PSB端, H:并行 L:串行sbit LCD_RST=P3^4; //定义12864液晶RST端, H:不复位 L:复位uchar code dis1[]={"床前明月光"};uchar code dis2[]={"疑是地上霜"};uchar code dis3[]={"举头望明月"};uchar code dis4[]={"低头思故乡"};//毫秒延时函数void delay(uint xms){uint i,j;for(j=0;i<xms;j++)for(i=0;i<110;i++);}//LCD忙检测函数bit lcd_busy(){bit result;LCD_RS=0;LCD_RW=1;LCD_EN= 1;result=(bit)(Part & 0x80); LCD_EN=0;return result;}//液晶写命令函数void lcd_write_cmd(uchar com) {while(lcd_busy());LCD_RS=0; //选择指令寄存器LCD_RW=0; //写LCD_EN=0;Part=com; //指令值赋给P0口delay(5);LCD_EN=1;delay(5);LCD_EN=0;}//液晶写一个字符数据函数void lcd_write_dat(uchar date){while(lcd_busy());LCD_RS=1; //选择数据寄存器LCD_RW=0; //写LCD_EN=0;P0=date; //数据值赋给P0口delay(5);LCD_EN=1;delay(5);LCD_EN=0;}//液晶写一个字符串函数void lcd_write_string(uchar *str){while(*str!='\0') //未结束{lcd_write_dat(*str++);delay(5);}}//液晶显示位置函数void lcd_pos(uchar x,uchar y) //从第X行的第Y位置开始显示{uchar pos;if(x==1) //第一行{ x=0x80;}else if(x==2) //第二行{ x=0x90;}else if(x==3) //第三行{ x=0x88;}else if(x==4) //第四行{ x=0x98;}pos=x+y-1; //首地址为0X80lcd_write_cmd(pos);}//液晶初始化函数void lcd_init(){LCD_PSB=1; //并行方式LCD_RST=1; //不复位lcd_write_cmd(0x30);delay(5);lcd_write_cmd(0x0c); //开显示,不显示光标delay(5);lcd_write_cmd(0x06); //写一个字符后地址指针自动加1 delay(5);lcd_write_cmd(0x01); //清屏delay(5);}//主函数函数void main(){// uchar i;lcd_init();while(1){lcd_pos(1,1);// lcd_write_string(dis1);lcd_write_string("床前明月光");delay(5);lcd_pos(2,1);// lcd_write_string(dis2);lcd_write_string("疑是地上霜");delay(5);lcd_pos(3,1);// lcd_write_string(dis3);lcd_write_string("举头望明月");delay(5);lcd_pos(4,1);// lcd_write_string(dis4);lcd_write_string("低头思故乡");delay(500);}}。
LCD12864xy坐标轴显示程序
#include<reg51.h>#define uchar unsigned char#define uint unsigned intuchar code shuzi[]={0x00,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};//0--8uchar code zuobiao[]={/*-- 调入了一幅图像:C:\Documents and Settings\Administrator\桌面\温度坐标.bmp --*/ /*-- 宽度x高度=128x64 --*/0x00,0x00,0x00,0x70,0x50,0xD0,0x00,0xF0,0x10,0xF0,0x00,0xFF,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xC1,0x01,0xC1,0x00,0xC1,0x41,0xC1,0x00,0xFF,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x01,0x01,0x07,0x00,0x07,0x04,0x07,0x00,0xFF,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x15,0x15,0x1F,0x00,0x1F,0x11,0x1F,0x00,0xFF,0x04,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x74,0x54,0x5C,0x00,0x7C,0x44,0x7C,0x00,0xFF,0x10,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xF0,0x10,0xF0,0x00,0xFF,0x40,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x01,0x01,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x44,0x7C,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x7D,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x75,0x55,0x5D,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x55,0x55,0x7D,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x1D,0x11,0x7D,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x5D,0x55,0x75,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x7D,0x55,0x75,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x05,0x05,0x7D,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x7D,0x55,0x7D,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x1D,0x15,0x7D,0x01,0x01,0x01,0x01,0x01,0x01,0x7D,0x01,0x7D,0x45,0x7D,0x01,0x01,0x01,0x01,0x01,0x01,0x7D,0x01,0x01,0x7D,0x01,0x01,0x01,0x01,};void delay(uint k);//延时void hua_zuobiao(void);//画坐标void wcode(uchar com,uchar cs1,uchar cs2);//写指令void wdata(uchar da,uchar cs1,uchar cs2);//写数据void set_startline(uchar i);//起始行void set_adr(uchar x,uchar y);//页值设置,起始列值函数void clear(void);///clear清屏void initi_LCD(void);//初始化LCDsbit RST=P3^0;sbit CS2=P3^5;sbit CS1=P3^4;sbit RS=P3^1;sbit RW=P3^3;sbit E=P3^2;void busy() //状态检查,LCD是否忙{P2=0X00;RS=0;RW=1;E=1;while(P2&0X80);//结果为真则一直执行空操作,也就是说P0&0X80为0则结束循环E=0;}void initi_LCD(void)//初始化LCD{wcode(0x3e,1,1);//显示开//0x3e关set_startline(0);//起始行第0行}void set_startline(uchar i)//起始行。
LCD12864菜单程序
一起来学LCD12864菜单程序(包含完整程序)一起来学LCD12864菜单程序(包含完整程序)/*-------------------------------------------项目名:家电中央控制系统工程程序名:显示MCU总体程序编写人:杜洋初写时间:2005年9月5日晚20时程序功能:实现液晶、语音部分的人机对话和总线的通信实现方法:用中断实现总线接收CPU说明:89S5212MHZ晶振接口说明:(详见初定义)信息说明:修改日志:NO.1--------------------------------------------*/;----------------------------------------初定义LCDDAT EQU P2RS EQU P3.5RW EQU P3.6E EQU P3.7REDLED EQU P3.4BACKLED EQU P3.1PLAY EQU P1.7STOPIN EQU P3.0LIN EQU P3.2SPDAT EQU P1XX2 EQU P0.0LT_RAM EQU 30HLR_RAM EQU 40HSP_RAM EQU 20HDIS1_RAM EQU 50HDIS2_RAM EQU 70HDIS3_RAM EQU 60HDIS4_RAM EQU 80HRR1 EQU 26HRR3 EQU 21HRR4 EQU 22HT0_RAM EQU 23HQR3_RAM EQU 24HQR2_RAM EQU 25HLCDDISPLAY EQU 26H ;菜单显示移位寄存器MENU_RAM EQU 27H;菜单位置寄存器ONOFFLCD EQU 28H;-------------------------------------程序入口ORG 0000HJMP LCD_STARTORG 0003HJMP LIN_INT0ORG 000BHJMP LED_T0ORG 0030H;--------------------------------------主程序开始LCD_START br>SETB PLAYMOV T0_RAM,#250MOV TMOD,#01HSETB ET0MOV TL0,#0B0H ;50MS 定时初值(T0计时用)MOV TH0,#3CH ;50MS定时初值CLR IT0SETB EX0SETB TR0SETB EAMOV DPTR,#TAB_0CALL START_LCD;-----自检程序CALL DL1SMOV MENU_RAM,#00HMOV DPTR,#TAB_HCALL START_LCDCLR LCDDISPLAY;--------------------------------------主循环体程序LCD_LOOP br>JB ONOFFLCD,DISPLAY_PROLCD_LOOP_1br>JMP LCD_LOOP;---------------------------- 菜单显示处理DISPLAY_PRO br>MOV A,MENU_RAMMOV DPTR,#MENUTAB_HOSTRLC AJMP @A+DPTRMENUNEXT br>CALL START_LCDCLR LCDDISPLAYCLR ONOFFLCDJMP LCD_LOOP;-------------------------MENUTAB_HOST:JMP HOST_H ;主菜单JMP HOST_1 ; 1,控制JMP HOST_2 ; 2,设置JMP HOST_3 ; 3,智能JMP HOST_4 ; 4,帮助<。
12864显示汉字,图型,任意点,任意直线程序(绝对能用)
#include<stdio.h>#include<reg52.h>#include<math.h>#include<intrins.h>sbit RS=P0^0;sbit RW=P0^1;sbit E=P0^2;sbit PSB=P0^3;sbit RES=P0^4;#define LCD12864_DatePort P2unsigned char lcd_x,lcd_y;unsigned char h[]={"aaaaaaaaaaaaaaaa"};unsigned char code image[1024]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0xC0,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0xFF,0xE0,0x00,0x00,0x00,0x1F,0xC1,0xC0,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x07,0xFF,0xF8,0x00,0x00,0x00,0xFF,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x1F,0xFF,0xFC,0x00,0x00,0x01,0xFF,0xFE,0x1F,0x80,0x00,0x00,0x00,0x00, 0x00,0x00,0x3F,0xFF,0xFF,0x00,0x00,0x07,0xFF,0xFF,0x9E,0xC0,0x00,0x00,0x00,0x00, 0x00,0x00,0x7F,0xFF,0xFF,0x80,0x00,0x0F,0xFF,0xFF,0xEC,0x60,0x00,0x00,0x00,0x00, 0x00,0x00,0xFF,0xFF,0xFF,0xC0,0x00,0x0F,0xFF,0xFF,0xE0,0x40,0x00,0x00,0x00,0x00, 0x00,0x01,0xFF,0x3E,0x3F,0xC0,0x00,0x1F,0xE3,0xE7,0xF0,0x80,0x00,0x00,0x00,0x00, 0x00,0x01,0xFE,0x1E,0x1F,0xE0,0x00,0x3F,0xE3,0xC3,0xF9,0x00,0x00,0x00,0x00,0x00, 0x00,0x03,0xFC,0x1C,0x1F,0xE0,0x00,0x3F,0xC1,0xC3,0xFC,0x00,0x00,0x00,0x00,0x00, 0x00,0x03,0xFC,0x6D,0x9F,0xF0,0x00,0x7F,0xC1,0x81,0xFE,0x00,0x00,0x00,0x00,0x00, 0x00,0x07,0xFC,0x6D,0x8F,0xF0,0x00,0x7F,0xCD,0xB1,0xFE,0x00,0x00,0x00,0x00,0x00, 0x00,0x07,0xFC,0x6D,0x9F,0xF0,0x00,0x7F,0xCF,0xB1,0xFF,0x00,0x00,0x00,0x00,0x00, 0x00,0x07,0xFC,0x1C,0x1F,0xF0,0x00,0xFF,0xC5,0xF3,0xFF,0x00,0x00,0x00,0x00,0x00, 0x00,0x07,0xFE,0x1E,0x1F,0xF8,0x00,0xFF,0xE3,0xC3,0xFF,0x00,0x00,0x00,0x00,0x00, 0x00,0x07,0xFF,0x3E,0x3F,0xF8,0x00,0xFF,0xE3,0xE7,0xFF,0x00,0x00,0x00,0x00,0x00, 0x00,0x0F,0xFF,0xF3,0xFF,0xF8,0x00,0xFF,0xFE,0x7F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x0F,0xF8,0xC1,0xCF,0xFC,0x00,0xFF,0x9C,0x38,0xFF,0x80,0x00,0x00,0x00,0x00, 0x00,0x0F,0xE0,0x7F,0x83,0xFC,0x01,0xFE,0x0F,0xF0,0x3F,0x80,0x00,0x00,0x00,0x00, 0x00,0x1F,0xFF,0x00,0x3F,0xFC,0x01,0xFF,0xE0,0x07,0xFF,0x80,0x00,0x00,0x00,0x00, 0x00,0x1F,0xFF,0xFB,0xFF,0xFC,0x01,0xBF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00, 0x00,0x1F,0xFF,0xFF,0xFF,0xFC,0x01,0xDF,0xFF,0xFF,0xFB,0x80,0x00,0x00,0x00,0x00, 0x00,0x3F,0xFF,0xFF,0xFF,0xFC,0x03,0xC7,0xFF,0xFF,0xE7,0x80,0x00,0x00,0x00,0x00, 0x00,0x7F,0xFF,0xFF,0xFF,0xFC,0x07,0xC1,0xFF,0xFF,0x8F,0xC0,0x00,0x00,0x00,0x00, 0x00,0xFF,0xFF,0xFF,0xFF,0xFE,0x0F,0xE0,0x3F,0xFC,0x3F,0xC0,0x00,0x00,0x00,0x00, 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0xF8,0x00,0x00,0x7F,0xE0,0x00,0x00,0x00,0x00, 0x01,0xFC,0x7F,0xFF,0xFF,0x3F,0x1F,0x8E,0x00,0x00,0xE3,0xF0,0x00,0x00,0x00,0x00, 0x03,0xF8,0x7F,0xFF,0xFC,0x1F,0xBF,0x87,0xC8,0x1F,0x83,0xF0,0x00,0x00,0x00,0x00, 0x03,0xF8,0x7F,0xFF,0xE0,0x1F,0xFF,0x87,0xFF,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00, 0x03,0xF8,0x7F,0x00,0x00,0x1F,0xFF,0x04,0xE0,0x00,0x01,0xF8,0x00,0x00,0x00,0x00, 0x07,0xF8,0x7F,0x00,0x00,0x0F,0xFF,0x04,0x60,0x00,0x01,0xF8,0x00,0x00,0x00,0x00, 0x07,0xF8,0x7F,0x00,0x00,0x0F,0xFF,0x0C,0x60,0x00,0x01,0xFC,0x00,0x00,0x00,0x00, 0x07,0xF8,0x7F,0x00,0x00,0x0F,0xFF,0x0C,0x60,0x00,0x01,0xFC,0x00,0x00,0x00,0x00, 0x07,0xF8,0x7F,0x00,0x00,0x0F,0xFF,0x06,0x60,0x00,0x01,0xFC,0x00,0x00,0x00,0x00, 0x07,0xB8,0x3E,0x00,0x00,0x19,0xF3,0x87,0xE0,0x00,0x01,0xBC,0x00,0x00,0x00,0x00, 0x07,0x18,0x00,0x00,0x00,0x18,0xE3,0x80,0x00,0x00,0x01,0x18,0x00,0x00,0x00,0x00, 0x00,0x1C,0x00,0x00,0x00,0x10,0x01,0x80,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00, 0x00,0x0C,0x00,0x00,0x00,0x30,0x01,0xC0,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00, 0x00,0x06,0x00,0x00,0x00,0x60,0x00,0xE0,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00, 0x00,0x03,0x00,0x00,0x00,0x40,0x00,0x70,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00, 0x00,0x03,0x80,0x00,0x00,0xC0,0x00,0x78,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00, 0x00,0x0D,0xE0,0x00,0x03,0xB8,0x01,0x9C,0x00,0x00,0x3B,0x00,0x00,0x00,0x00,0x00, 0x00,0x18,0x78,0x00,0x0F,0x7C,0x03,0xCF,0x00,0x00,0xE7,0x80,0x00,0x00,0x00,0x00, 0x00,0x10,0x1C,0x00,0x3E,0xFC,0x03,0xF3,0xE0,0x03,0xDF,0x80,0x00,0x00,0x00,0x00, 0x00,0x1A,0x0B,0xC1,0xE3,0xF8,0x01,0xF8,0xFC,0x3F,0x3F,0x00,0x00,0x00,0x00,0x00, 0x00,0x0F,0xF1,0x80,0xEF,0xE0,0x00,0x7F,0xF0,0x1F,0xFC,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};void delay_ms(unsigned char z) //延时{unsigned i,j;for(i=0;i<z;i++)for(j=0;j<110;j++);}void LCD12864_WriteCmd(unsigned int cmd) //写命令{RS=0;RW=0;E=0;LCD12864_DatePort=cmd;delay_ms(5);E=1;delay_ms(5);E=0;}void LCD12864_WriteDate(unsigned char dat) //写数据{RS=1;RW=0;E=0;LCD12864_DatePort=dat;delay_ms(5);E=1;delay_ms(5);E=0;}void LCD12864_Init(){PSB=1; //1并行,0串行LCD12864_WriteCmd(0x30); //基本指令操作//delay_ms(5);LCD12864_WriteCmd(0x0c); //显示开,关光标//delay_ms(5);LCD12864_WriteCmd(0x01); //清除led的显示内容//delay_ms(5);LCD12864_WriteCmd(0x06);}/*====================================================函数功能:清除GCROM的内容,如果不清除会出现花屏现象清除方法:向GCROM中写入0x00来清除内========================================================*/ void LCD12864_ClearGDRAM(){unsigned char i,j,k;lcd_x=0x80;lcd_y=0x80;LCD12864_WriteCmd(0x34);for(i=0;i<2;i++){for(j=0;j<32;j++){LCD12864_WriteCmd(lcd_y+j);LCD12864_WriteCmd(lcd_x);for(k=0;k<16;k++){LCD12864_WriteDate(0x00);}}lcd_x=0x88;}LCD12864_WriteCmd(0x36);LCD12864_WriteCmd(0x30);}/*================================================================ 函数功能:向12864中写入一幅图片函数参数:lcd_x为水平显示位置,lcd_y为垂直显示位置,函数将12864屏分成上下两屏写入,上半屏LCD_x=0x80,下半屏lcd_x=0x88=================================================================*/ void LCD12864_WriteImage(unsigned char *p){unsigned char i,j,k;lcd_x=0x80;lcd_y=0x80;LCD12864_WriteCmd(0x34);for(i=0;i<2;i++) //分为上下两屏{for(j=0;j<32;j++){LCD12864_WriteCmd(lcd_y+j);LCD12864_WriteCmd(lcd_x);for(k=0;k<16;k++) //写入显示数据{LCD12864_WriteDate(*p++);}}lcd_x=0x88;}LCD12864_WriteCmd(0x36);LCD12864_WriteCmd(0x30);}bit LCD12864_CheckBusy() //读忙碌状态{bit i;RS=0;RW=1;E=1;LCD12864_DatePort=0xff;delay_ms(1);i=(bit)(LCD12864_DatePort&0x80);E=0;return(i);}unsigned char LCD12864_ReadByte( void ){unsigned char ReturnValue ;LCD12864_CheckBusy() ;LCD12864_DatePort = 0xff ;RS=1;RW=1;E=0;E=1;ReturnValue =LCD12864_DatePort;E=0;return ReturnValue ;}void LCD12864_DrawPoint( unsigned char X, unsigned char Y, unsigned char Color ) {unsigned char Row , Tier , Tier_bit ;unsigned char ReadOldH, ReadOldL ;LCD12864_WriteCmd( 0x34 ) ;LCD12864_WriteCmd( 0x36 ) ;Tier = X >> 4 ;Tier_bit = X & 0x0f ;if( Y < 32 ){Row = Y ;}else{Row = Y - 32 ;Tier += 8 ;}LCD12864_WriteCmd( Row + 0x80 ) ;LCD12864_WriteCmd( Tier + 0x80 ) ;LCD12864_ReadByte();ReadOldH = LCD12864_ReadByte() ;ReadOldL = LCD12864_ReadByte() ;LCD12864_WriteCmd( Row + 0x80 ) ;LCD12864_WriteCmd( Tier + 0x80 ) ;if( Tier_bit < 8 ){switch( Color){case 0 : ReadOldH &=( ~( 0x01 << ( 7 - Tier_bit ))) ; break ;case 1 : ReadOldH |= ( 0x01 << ( 7 - Tier_bit )) ; break ;case 2 : ReadOldH ^= ( 0x01 << ( 7 - Tier_bit )) ; break ;default : break ;}LCD12864_WriteDate( ReadOldH ) ;LCD12864_WriteDate( ReadOldL ) ;}else{switch(Color){case 0 : ReadOldL &= (~( 0x01 << ( 15 - Tier_bit ))) ; break ;case 1 : ReadOldL |= ( 0x01 << ( 15 - Tier_bit )) ; break ;case 2 : ReadOldL ^= ( 0x01 << ( 15 - Tier_bit )) ; break ;default : break ;}LCD12864_WriteDate( ReadOldH ) ;LCD12864_WriteDate( ReadOldL ) ;}LCD12864_WriteCmd( 0x30 ) ;}void LCD12864_DrawLine_X( unsigned char X0, unsigned char X1, unsigned char Y, unsigned char Color ){ unsigned char Temp ;if( X0 > X1 ){Temp = X1 ;X1 = X0 ;X0 = Temp ;}for( ; X0 <= X1 ; X0++ )LCD12864_DrawPoint( X0, Y, Color ) ;}void LCD12864_DrawLine_Y( unsigned char X, unsigned char Y0, unsigned char Y1, unsigned char Color ){unsigned char Temp ;if( Y0 > Y1 ){Temp = Y1 ;Y1 = Y0 ;Y0 = Temp ;}for(; Y0 <= Y1 ; Y0++)LCD12864_DrawPoint( X, Y0, Color) ;}void LCD12864_DrawLine( unsigned char StartX, unsigned char StartY, unsigned char EndX, unsigned char EndY, unsigned char Color ){int t, distance; /*根据屏幕大小改变变量类型(如改为int型)*/int x = 0 , y = 0 , delta_x, delta_y ;char incx, incy ;delta_x = EndX - StartX ;delta_y = EndY - StartY ;if( delta_x > 0 ){incx = 1;}else if( delta_x == 0 ){LCD12864_DrawLine_Y( StartX, StartY, EndY, Color ) ;return ;}else{incx = -1 ;}if( delta_y > 0 ){incy = 1 ;}else if(delta_y == 0 ){LCD12864_DrawLine_X( StartX, EndX, StartY, Color ) ;return ;}else{incy = -1 ;}delta_x = abs( delta_x );//求绝对值delta_y = abs( delta_y );if( delta_x > delta_y ){distance = delta_x ;}else{distance = delta_y ;}LCD12864_DrawPoint( StartX, StartY, Color ) ;/* Draw Line*/for( t = 0 ; t <= distance+1 ; t++ ){LCD12864_DrawPoint( StartX, StartY, Color ) ;x += delta_x ;y += delta_y ;if( x > distance ){x -= distance ;StartX += incx ;}if( y > distance ){y -= distance ;StartY += incy ;}}}void LCD12864_DrawCross(){LCD12864_DrawLine_X( 0, 127 , 0, 1 ) ;LCD12864_DrawLine_X( 0, 127 , 7, 1 ) ;LCD12864_DrawLine_X( 0, 127 , 15, 1 ) ;LCD12864_DrawLine_X( 0, 127 , 23, 1 ) ;LCD12864_DrawLine_X( 0, 127 , 31, 1 ) ;LCD12864_DrawLine_X( 0, 127 , 39, 1 ) ;LCD12864_DrawLine_X( 0, 127 , 47, 1 ) ;LCD12864_DrawLine_X( 0, 127 , 55, 1 ) ;LCD12864_DrawLine_X( 0, 127 , 63, 1 ) ;LCD12864_DrawLine_Y( 0, 0 , 63, 1 ) ;LCD12864_DrawLine_Y( 15, 0 , 63, 1 ) ;LCD12864_DrawLine_Y( 31, 0 , 63, 1 ) ;LCD12864_DrawLine_Y( 47, 0 , 63, 1 ) ;LCD12864_DrawLine_Y( 63, 0 , 63, 1 ) ;LCD12864_DrawLine_Y( 79, 0 , 63, 1 ) ;LCD12864_DrawLine_Y( 95, 0 , 63, 1 ) ;LCD12864_DrawLine_Y( 111, 0 , 63, 1 ) ;LCD12864_DrawLine_Y( 127, 0 , 63, 1 ) ;}void LCD12864_Draw_ObliqueLine(){LCD12864_DrawLine( 0, 0, 127, 63, 1 ) ;LCD12864_DrawLine( 0, 63, 127, 0 , 1 ) ;LCD12864_DrawLine( 12, 0, 127, 63, 1 ) ;LCD12864_DrawLine( 52, 63, 127, 0 , 1 ) ;LCD12864_DrawLine( 32, 63, 98, 0, 1 ) ;LCD12864_DrawLine( 67, 0, 127, 63 , 1 ) ;}void LCD12864_DisplayOneChar(unsigned char X, unsigned char Y, unsigned char Data) {switch(Y){case 0:Y=0X80;break; //根据行数来选择相应地址case 1:Y=0X90;break;case 2:Y=0X88;break;case 3:Y=0X98;break;}LCD12864_WriteCmd( Y+X ); //这里不检测忙信号,发送地址码LCD12864_WriteDate(Data);}void LCD12864_DisplayListChar(unsigned char X, unsigned char Y, unsigned char *Data) {switch(Y){case 0:Y=0X80;break; //根据行数来选择相应地址case 1:Y=0X90;break;case 2:Y=0X88;break;case 3:Y=0X98;break;}LCD12864_WriteCmd( Y+X ); //这里不检测忙信号,发送地址码X = X*2;Y = 0;while( Data[Y] != 0 ) //若到达字串尾则退出{if (X <= 0x0F) //X坐标应小于0xF{LCD12864_WriteDate(Data[Y]);X++;Y++;}else break;}}void main(){LCD12864_Init();// write_com(0x1c);LCD12864_ClearGDRAM();//LCD12864_WriteImage(image);//LCD12864_Draw_ObliqueLine();LCD12864_DrawCross();//LCD12864_DisplayListChar(0,0,h);while(1);}。
LCD12864显示程序
本例程为通过用AT89C52芯片把持LCD12864显示的法式, 使用的晶振为12M.之马矢奏春创作/**********************************************************法式说明:LCD12864显示主法式法式调试员:莫剑辉调试时间:2010-6-7**********************************************************/#include<reg52.h>#include"12864.c"void main(){Ini_Lcd(); //液晶初始化子法式Disp(1,0,6,"莫剑辉"); //显示数据到LCD12864子法式while(1);}这里我们通过调用下面的头文件就可以了, 这样的做法方便我们以后要用到LCD12864的法式的调用./**********************************************************法式说明:LCD12864显示头文件法式调试员:莫剑辉调试时间:2010-6-7********************************************************* *///#include<reg52.h>#define uchar unsigned char#define uint unsigned int#define DATA P2 //数据输出端0~7sbit RS=P0^0; //LCD12864 RS端sbit RW=P0^1; //LCD12864 RW端sbit E =P0^2; //LCD12864 E 端sbit PSB =P0^3;/*********************************************延时子法式*********************************************/void Delay_1ms(uint x){uint j,i;for(j=0;j<x;j++){for(i=0;i<120;i++); //延时X乘以120}}/*********************************************LCD12864液晶测忙子法式(读状态)*********************************************/void Busy(){uchar busy;do{E = 0; //0为关闭使能端,1为翻开使能端RS = 0; //1为指令,0为数据RW = 1; //1为读,0为写Delay_1ms(20); //延时20乘以120时间E = 1; //0为关闭使能端,1为翻开使能端busy=P1; //读取P2状态Delay_1ms(20); //延时20乘以120时间E = 0; //0为关闭使能端,1为翻开使能端}while(busy&0x80); //判断BUSY位是否工作:1为内部在工作,0为正常状态}/********************************************* LCD12864液晶数据写入子法式*********************************************/ void Write_Data(uchar k){Busy(); //测忙E =1;//0为关闭使能端,1为翻开使能端RS=1;//1为指令,0为数据RW=0;//1为读,0为写DATA=k;//输入数据K到DATADelay_1ms(20);//延时20乘以120时间E =0; //0为关闭使能端,1为翻开使能端Delay_1ms(20); //延时20乘以120时间}/********************************************* LCD12864液晶命令写入子法式*********************************************/ void Write_Cmd(uchar cmd){Busy(); //测忙E=1;//0为关闭使能端,1为翻开使能端RS=0; //1为指令,0为数据RW=0;//1为读,0为写DATA=cmd; //输入命令cmd到DATADelay_1ms(20);//延时20乘以120时间E=0;//0为关闭使能端,1为翻开使能端Delay_1ms(20);//延时20乘以120时间}/*********************************************LCD12864液晶数据显示子法式*********************************************/void Disp(uchar y,uchar x,uchar i,uchar *z){uchar Address;if(y==1){Address=0x80+x;} //Y判断第几行,X判断第几列,0x80为液晶行初始地址if(y==2){Address=0x90+x;}if(y==3){Address=0x88+x;}if(y==4){Address=0x98+x;}Write_Cmd(Address); //写入地址命令到LCD12864while(i) //写入显示数据的年夜小{Write_Data(*(z++)); //写入显示数据到LCD12864i--;}}/********************************************* LCD12864液晶初始化子法式*********************************************/ void Ini_Lcd(void){PSB=1;Delay_1ms(20);Write_Cmd(0x30); //基本指令集Delay_1ms(20);Write_Cmd(0x02); // 地址归位Delay_1ms(20);Write_Cmd(0x0c); //整体显示翻开,游标关闭 Delay_1ms(20);Write_Cmd(0x06); //游标右移Delay_1ms(20);Write_Cmd(0x80); //设定显示的起始地址Delay_1ms(20);Write_Cmd(0x01); //清除显示}。
LCD12864(并口)显示程序
#ifndef jh_f330#define jh_f330#include<c8051f330.h>#endiftypedef unsigned char uint8;typedef unsigned int uint16;/*************端口配置**************///******************************************************sbit CS =P0^4;sbit RSET=P0^3;sbit A0 =P0^2;sbit WR =P0^1;sbit RD =P0^0;#define DATAPORT P1 //数据口uint8 code word1[]={0x04,0x44,0x84,0x04,0xE4,0x1F,0x84,0x44,0xA4,0x3F,0xA4,0xA4,0x64,0x06,0x04,0x00, 0x20,0x10,0x09,0x04,0xFF,0x04,0x04,0x14,0x26,0x05,0x84,0xFF,0x04,0x06,0x04,0x00 };/**********预定义数据*********/#define LCD_X 128-1 //屏幕的X轴的物理宽度#define LCD_Y 64-1 //屏幕的Y轴的物理宽度/***********LCD指令集***************///LCD开关命令#define LCD_ON() Wr_Com(0xaf)#define LCD_OFF() Wr_Com(0xae)//设置显示起始行#define LCD_START_LINE 0x40 //起始行地址为,0x40+(0-63)//页地址设置#define LCD_Page 0xb0 //页地址为:0xb0+(0-8)//列地址设置#define LCD_Ad_H 0x10 //列高四位地址:0x10+()#define LCD_Ad_L 0x00 //列低四位地址:0x00+()//行列地址方向设置#define ADC_Norm() Wr_Com(0xa0);#define ADC_Reve() Wr_Com(0xa1);#define Com_Norm() Wr_Com(0xc0);#define Com_Reve() Wr_Com(0xc8);void Init_f330(){/*****内部振荡器配置******/OSCICL=OSCICL+4; //设置系统时钟为24MHZ,ΔT=(0.005*ΔOSCICL)/fbase // OSCICL=OSCICL+22; //设置系统时钟为22.1184MHZ// OSCICL=OSCICL+45; //设置系统时钟为20MHZ //15MHZ--24.5MHZ/********设置分频*********/// OSCICN|=0x00; //设置时钟为八分频,OSCIN复位值为1100000//00:8分频,01:4分频,10:2分频,11:不分频// OSCICN|=0x01; //设置系统时钟4分频// OSCICN|=0x02; //设置系统时钟2分频OSCICN|=0x03; //设置系统时钟不分频// RSTSRC=0x04;// OSCLCN = 0x82; // 设置内部L-F振荡器为40kHZ// CLKSEL = 0x02; // 内部低频振荡器while(OSCLCN&0x40 == 0); // 等待振荡器频率稳定/*****设置看门狗*****/PCA0MD &=~0x40; // 禁止看门狗定时器EA=1;/*****端口初始化******/P0MDIN = 0xff; //复位值为11111111P1MDIN = 0xff; //1为数字输入,0为模拟输入P0MDOUT = 0xff; //复位值为11111111P1MDOUT = 0xff; //1为推挽输出,0为漏极输出XBR0 = 0x00; // 交叉开关使能XBR1 = 0x40; //交叉开关允许,T0接到引脚//XBR1 = 0x48; // ECI连到端口引脚//XBR1 |= 0x08; // PCA0 外部计数输入使能}/****************************************函数名:Wr_com**功能:LCD12864写命令程序**输入:uint8 com***************************************/void Wr_Com(uint8 com){A0=0; //命令数据选通,H:数据,L:命令CS=0; //芯片选通,低电平有效RD=1; //L:读信号WR=0; //L:写信号//nop();Data=com;WR=1;CS=1;}/****************************************函数名:Wr_Dat**功能:LCD12864写数据程序**输入:uint8 dat***************************************/void Wr_Dat(uint8 dat){A0=1; //命令数据选通,H:数据,L:命令CS=0; //芯片选通,低电平有效RD=1; //L:读信号WR=0; //L:写信号//nop();Data=dat;WR=1;CS=1;}/***************************************函数名称:LCD_Fill()**功能:LCD全屏显示数据程序**输入:8位数据**输出:无************************************/void LCD_Fill(uint8 dat){uint8 page;uint8 colume;for(page=0;page<8;page++){Wr_Com(LCD_Page+page);Wr_Com(LCD_Ad_H);Wr_Com(LCD_Ad_L);for(colume=0;colume<LCD_X;colume++)Wr_Dat(dat);}}/***************************************函数名称:LCD_Clear()**功能:LCD清屏程序(全屏填充0x00)**输入:8位数据**输出:无************************************/void LCD_Clear(){LCD_Fill(0x00);}/******************************************************* ** 函数名称: LCD12864_Init** 功能: LCD1286初始化程序** 输入: 无TimeDelay ** 输出: 无********************************************************/ void TimeDelay(int Time){int i;while(Time > 0){for(i = 0;i < 8000;i++){}Time --;}}void LCD_Init(void){LCD_RST=0;TimeDelay(200);LCD_RST=1;TimeDelay(200);ADC_Norm();Com_Reve();Wr_Com(0xa2);Wr_Com(0x2c); //vc onTimeDelay(200);Wr_Com(0x2e); //vr onTimeDelay(200);Wr_Com(0x2f); //internal booster,follower,divided onWr_Com(0x24); //set rb/ra=5.29Wr_Com(0x81); //set reference voltage selectWr_Com(0x1d);LCD_ON();Wr_Com(LCD_START_LINE);}/***********************************************************************函数名称:LCD_Word()**功能:输入单个汉字(16x16符号)**输入:页地址,列地址、字符数组**输出:无***********************************************************************/ void LCD_Word(unsigned char row,unsigned char colume,unsigned char *pword){unsigned char page= row;unsigned char col_high=colume>>4;unsigned char col_low =colume&0x0f;unsigned char i;Wr_Com(LCD_Page+page);Wr_Com(LCD_Ad_H+col_high);Wr_Com(LCD_Ad_L+col_low);for(i=0;i<16;i++){Wr_Dat(*(pword+i));}Wr_Com(LCD_Page+page+1);Wr_Com(LCD_Ad_H+col_high);Wr_Com(LCD_Ad_L+col_low);for(i=0;i<16;i++){Wr_Dat(*(pword+16+i));}main(){Init_f330();LCD_Init();LCD_Clear();LCD_Word(1,1,word1);while(1);}。
多种12864液晶屏显示程序
多种12864液晶屏显示程序(1)#include#define uchar unsigned char#define uint unsigned int#define lcddata P0sbit RS=P2^0;sbit RW=P2^1;sbit E=P2^2;sbit PSB=P2^3;void delayms(uint n)//1T单片机毫秒延时函数{ unsigned int x;while(n--){x=627;while(x--);}}void delayus(uint t)//1T单片机微秒延时函数{ unsigned int a,b;for(b=t;b>0;b--)for(a=3;a>0;a--);}bit lcdbusy() //忙检查{bit result;RS=0;RW=1;E=1;delayus(5);result=(bit)(P0&0x80);E=0;return(result) ;}void writecmd(uchar cmd) //写命令{while(lcdbusy()) ;RS=0;RW=0;E=0;delayus(5);P0=cmd;delayus(10);E=1;delayus(5);E=0;}void writedat(uchar dat) //写数据{while(lcdbusy()) ;RS=1;RW=0;E=0;delayus(5);P0=dat;delayus(10);E=1;delayus(5);E=0;}void print(uchar place,uchar num,uchar *point)//液晶屏显示数组{uchar i,progdata;writecmd(place);for(i=0;i<="">{progdata=*(point+i);writedat(progdata);}}void lcdclear(){unsigned char i;writecmd(0x30);writecmd(0x80);writecmd(0x01);delayus(20);for(i=0;i<64;i++)writedat(' ');}void lcdinit()//液晶屏初始化{PSB=1;//并口方式writecmd(0x30);//基本指令操作delayms(5);writecmd(0x06);//写一个字符后地址指针自动加1 delayms(5);writecmd(0x0c);//开显示,关光标delayms(5);writecmd(0x01);//清屏指令delayms(5);}void main(){lcdinit();print(0x80,3,"战斗机");//起始位,显示汉字数print(0x85,3,"巡洋舰");print(0x8a,4,"航空母舰");while(1);}(2)#include#define uchar unsigned char#define uint unsigned int#define lcddata P0sbit RS=P2^0;sbit RW=P2^1;sbit E=P2^2;sbit PSB=P2^3;void delayms(uint n)//1T单片机毫秒延时函数{ unsigned int x;while(n--){x=627;while(x--);}}void delayus(uint t)//1T单片机微秒延时函数{ unsigned int a,b;for(b=t;b>0;b--)for(a=3;a>0;a--);}bit lcdbusy() //忙检查{bit result;RS=0;RW=1;E=1;delayus(5);result=(bit)(P0&0x80);E=0;return(result) ;}void writecmd(uchar cmd) //写命令{while(lcdbusy()) ;RS=0;RW=0;E=0;delayus(5);P0=cmd;delayus(10);E=1;delayus(5);E=0;}void writedat(uchar dat) //写数据{while(lcdbusy()) ;RS=1;RW=0;E=0;delayus(5);P0=dat;delayus(10);E=1;delayus(5);E=0;}void lcdpos(uchar x,uchar y)//液晶屏显示位置,x轴0~7,y轴0~7 {uchar pos;if(x==0){x=0x80;}else if(x==1){x=0x90;}else if(x==2){x=0x88;}else if(x==3){x=0x98;}pos=x+y;writecmd(pos);}void print(uchar *str) //液晶屏显示数组{while(*str!='\0'){writedat(*str);str++;}}void lcdclear()//液晶屏清屏函数{unsigned char i;writecmd(0x30);writecmd(0x80);writecmd(0x01);delayus(20);for(i=0;i<64;i++)writedat(' ');}void lcdinit()//液晶屏初始化{PSB=1;//并口方式writecmd(0x30);//基本指令操作delayms(5);writecmd(0x06);//写一个字符后地址指针自动加1 delayms(5); writecmd(0x0c);//开显示,关光标delayms(5);writecmd(0x01);//清屏指令delayms(5);}void main(){lcdinit();lcdpos(0,0);//起始位(行数,列数)print("战斗机");lcdpos(0,5);print("巡洋舰");lcdpos(2,2);print("航空母舰");while(1);}(3)#include#define uchar unsigned char#define uint unsigned int#define lcddata P0sbit RS=P2^0;sbit RW=P2^1;sbit E=P2^2;sbit PSB=P2^3;uchar code dis1[]="战斗机"; //液晶屏一行显示8个汉字,16个字节(i=0;i<16;i++)uchar code dis2[]="巡洋舰";uchar code dis3[]="航空母舰";void delayms(uint n)//1T单片机毫秒延时函数{unsigned int x;while(n--){x=627;while(x--);}}void delayus(uint t)//1T单片机微秒延时函数{unsigned int a,b;for(b=t;b>0;b--)for(a=3;a>0;a--);}bit lcdbusy() //忙检查{bit result;RW=1;E=1;delayus(5);result=(bit)(P0&0x80);E=0;return(result) ;}void writecmd(uchar cmd) //写命令{while(lcdbusy()) ;RS=0;RW=0;E=0;delayus(5);P0=cmd;delayus(10);E=1;delayus(5);E=0;}void writedat(uchar dat) //写数据{while(lcdbusy()) ;RS=1;RW=0;E=0;delayus(5);P0=dat;delayus(10);delayus(5);E=0;}void lcdpos(uchar x,uchar y)//液晶屏显示位置,x轴0~7,y轴0~7 {uchar pos;if(x==0){x=0x80;}else if(x==1){x=0x90;}else if(x==2){x=0x88;}else if(x==3){x=0x98;}pos=x+y;writecmd(pos);}void lcdclear()//液晶屏清屏函数{unsigned char i;writecmd(0x30);writecmd(0x80);writecmd(0x01);delayus(20);for(i=0;i<64;i++)writedat(' ');}void lcdinit()//液晶屏初始化{PSB=1;//并口方式writecmd(0x30);//基本指令操作delayms(5);writecmd(0x06);//写一个字符后地址指针自动加1delayms(5);writecmd(0x0c);//开显示,关光标delayms(5);writecmd(0x01);//清屏指令delayms(5);}void main(){uint i;lcdinit();lcdpos(0,0);//起始位(行数,列数)for(i=0;i<6;i++)//占用字节数(一个汉字占两个字节,一个字母、数字、符号占一个字节)writedat(dis1[i]);lcdpos(0,5);for(i=0;i<6;i++)writedat(dis2[i]);lcdpos(2,2);for(i=0;i<8;i++)writedat(dis3[i]);while(1);}(4)#include#define uchar unsigned char#define uint unsigned int#define lcddata P0sbit RS=P2^0;sbit RW=P2^1;sbit E=P2^2;sbit PSB=P2^3;uchar code dis1[]="战斗机"; //液晶屏一行显示8个汉字,16个字节(i=0;i<16;i++)uchar code dis2[]="巡洋舰";uchar code dis3[]="航空母舰";void delayms(uint n)//1T单片机毫秒延时函数{unsigned int x;while(n--){x=627;while(x--);}}void delayus(uint t)//1T单片机微秒延时函数{unsigned int a,b;for(b=t;b>0;b--)for(a=3;a>0;a--);}bit lcdbusy() //忙检查{bit result;RS=0;RW=1;E=1;delayus(5);result=(bit)(P0&0x80);E=0;return(result) ;}void writecmd(uchar cmd) //写命令{while(lcdbusy()) ;RS=0;RW=0;E=0;delayus(5);P0=cmd;delayus(10);E=1;delayus(5);E=0;}void writedat(uchar dat) //写数据{while(lcdbusy()) ;RS=1;RW=0;E=0;delayus(5);P0=dat;delayus(10);E=1;delayus(5);E=0;}void lcdpos(uchar x,uchar y)//液晶屏显示位置,x轴0~7,y轴0~7 {uchar pos;if(x==0){x=0x80;}else if(x==1){x=0x90;}else if(x==2){x=0x88;}else if(x==3){x=0x98;}pos=x+y;writecmd(pos);}void lcdclear()//液晶屏清屏函数{unsigned char i;writecmd(0x30);writecmd(0x80);writecmd(0x01);delayus(20);for(i=0;i<64;i++)writedat(' ');}void lcdinit()//液晶屏初始化{PSB=1;//并口方式writecmd(0x30);//基本指令操作delayms(5);writecmd(0x06);//写一个字符后地址指针自动加1 delayms(5); writecmd(0x0c);//开显示,关光标delayms(5);writecmd(0x01);//清屏指令delayms(5);}void main(){uint i;lcdinit();lcdpos(0,0);//起始位(行数,列数)i=0;while(dis1[i]!='\0'){writedat(dis1[i]);//显示字符i++;}lcdpos(0,5);i=0;while(dis2[i]!='\0'){writedat(dis2[i]);i++;}lcdpos(2,2);i=0;while(dis3[i]!='\0'){writedat(dis3[i]);i++;}while(1); }(5)#include#define uchar unsigned char#define uint unsigned intsbit CS=P2^0; //片选信号sbit SID=P2^1; //数据信号sbit SCLK=P2^2; //时钟信号sbit PSB=P2^3; //串并行选择,H并行,L串行sbit key=P3^0;unsigned char code temp1[]={"战斗机"}; unsigned char code temp2[]={"航空母舰"};void delayms(uint n)//毫秒延时{unsigned int x;while(n--){x=627;while(x--);}}void delay(uint m)//100us延时{unsigned int da,db;for(da=0;da<m;da++)< bdsfid="537" p=""></m;da++)<> for(db=0;db<100;db++);}void sendbyte(uchar bbyte) //发送一个字节{unsigned char i;for(i=0;i<8;i++){SID=bbyte&0x80;SCLK=1;SCLK=0;bbyte<<=1;}}void writechar(bit start,uchar ddata) //写指令或数据{unsigned char start_data,Hdata,Ldata;if(start==0)start_data=0xf8;elsestart_data=0xfa;Hdata=ddata&0xf0;Ldata=(ddata<<4)&0xf0;sendbyte(start_data);delay(5);sendbyte(Hdata);delay(1);sendbyte(Ldata);delay(1);}void lcdsetxy(uchar x,uchar y)//设置LCD显示的起始位置,X 为行,Y为列{uchar address;switch(x){case 0: address = 0x80 + y; break;case 1: address = 0x80 + y; break;case 2: address = 0x90 + y; break;case 3: address = 0x88 + y; break;case 4: address = 0x98 + y; break;default:address = 0x80 + y; break;}writechar(0, address);}void print(uchar X,uchar Y,uchar *s)//中英文字符串显示函数{lcdsetxy( X, Y );while (*s){writechar( 1, *s );s ++;delay(1);}}void lcdclear() //清屏函数{writechar(0,0x01);}void lcdinit(){delay(10);PSB=0;CS=1;writechar(0,0x30); writechar(0,0x0c); writechar(0,0x01); } void main(){lcdinit();print(1,2,temp1);print(3,2,temp2);while(1);}。
液晶显示12864程序(调试通过)
0x00,0x00,0x1F,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x38,0x0E,0x01,0xFF,0x1F,0xF8,0x00,0x07,0xFE,0x03,0xF8,0x00,0xFF,0xFF,0x00,
0x00,0x3C,0x06,0x01,0xFC,0x1F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xFF,0xFF,0xC0,0x00,0x00,0x0F,0xFF,0xFF,0xF0,0x00,0x00,0x1F,
0xFF,0xFF,0xFE,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0x00,0x00,0x7F,0xFF,0xF8,0x07,0x80,
0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7F,0xF8,0x07,0x80,0x3F,0x01,0xFF,0xF0,0x07,0xE0,0x00,0x07,0xFF,0xF0,0x03,0xF0,
0x00,0x1F,0xFF,0xE0,0x01,0xFF,0x03,0xFF,0xFF,0xC0,0x01,0xFF,0xFF,0xFF,0xFF,0xC0,
LCD12864液晶显示原理电路图程序
DB0X=8∫PAGE7DB74、设置列地址CODE:R/W D/I DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0L L L H列地址(0~63)功能:DD RAM 的列地址存储在Y地址计数器中,读写数据对列地址有影响,在对DD RAM进行读写操作后,Y地址自动加一。
5、状态检测CODE:R/W D/I DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0H L BF L ON/OFF RST L L L L功能:读忙信号标志位(BF)、复位标志位(RST)以及显示状态位(ON/OFF)。
BF=H:内部正在执行操作;BF=L:空闲状态。
RST=H:正处于复位初始化状态;RST=L:正常状态。
ON/OFF=H:表示显示关闭;ON/OFF=L:表示显示开。
6、写显示数据CODE:R/W D/I DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0L H D7D6D5D4D3D2D1D0功能:写数据到DD RAM,DD RAM是存储图形显示数据的,写指令执行后Y地址计数器自动加1。
D7-D0位数据为1表示显示,数据为0表示不显示。
写数据到DD RAM前,要先执行“设置页地址”及“设置列地址”命令。
7、读显示数据CODE:RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0H H D7D6D5D4D3D2D1D0功能:从DD RAM读数据,读指令执行后Y地址计数器自动加1。
从DD RAM读数据前要先执行“设置页地址”及“设置列地址”命令。
六、接口时序1.写操作时序时序1读操作时序时序2时序参数表:名称符号最小值典型值最大值单位E周期时间Tcyc1000nsE高电平宽度Pweh450nsE低电平宽度Pwel450ns九、读写模块程序举例 写指令子程序(INST ) SETB E CLR D_I CLR R_W MOV P1, A CLR E RET写数据子程序(DATA ) SETB E SETB D_I CLR R_W MOV P1, A CLR E RET写一页显示RAM 数据(假设指令子程序为INST ,数据子程序为DATA ) MOV A , #0B8H LCALL INST ;置页地址为0页 MOV A , #40H LCALL INST ;置列地址为0列 MOV R2, #40H MOV R1, #00H MOV DPTR ,#ADDR LOOP :MOV A , R1 MOVC A , @A+DPTR LCALL DATAVEE ’V0第三脚VEE 第18脚可调10K(三极管内置)INC R1DJNZ R2, LOOP带中文字库的128X64是一种具有4位/8位并行、2线或3线串行多种接口方式,内部含有国标一级、二级简体中文字库的点阵图形液晶显示模块;其显示分辨率为128×64, 内置8192个16*16点汉字,和128个16*8点ASCII字符集.利用该模块灵活的接口方式和简单、方便的操作指令,可构成全中文人机交互图形界面。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
//--定时使用的IO口--//
#define DATA_PORT P0
sbit LCD12864_CS = P3^2;
sbit LCD12864_RSET = P3^3;
void Lcd12864_ClearScreen(void);
void Lcd12864_Write16CnCHAR(uchar x, uchar y,uchar k);
void Delay10ms(unsigned int c);
unsigned char code t字:绝--*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xE0,0x2C,0x34,0xE4,0x24,0x27,0xE8,0x10,0x20,0x10,0x63,0xAC,0x30,0x20,
0x00,0x70,0x43,0x42,0x42,0x43,0x42,0x42,0x3F,0x00,0x00,0x12,0x12,0x22,0x67,0x22,
/*--文字:,--*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x58,0x00,0x00,
sbit LCD12864_RS = P2^6;
sbit LCD12864_RW = P2^7;
sbit LCD12864_RD = P2^5;
//--定义全局函数--//
void LcdSt7565_WriteCmd(cmd);
void LcdSt7565_WriteData(dat);
void Lcd12864_Init();
/*--文字:。--*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x24,0x24,0x18,0x00,0x00,
/*--文字:都--*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x06,0xDA,0x22,0x02,0xFE,0x20,0x26,0x28,0x34,0x24,0x7F,0xA4,0x24,0x24,0x20,
0x00,0x07,0x08,0x10,0x08,0xFF,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0xFF,0x02,0x04,
/*--文字:烟--*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFE,0x42,0x42,0x42,0xFA,0x42,0x42,0x42,0xFE,0x08,0x10,0xFF,0x00,0x70,0x80,
0x00,0xFF,0x40,0x4C,0x42,0x41,0x46,0x48,0x50,0xFF,0x10,0x08,0x07,0x18,0x60,0x80,
/*--文字:柳--*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFC,0x04,0x04,0xFC,0x00,0xF8,0x02,0x04,0xFC,0x10,0x90,0xFF,0xD0,0x10,0x10,
0x00,0x07,0x08,0x04,0xFF,0x00,0x0F,0x32,0x44,0x8F,0x01,0x00,0xFF,0x00,0x03,0x04,
/*--文字:胜--*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x10,0x10,0x10,0xFF,0x10,0x10,0x3C,0x40,0x00,0xFE,0x22,0x22,0xFE,0x00,
0x00,0x40,0x42,0x42,0x42,0x7F,0x42,0x42,0x42,0x40,0x00,0xFF,0x82,0x02,0x7F,0x80,
/*--文字:满--*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x24,0x24,0x2F,0xE4,0x24,0x24,0xE4,0x2F,0x24,0x24,0x00,0x8C,0x02,0x60,0x10,
0x00,0x7F,0x91,0x49,0x07,0x09,0x19,0x07,0x09,0x11,0xFF,0x00,0x01,0x7E,0x04,0x04,
/*--文字:处--*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x80,0x40,0x20,0x10,0xFF,0x00,0x00,0xF8,0x08,0x08,0x9F,0x60,0x80,0x00,
0x00,0x40,0x41,0x40,0x40,0x40,0x5F,0x40,0x20,0x20,0x13,0x0C,0x13,0x20,0x40,0x81,
/*--文字:皇--*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x7C,0x54,0x54,0x54,0x54,0x55,0x56,0x54,0x7C,0x00,0x00,0x00,
0x00,0x40,0x41,0x49,0x49,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x49,0x49,0x41,0x40,