lcd12864并行数据传输汉字及图形显示程序

合集下载

带字库LCD12864自定义图形、汉字显示

带字库LCD12864自定义图形、汉字显示

带字库的LCD12864自定义图片、汉字显示
一、将图片修改成128*64像素
1、打开win7自带的画图软件,载入图片(图片不满足128*64)
2、点击重新调整大小(或者图片处右击鼠标),如下设置,保持纵横比不勾选。

3、图片另存为,选择单色位图。

二、LCD12864用ZIMO21软件取模(BMP图片)
1、基本设置里面设置LCD的大小(如果图片像素就是128*64就不需要设置,直接打开)
2、打开BMP图片(黑白)
3、发现图片偏小,不足128*64,此时生成的数据就缺少128*64个点,显示会照成错误,需要修改一下图片大小。

改成128*64
3、直接调入128*64图片
4、设置参数,如下
5、取模选择C51格式
6、显示效果
三、PCtoLCD2002图片取模设置
四、PCtoLCD2002汉字取模设置(根据程序而定)
1、汉字取模参数设置
2、显示效果如下。

LCD12864显示中文及图片C程序

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左右滚屏显示汉字

液晶LCD12864左右滚屏显示汉字

Keil C语言源程序#include<AT89X51.h>#include<intrins.h>#define uchar unsigned char#define uint unsigned int#define LCD_databus P0uchar num;uchar code zi[10][32]={/***********************临**************************/ 0x00,0xF8,0xF0,0x00,0xFF,0xFE,0x80,0x60,0x38,0x1E,0x3F,0x6A,0x68,0xC8,0x4C,0x08,0x00,0x0F,0x07,0x00,0xFF,0x7F,0x00,0xFF,0x7E,0x42,0x7E,0x7E,0x42,0xFE,0x7F,0x02,/***********************沂**************************/ 0x00,0x10,0xE1,0xC6,0x0C,0x8C,0xE0,0xFE,0xFC,0x24,0x26,0xE2,0xE3,0x23,0x32,0x20,0x00,0x04,0x78,0xF8,0x1E,0x83,0x40,0x3F,0x1F,0x00,0x00,0xFF,0x7F,0x00,0x00,0x00,/***********************大**************************/ 0x00,0x00,0x20,0x20,0x20,0x20,0x20,0xFF,0xFE,0xA0,0x20,0x20,0x20,0x30,0x20,0x00,0x00,0x80,0x40,0x60,0x30,0x1C,0x0F,0x03,0x00,0x03,0x0E,0x18,0x30,0x60,0xE0,0x40,/***********************学**************************/ 0x00,0x10,0x38,0x1C,0x0B,0x4E,0x48,0x4B,0x4E,0xC8,0xEC,0x4F,0x0A,0x38,0x1C,0x08,0x00,0x00,0x04,0x04,0x04,0x04,0x44,0x44,0xFF,0x7F,0x04,0x04,0x04,0x06,0x04,0x00,/**********************横杠*************************/ 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/***********************欢**************************/ 0x04,0x34,0xC4,0x04,0xC4,0x3C,0x20,0x10,0x0F,0xE8,0x08,0x08,0x28,0x18,0x00,0x00,0x10,0x08,0x06,0x01,0x82,0x8C,0x40,0x30,0x0C,0x03,0x0C,0x10,0x60,0xC0,0x40,0x00,/***********************迎**************************/ 0x40,0x42,0x44,0xC8,0x00,0xFC,0x04,0x02,0x82,0xFC,0x04,0x04,0x04,0xFE,0x04,0x00,0x00,0x40,0x20,0x1F,0x20,0x47,0x42,0x41,0x40,0x7F,0x40,0x42,0x44,0x63,0x20,0x00,/***********************您**************************/ 0x40,0x20,0x10,0xFC,0x23,0x10,0x8C,0x67,0x04,0xF4,0x04,0x44,0x94,0x8C,0x00,0x00,0x40,0x30,0x00,0x77,0x80,0x81,0x88,0x92,0xB4,0x83,0x80,0xE0,0x00,0x11,0x60,0x00,/**********************笑脸*************************/ 0x00,0x40,0x20,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x08,0x08,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};sbit RS=P2^2;sbit RW=P2^1;sbit EN=P2^0;sbit CS1=P2^4;sbit CS2=P2^3;void delay(uint x){uchar i;while(x--)for(i=0;i<120;i++);}void Read_busy(){P0=0X00;RS=0;RW=1;EN=1;while(P0&0x80);EN=0;}void write_LCD_command(uchar value){Read_busy();RS=0;RW=0;LCD_databus=value;EN=1;_nop_();_nop_ ();EN=0;}void write_LCD_data(uchar value){Read_busy();RS=1;RW=0;LCD_databus=value;EN=1;_nop_();_nop_();EN=0;}void Set_page(uchar page){page=0xb8|page;write_LCD_command(page);}void Set_line(uchar startline) {startline=0xc0|startline; write_LCD_command(startline); }void Set_colum(uchar colum) {colum=colum&0x3f;colum=0x40|colum;write_LCD_command(colum);}void Setonoff(uchar onoff){onoff=0x3e|onoff;write_LCD_command(onoff);}void SelectScreen(uchar screen) {switch(screen){case 0:CS1=0;CS2=0;break;case 1:CS1=0;CS2=1;break;case 2:CS1=1;CS2=0;break;default:break;}}void ClearScreen(uchar screen) {uchar i,j;SelectScreen(screen);for(i=0;i<8;i++){Set_page(i);Set_colum(0);for(j=0;j<64;j++){write_LCD_data(0x00);}}}void InitLCD(){Read_busy();SelectScreen(0);Setonoff(0);SelectScreen(0);Setonoff(1);SelectScreen(0);ClearScreen(0);Set_line(0);}void Display(uchar ss,uchar page,uchar colum,uchar *p){uchar i;SelectScreen(ss);Set_page(page);Set_colum(colum);for(i=0;i<16;i++){write_LCD_data(p[i]);}Set_page(page+1);Set_colum(colum);for(i=0;i<16;i++){write_LCD_data(p[i+16]);}}void main(){int i;InitLCD();ClearScreen(0);Set_line(0);while(1){for(i=0;i<10;i++){int a=i+1,b=i+2,c=i+3,d=i+4,e=i+5,f=i+6,g=i+7;if(a>=10||b>=10||c>=10||d>=10||e>=10||f>=10||g>=10){a=a%10;b=b%10;c=c%10;d=d%10;e=e%10;f=f%10;g=g%10;}Display(1,2,0*16,zi[i]);Display(1,2,1*16,zi[a]);Display(1,2,2*16,zi[b]);Display(1,2,3*16,zi[c]);Display(2,2,0*16,zi[d]);Display(2,2,1*16,zi[e]);Display(2,2,2*16,zi[f]);Display(2,2,3*16,zi[g]);delay(500);ClearScreen(0);}}}Protues仿真图。

LCD12864显示屏程序汉子显示顺序对应的数值错误解决方案

LCD12864显示屏程序汉子显示顺序对应的数值错误解决方案

LCD12864显示屏程序汉子显示顺序对应的数值错误
解决方案
STC12C5A60S2调试LCD12864显示汉字。

问题描述
每次显示汉字,第一次汉字总是显示不对。

code u8 string[4]=
{
"床前明月光",
"疑是地上霜",
"举头望明月",
"低头思故乡",
};
第一行显示总是为:
42前明月光
另外换成其他任意汉字,第一个字总是不对,后面的字有概率不对。

原因分析:
一开始怀疑时序有问题,不停的去网上找别人写的例程,拿过来调试发现还是不行。

然后怀疑是KEIL编码有问题,但是调到GB2312还是老样子。

后来又怀疑是液晶屏问题,重新找了个换下还是不行。

程序发给同事,他运行正常。

然后我就想起来可能是我板子供电不正常,丢了原装适配器,只是用一根线链接的USB 5V供电,之前用示波器测试发现电源有时候波动很厉害,导致数据脚数据出错。

解决方案:
于是直接将数据脚改成推挽输出,成功。

教程用的都不是增强型的芯片,并不会设置IO口。

由于暂时没有适配器,无法检验没有设置成推挽输出在我的开发板上是否正常。

带中文字库的12864lcd显示程序

带中文字库的12864lcd显示程序
uint i, j; for(i = a; i > 0; i--)
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液晶显示器中文说明

一、液晶显示模块概述12864A-1汉字图形点阵液晶显示模块,可显示汉字及图形,内置8192个中文汉字(16X16点阵)、128个字符(8X16点阵)及64X256点阵显示RAM(GDRAM)。

主要技术参数和显示特性:电源:VDD 3.3V~+5V(内置升压电路,无需负压);显示内容:128列× 64行显示颜色:黄绿显示角度:6:00钟直视LCD类型:STN与MCU接口:8位或4位并行/3位串行配置LED背光多种软件功能:光标显示、画面移位、自定义字符、睡眠模式等二、外形尺寸1.外形尺寸图2.主要外形尺寸项目标准尺寸单位模块体积113.0×65.0×12.8mm定位尺寸105.0×55.0mm视域73.4×38.8 mm行列点阵数128×64dots点距离0.52×0.52 mm点大小0.48×0.48 mm二、模块引脚说明128X64 引脚说明引脚号引脚名称方向功能说明1 VSS - 模块的电源地2 VDD - 模块的电源正端3 V0 - LCD驱动电压输入端4 RS(CS) H/L 并行的指令/数据选择信号;串行的片选信号5 R/W(SID) H/L 并行的读写选择信号;串行的数据口6 E(CLK) H/L 并行的使能信号;串行的同步时钟7 DB0 H/L 数据08 DB1 H/L 数据19 DB2 H/L 数据210 DB3 H/L 数据311 DB4 H/L 数据412 DB5 H/L 数据513 DB6 H/L 数据614 DB7 H/L 数据715 PSB H/L 并/串行接口选择:H-并行;L-串行16 NC 空脚17 /RET H/L 复位低电平有效18 NC 空脚19 LED_A - 背光源正极(LED+5V)20 LED_K - 背光源负极(LED-OV)逻辑工作电压(VDD):4.5~5.5V电源地(GND):0V工作温度(Ta):0~60℃(常温) / -20~75℃(宽温)三、接口时序模块有并行和串行两种连接方法(时序如下):8位并行连接时序图MPU写资料到模块MPU从模块读出资料2、串行连接时序图串行数据传送共分三个字节完成:第一字节:串口控制—格式11111ABCA为数据传送方向控制:H表示数据从LCD到MCU,L表示数据从MCU到LCDB为数据类型选择:H表示数据是显示数据,L表示数据是控制指令C固定为0第二字节:(并行)8位数据的高4位—格式DDDD0000第三字节:(并行)8位数据的低4位—格式0000DDDD串行接口时序参数:(测试条件:T=25℃VDD=4.5V)四、用户指令集指令指令码说明执行时间(540KHZ)RSRWDB7DB6DB5DB4DB3DB2DB1DB清除显示0 0 0 0 0 0 0 0 0 1将DDRAM填满“20H”,并且设定DDRAM的地址计数器(AC)到“00H”4.6ms地址归位0 0 0 0 0 0 0 0 1 X设定DDRAM的地址计数器(AC)到“00H”,并且将游标移到开头原点位置;这个指令并不改变DDRAM的内容4.6ms进入点设定0 0 0 0 0 0 0 1 I/D S指定在资料的读取与写入时,设定游标移动方向及指定显示的移位72us显示状态开/关0 0 0 0 0 0 1 D C BD=1:整体显示ONC=1:游标ONB=1:游标位置ON72us游标或显示移位控制0 0 0 0 0 1S/CR/LX X设定游标的移动与显示的移位控制位元;这个指令并不改变DDRAM的内容72us功能设定0 0 0 0 1 DL XREX XDL=1 (必须设为1)RE=1:扩充指令集动作72us备注:1、当模块在接受指令前,微处理顺必须先确认模块内部处于非忙碌状态,即读取BF标志时BF需为0,方可接受新的指令;如果在送出一个指令前并不检查BF标志,那么在前一个指令和这个指令中间必须延迟一段较长的时间,即是等待前一个指令确实执行完成,指令执行的时间请参考指令表中的个别指令说明。

lcd12864程序流程图

lcd12864程序流程图

lcd12864 程序流程图
我们常用的人机交互显示界面中,除了数码管,LED,以及我们之前已经提到的LCD1602 之外,还有一种液晶屏用的比较多。

相信接触过单片机的朋友都知道了,那就是12864 液晶。

顾名思义,12864 表示其横向可以显示128 个点,纵向可以显示64 个点。

我们常用的12864 液晶模块中有带字库的,也有不带字库的,其控制芯片也有很多种,如KS0108 、T6963,ST7920 等等。

在这里我们以ST7920 为主控芯片的12864 液晶屏来学习如何去驱动它。

(液晶屏采用金鹏的OCMJ4X8C)。

lcd12864 液晶说明:
我们先来了解一下它的并行连接情况。

下面是电路连接图:
上面的图可以看出,液晶模块和单片机的连接除了P0 口的8 位并行数据线之外,还有RS,RW,E 等几根线。

其中R/S 是指令和数据寄存器的选择控制线(串行模式下为片选),R/W 是读写控制线(串行模式下是数据线),E 是使能线(串行模式下为时钟线)。

通过这几根控制线和数据线,再结合它的时序图,我们就可以编写出相应的驱动程序啦。

看看并行模式下的写时序图:。

LCD12864中文字库使用说明

LCD12864中文字库使用说明

( 一 ) ( 一 )概括⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯3(二) ( 二)外形尺寸1 方框⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯32 外型尺寸⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯4( 三 )( 三 )模的接口⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯4( 四 )( 四 )硬件明⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯5( 五 )指令明⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯7( 五 )( 五 )写操作序⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯8( 六 )( 六 )沟通参数⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯11( 七 )( 七 )件初始化程⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯12( 八 )( 八 )用例⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯13( 九 )( 九 )附1 半字符表⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯202 字字符表⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯21一、概括FYD12864-0402B是一种拥有 4 位/8 位并行、 2 线或 3 线串行多种接口方式,内部含有国标一级、二级简体中文字库的点阵图形液晶显示模块;其显示分辨率为 128× 64, 内置 8192 个 16*16 点汉字,和 128 个 16*8 点 ASCII 字符集 . 利用该模块灵巧的接口方式和简单、方便的操作指令,可构成全中文人机交互图形界面。

能够显示 8× 4 行 16× 16 点阵的汉字 . 也可达成图形显示 . 低电压低功耗是其又一明显特色。

由该模块构成的液晶显示方案与同种类的图形点阵液晶显示模块对比,无论硬件电路构造或显示程序都要简短得多,且该模块的价钱也略低于同样点阵的图形液晶模块。

基本特征 :低电源电压( VDD:+3.0--+5.5V)显示分辨率 :128 × 64 点内置汉字字库,供给8192 个 16× 16 点阵汉字 ( 简繁体可选 )内置 128 个 16× 8 点阵字符2MHZ时钟频次显示方式: STN、半透、正显驱动方式: 1/32DUTY, 1/5BIAS视角方向: 6 点背光方式:侧部高亮白色 LED,功耗仅为一般 LED的 1/5 —1/10 通信方式:串行、并口可选内置 DC-DC变换电路,无需外加负压无需片选信号,简化软件设计工作温度 :0 ℃ -+55℃ ,储存温度:-20℃ -+60℃二、方框图3、外形尺寸图三、模块接口说明* 说明 1:如在实质应用中仅使用串口通信模式,可将PSB接固定低电平,也能够将模块上的J8 和“ GND”用焊锡短接。

LCD12864液晶显示器中文说明

LCD12864液晶显示器中文说明

一、液晶显示模块概述12864A-1汉字图形点阵液晶显示模块,可显示汉字及图形,内置8192个中文汉字(16X16点阵)、128个字符(8X16点阵)及64X256点阵显示RAM(GDRAM)。

主要技术参数和显示特性:电源:VDD 3.3V~+5V(内置升压电路,无需负压);显示内容:128列× 64行显示颜色:黄绿显示角度:6:00钟直视LCD类型:STN与MCU接口:8位或4位并行/3位串行配置LED背光多种软件功能:光标显示、画面移位、自定义字符、睡眠模式等二、外形尺寸1.外形尺寸图2.主要外形尺寸项目标准尺寸单位模块体积113.0×65.0×12.8mm定位尺寸105.0×55.0mm视域73.4×38.8 mm行列点阵数128×64dots点距离0.52×0.52 mm点大小0.48×0.48 mm二、模块引脚说明128X64 引脚说明引脚号引脚名称方向功能说明1 VSS - 模块的电源地2 VDD - 模块的电源正端3 V0 - LCD驱动电压输入端4 RS(CS) H/L 并行的指令/数据选择信号;串行的片选信号5 R/W(SID) H/L 并行的读写选择信号;串行的数据口6 E(CLK) H/L 并行的使能信号;串行的同步时钟7 DB0 H/L 数据08 DB1 H/L 数据19 DB2 H/L 数据210 DB3 H/L 数据311 DB4 H/L 数据412 DB5 H/L 数据513 DB6 H/L 数据614 DB7 H/L 数据715 PSB H/L 并/串行接口选择:H-并行;L-串行16 NC 空脚17 /RET H/L 复位低电平有效18 NC 空脚19 LED_A - 背光源正极(LED+5V)20 LED_K - 背光源负极(LED-OV)逻辑工作电压(VDD):4.5~5.5V电源地(GND):0V工作温度(Ta):0~60℃(常温) / -20~75℃(宽温)三、接口时序模块有并行和串行两种连接方法(时序如下):8位并行连接时序图MPU写资料到模块MPU从模块读出资料2、串行连接时序图串行数据传送共分三个字节完成:第一字节:串口控制—格式11111ABCA为数据传送方向控制:H表示数据从LCD到MCU,L表示数据从MCU到LCDB为数据类型选择:H表示数据是显示数据,L表示数据是控制指令C固定为0第二字节:(并行)8位数据的高4位—格式DDDD0000第三字节:(并行)8位数据的低4位—格式0000DDDD串行接口时序参数:(测试条件:T=25℃VDD=4.5V)四、用户指令集指令指令码说明执行时间(540KHZ)RSRWDB7DB6DB5DB4DB3DB2DB1DB清除显示0 0 0 0 0 0 0 0 0 1将DDRAM填满“20H”,并且设定DDRAM的地址计数器(AC)到“00H”4.6ms地址归位0 0 0 0 0 0 0 0 1 X设定DDRAM的地址计数器(AC)到“00H”,并且将游标移到开头原点位置;这个指令并不改变DDRAM的内容4.6ms进入点设定0 0 0 0 0 0 0 1 I/D S指定在资料的读取与写入时,设定游标移动方向及指定显示的移位72us显示状态开/关0 0 0 0 0 0 1 D C BD=1:整体显示ONC=1:游标ONB=1:游标位置ON72us游标或显示移位控制0 0 0 0 0 1S/CR/LX X设定游标的移动与显示的移位控制位元;这个指令并不改变DDRAM的内容72us功能设定0 0 0 0 1 DL XREX XDL=1 (必须设为1)RE=1:扩充指令集动作72us备注:1、当模块在接受指令前,微处理顺必须先确认模块内部处于非忙碌状态,即读取BF标志时BF需为0,方可接受新的指令;如果在送出一个指令前并不检查BF标志,那么在前一个指令和这个指令中间必须延迟一段较长的时间,即是等待前一个指令确实执行完成,指令执行的时间请参考指令表中的个别指令说明。

LCD12864液晶的使用之字库型液晶(二)

LCD12864液晶的使用之字库型液晶(二)
Read_H=ReadByte(); //读高8位
Read_L=ReadByte(); //读低8位
write_LCD_command(ROW+0x80); //送入垂直地址
write_LCD_command(xlabel+0x80);//再送入水平地址
if(xlabel_bit<8)
{
switch(color)
address++;//指针地址指向下个位置
}
}
}
还有一点要注意的就是显示图片和显示ASCII码、汉字的初始化函数不同,显示图片用的是扩展指令:
void init_BMP()
{
write_LCD_command(0x36);//CL=1--8位。扩充指令(RE=1),绘图打开(G=1)
delay(100);//适当延时
下面这个显示温度曲线:
这两个的仿真图大家可以做一下!
/echoas/blog/item/525d2f74bc735508b151b92d.html
{
ROW=y;
}
else//显示的是下半屏
{
ROW=y-32;
xlabel+=8; //规定显示在下半屏
}
write_LCD_command(ROW+0x80); //送入垂直地址
write_LCD_command(xlabel+0x80);//再送入水平地址
ReadByte();//读取当前GDRAM数据前腰进行一次空读,接下来就可以读出数据了
break;
default:break;
}
write_LCD_data(Read_H);//将数据写入GDRAM

LCD12864带中文字库图形显示单片机程序多图

LCD12864带中文字库图形显示单片机程序多图

LCD12864带中文字库图形显示-单片机程序(多图)代码:#include ;#define uchar unsigned charsbit rs=P2^2;//写指令/数据sbit rw=P2^3;//读状态/写sbit e=P2^4;//使能端sbit psb=P2^5;//串/并输入//校徽unsigned char code image[]={0x00,0x00,0x00,0x00,0x00,0x00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F ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x1F,0xBB,0xFC,0xFD,0xC0,0x00,0x0F,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x0F,0xAA,0xBE,0xBF,0x00,0x00,0x0F,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x03,0xEE,0xBE,0xBC,0x00,0x00,0x0F,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x7E,0x9F,0xF0,0x00,0x00,0x0F,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x0F,0xFF,0x00,0x00,0x00,0x0F,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,};void delay(int i){uchar j;while(i--)for(j=110;j>;0;j--);}//读状态,检测忙void check_busy(){rs=0;rw=1;e=1;P0=0xff;while((P0&0x80)==0x80);e=0;}//写指令void write_com(uchar com) {check_busy();rs=0;rw=0;e=1;P0=com;delay(5);e=0;delay(5);}//写数据void write_data(uchar _data) {check_busy();rs=1;rw=0;e=1;P0=_data;delay(5);e=0;delay(5);}//初始化lcdvoid init(){rw=0;psb=1;//选择为并行输入delay(50);write_com(0x30);//基本指令操作delay(5);write_com(0x0c);//显示开,关光标delay(5);write_com(0x06);//写入一个字符,地址加1 delay(5);write_com(0x01);delay(5);}void wstring(uchar *str){while(*str){write_data(*str);delay(5);str++;}}void lcd_draw(unsigned char code *pic) {unsigned i,j,k;write_com(0x34);//扩充指令集for(i=0;i绘图更好的一个算法:(可以绘分块,也可绘全屏)void lcd_block(char num,char flag){//x1:列数,yl:行数,x:列坐标,//sx:该图形距离第一幅图的距离//此函数也可以用来画全屏图unsigned i,j,k,xl,yl,x,y,sx;unsigned char code *pic;switch(num){case 0: j=0;pic=image0;xl=5;yl=12;sx=3;x=0x80|sx;break;case 1:j=13;pic=image4;xl=4;yl=37;sx=0;x=0x80|sx;break; case 2:j=13;pic=image4;xl=4;yl=37;sx=3;x=0x80|sx;break; case 3:j=13;pic=image4;xl=4;yl=12;sx=6;x=0x80|sx;break; case 4: j=7;pic=image4;xl=4;yl=31;sx=0;x=0x88|sx;break;case 5: j=7;pic=image5;xl=4;yl=31;sx=3;x=0x88|sx;break;case 6: j=7;pic=image5;xl=4;yl=31;sx=6;x=0x88|sx;break;case 7: j=0;pic=image7;xl=16;yl=64;sx=0;x=0x80|sx;break;}write_com(0x34);for(j;j;31) {y=j-32;x=0x88|sx;} else y=j;write_com(0x80+y);write_com(x);for(k=0;k<xl;k++){if(flag)write_data(*pic++);else write_data(~(*pic++));}}/*for(j;j<yl;j++){write_com(0x80+j);write_com(x);for(k=0;k<xl;k++){if(flag)write_data(*pic++);else write_data(~(*pic++));}}*/write_com(0x36);//显示图形write_com(0x30);//基本指令集}。

lcd12864带字库经典程序

lcd12864带字库经典程序
ListLength++;
X++;
Delay5Ms();
}
}
}
/***********短延时********************************************************/
voidDelay5Ms(void)
{
unsignedintTempCyc= 5552;
while(TempCyc--);
WriteDataLCD(DData);
}
/***********按指定位置显示一串字符*****************************************/
voidDisplayListChar(unsignedcharX,unsignedcharY,unsignedcharcode*DData)
voidWriteDataLCD(unsignedcharWDLCD)
{
ReadStatusLCD();//检测忙
LCD_RS= 1;
LCD_RW= 0;
LCD_Data=WDLCD;
LCD_E= 1;
LCD_E= 1;
LCD_E= 0;
}
/***********写指令********************************************************/
sbitLCD_RS=P1^0;
sbitLCD_RW=P1^1;
sbitLCD_E=P1^2;
sbitPSB=P1^6;//PSB脚为-12系列的串、并通讯功能切换,使用位并行接口,PSB=1
/********宏定义***********************************************************/

LCD12864液晶显示器中文说明(DOC)

LCD12864液晶显示器中文说明(DOC)

一、液晶显示模块概述12864A-1汉字图形点阵液晶显示模块,可显示汉字及图形,内置8192个中文汉字(16X16点阵)、128个字符(8X16点阵)及64X256点阵显示RAM(GDRAM)。

主要技术参数和显示特性:电源:VDD 3.3V~+5V(内置升压电路,无需负压);显示内容:128列× 64行显示颜色:黄绿显示角度:6:00钟直视LCD类型:STN与MCU接口:8位或4位并行/3位串行配置LED背光多种软件功能:光标显示、画面移位、自定义字符、睡眠模式等二、外形尺寸1.外形尺寸图2.二、模块引脚说明电源地(GND):0V工作温度(Ta):0~60℃(常温) / -20~75℃(宽温)三、接口时序模块有并行和串行两种连接方法(时序如下):8位并行连接时序图MPU写资料到模块MPU从模块读出资料、串行连接时序图2串行数据传送共分三个字节完成:第一字节:串口控制—格式11111ABCA为数据传送方向控制:H表示数据从LCD到MCU,L表示数据从MCU到LCDB为数据类型选择:H表示数据是显示数据,L表示数据是控制指令C固定为0第二字节:(并行)8位数据的高4位—格式DDDD0000第三字节:(并行)8位数据的低4位—格式0000DDDD串行接口时序参数:(测试条件:T=25℃VDD=4.5V)四、用户指令集1、当模块在接受指令前,微处理顺必须先确认模块内部处于非忙碌状态,即读取BF 标志时BF 需为0,方可接受新的指令;如果在送出一个指令前并不检查BF 标志,那么在前一个指令和这个指令中间必须延迟一段较长的时间,即是等待前一个指令确实执行完成,指令执行的时间请参考指令表中的个别指令说明。

2、“RE ”为基本指令集与扩充指令集的选择控制位元,当变更“RE ”位元后,往后的指令集将维持在最后的状态,除非再次变更“RE ”位元,否则使用相同指令集时,不需每次重设“RE ”位元。

具体指令介绍:1、清除显示 CODE :功能:清除显示屏幕,把DDRAM 位址计数器调整为“00H ” 2、位址归位 CODE :功能:把DDRAM 位址计数器调整为“00H ”,游标回原点,该功能不影响显示DDRAM 3、位址归位 CODE : 功能:把DDRAM 位址计数器调整为“00H ”,游标回原点,该功能不影响显示DDRAM 功能:执行该命令后,所设置的行将显示在屏幕的第一行。

LCD12864液晶驱动编程指南

LCD12864液晶驱动编程指南

LCD12864液晶驱动编程指南
1.连接硬件:
2.初始化液晶:
在开始使用液晶之前,需要进行初始化。

初始化过程包括设置液晶的
工作模式、显示模式和其他参数。

通过向液晶发送一系列的指令,可以完
成初始化过程。

3.编写驱动程序:
液晶驱动程序的主要目的是将需要显示的内容以及液晶的控制指令发
送给液晶屏。

根据液晶屏的通信方式,可以采用单片机的IO口直接控制
液晶屏,也可以通过SPI或I2C等接口芯片间接控制。

4.显示图形:
5.显示文本:
除了图形外,液晶还可以显示文本。

可以通过设置显示位置和发送需
要显示的文本来实现。

6.更新显示:
当需要更新液晶上的内容时,可以通过重新设置显示的内容和刷新液
晶来实现。

可以定时刷新液晶,或者通过检测外部事件来触发刷新。

7.扩展功能:
除了基本功能外,还可以实现一些扩展功能,如显示动画、滚动显示、倒计时等。

只需要根据需求编写相应的代码即可实现。

总结:
注意事项:
在编写驱动程序时,需要注意及时更新液晶上的内容,避免频繁刷新导致的卡顿现象。

同时,为了保证程序的可移植性,可以将液晶驱动程序与其他功能模块进行分离,便于代码的维护和移植。

LCD12864(并口)显示程序

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);}。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

今天终于完成了12864带字库液晶模块的图象和中英文字母显示,图象显示显示了自己的一副照片,呵呵,还认得出是自己,开心啊。

硬件连接方式是:并口直接访问。

这是汉字显示程序:#include<reg51.h>#include<absacc.h>#define uchar unsigned char#define datawr 0x1200 //写数据通道#define comwr 0x1000 //写控制命令通道#define datare 0x1300 //读数据通道#define comre 0x1100 //读忙通道uchar code disp_data[]={" 浙江大学 " //第一行,第一页"04级通信工程一班" //第三行" 宁波理工学院 " //第二行" 竞赛小组 " //第四行"128X64液晶显示器" //第一行,第二页" 测试程序 " //第三行" 07年07月25日 " //第二行" Tornado "}; //第四行void set12864();void write_command(uchar command);void write_page(uchar data_add);void read_page(uchar data_add);void delays(uchar cont);void main(){while(1){set12864(); //初始化12864write_page(0); //写入一页数据read_page(0x30); //读出一页数据到内部RAMdelays(2); //延时2swrite_page(64); //写入下一页数据delays(2); //延时2s}}//初始化12864子程序void set12864(){write_command(0x30); //功能设定控制字write_command(0x0c); //显示开关控制字write_command(0x01); //清除屏幕控制字write_command(0x06); //进入设定点控制字}//写控制命令子程序void write_command(uchar command){bit flag="1"; //12864空闲标志位while(flag) //检查12864是否空闲flag="XBYTE"[comre]&0x80;XBYTE[comwr]=command; //空闲传送控制字}//写一页子程序void write_page(uchar data_add){bit flag="1"; //12864空闲标志位uchar num="64"; //64个循环,连续写入32个汉字或是64个西文字符write_command(0x80);for(;num>0;num--){while(flag) //检查12864是否空闲flag="XBYTE"[comre]&0x80;XBYTE[datawr]=disp_data[data_add++]; //空闲传送数据}}//读一页子程序void read_page(uchar data_add){bit flag="1"; //12864空闲标志位uchar num="64"; //64个循环,连续写入32个汉字或是64个西文字符write_command(0x80);for(;num>0;num--){while(flag) //检查12864是否空闲flag="XBYTE"[comre]&0x80;DBYTE[data_add++]=XBYTE[datare]; //空闲传送数据}}//延时cont秒子程序void delays(uchar count){unsigned char h,i,j,k;do{for(h=5;h>0;h--)for(i=4;i>0;i--)for(j=116;j>0;j--)for(k=214;k>0;k--);}while(--count);}这是图象显示程序:#include<reg51.h>#include<absacc.h>#define uchar unsigned char#define uint unsigned int#define datawr 0x1200 //写数据通道#define comwr 0x1000 //写控制命令通道#define datare 0x1300 //读数据通道#define comre 0x1100 //读忙通道uchar code disp_data[] = // 数据表{0x00,0x01,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x0 0,0x00,0x00,0x00,0x00,0x01,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x0 0,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x0 0,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x0 0,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x0 0,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x0 0,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x8 0,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF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FF,0xFF,0xFF,0x20,0x0E,0x60,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x8F,0xFF,0xF F,0xFF,0xFF,0xFF,0x05,0x80,0xE0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFD,0xFF,0xFF,0xF F,0xFF,0xFF,0xFF,0x09,0x80,0xA0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0x7F,0xFF,0xF F,0xFF,0xFF,0xFF,0x85,0x2A,0xC0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFB,0xFF,0xFF,0xF F,0xFF,0xFF,0xFE,0xBF,0xF3,0xC0,0x00,0x00,0x00,0x00,0x00,0xFF,0xF7,0xFF,0xFF,0xF F,0xFF,0xFF,0xF8,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0xFF,0xFF,0xF F,0xFF,0xFF,0x00,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0xFF,0xC0,0xFF,0xFF,0xF F,0xFF,0xC0,0x1F,0xFF,0xFF,0x80,0x00,0x40,0x00,0x00,0x00,0xFF,0x80,0xFF,0xFF,0xF F,0x80,0x07,0xFF,0xFF,0xFF,0xC0,0x00,0xC0,0x00,0x00,0x01,0xFF,0x01,0xFF,0xFF,0xF 8,0x00,0xFF,0xFF,0xFF,0xFF,0xE0,0x63,0x80,0x00,0x00,0x01,0xFE,0x01,0xFF,0x18,0x0 0,0x3F,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x01,0xCC,0x01,0xFE,0x00,0x0 7,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x07,0xA0,0x03,0xFC,0x00,0xF F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x05,0xC0,0x03,0xC8,0x00,0x7 F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x88,0x0C,0x0 7,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x0C,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0xC 0,0x7F,0xFF,0xFF,0xFF,0xFF,0xF8,0x07,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x30xFF,0xFF,0xD0,0x07,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x0 F,0x03,0xFF,0xF8,0xFF,0xFC,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x3F,0xFF,0xC0,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x0 0,0x00,0xFF,0xF8,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x0 0,0x00,0x1F,0xFE,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x78,0x02,0x00,0x00,0x00,0x0 0,0x00,0x0F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x03,0xF0,0x78,0x00,0x00,0x00,0x0 0,0x00,0x02,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xF0,0x00,0x00,0x00,0x0 0,0x00,0x00,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xC0,0x00,0x00,0x00,0x0 0,0x00,0x00,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x00,0x00,0x00,0x0 0,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x27,0xC0,0x00,0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x04,0x80,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x01};void set12864();void setxy(uchar x,uchar y);void write_command(uchar command);void write_16byte(uint data_add);void delays(uchar count);void main(){uchar x,y,i;while(1){y="0x80"; //设置液晶上半部分坐标x="0x80";delays(2); //延时2sset12864(); //初始化12864delays(2);for(i=0;i<32;i++) //写入液晶上半图象部分 { //写入坐标setxy(x,y);write_16byte(i*16); //连续写入16字节数据y++; //y轴地址加1}y="0x80"; //设置液晶下半部分坐标 x="0x88";for(i=0;i<32;i++) //写入液晶下半图象部分 {setxy(x,y); //写入坐标write_16byte((32+i)*16);//连续写入16字节数据y++; //y轴地址加1}write_command(0x34); //写入扩充指令命令write_command(0x36); //显示图象}}//初始化12864子程序void set12864(){write_command(0x30); //功能设定控制字write_command(0x0c); //显示开关控制字write_command(0x01); //清除屏幕控制字write_command(0x06); //进入设定点控制字}//设置绘图坐标void setxy(uchar x,uchar y){write_command(0x34); //写入扩充指令命令write_command(y); //写入y轴坐标write_command(x); //写入x轴坐标write_command(0x30); //写入基本指令命令}//写控制命令子程序void write_command(uchar command){bit flag="1"; //12864空闲标志位while(flag) //检查12864是否空闲flag="XBYTE"[comre]&0x80;XBYTE[comwr]=command; //空闲传送控制字}void write_16byte(uint data_add){bit flag="1"; //12864空闲标志位uchar num="16"; //16个循环,连续写入16个字节 for(;num>0;num--){while(flag) //检查12864是否空闲flag="XBYTE"[comre]&0x80;XBYTE[datawr]=disp_data[data_add++]; //空闲传送数据}}//延时count秒子程序void delays(uchar count){unsigned char h,i,j,k;do{for(h=5;h>0;h--)for(i=4;i>0;i--)for(j=116;j>0;j--)for(k=214;k>0;k--);}while(--count);}。

相关文档
最新文档