12864的OLED简单显示程序=

合集下载

12864液晶屏幕使用说明及程序

12864液晶屏幕使用说明及程序

12864使用说明一、串/并接口1.1 串口接口管脚信号*注释1:如在实际应用中仅使用并口通讯模式,可将PSB 接固定高电平。

*注释2:模块内部接有上电复位电路,因此在不需要经常复位的场合可将该端悬空。

*注释3:如背光和模块共用一个电源,可以将模块上的JA、JK 用焊锡短接。

1.2 并行接口管脚信号*注释1:如在实际应用中仅使用并口通讯模式,可将PSB 接固定高电平。

*注释2:模块内部接有上电复位电路,因此在不需要经常复位的场合可将该端悬空。

*注释3:如背光和模块共用一个电源,可以将模块上的JA、JK 用焊锡短接。

二、模块主要硬件构成说明控制器接口信号说明:2.1、RS,R/W的配合选择决定控制界面的4种模式:2.2、E信号●忙标志BFBF 标志提供内部工作情况.BF=1 表示模块在进行内部操作,此时模块不接受外部指令和数据.BF=0 时, 模块为准备状态,随时可接受外部指令和数据.利用STATUS RD 指令,可以将BF 读到DB7 总线,从而检验模块之工作状态.●字型产生ROM(CGROM)字型产生ROM(CGROM)提供8192 个此触发器是用于模块屏幕显示开和关的控制。

DFF=1 为开显示(DISPLAY ON),DDRAM 的内容就显示在屏幕上,DFF=0 为关显示(DISPLAY OFF)。

DFF 的状态是指令DISPLAY ON/OFF 和RST 信号控制的。

●显示数据RAM(DDRAM)模块内部显示数据 RAM 提供 64×2 个位元组的空间,最多可控制 4 行 16 字(64 个字)的中文字型显示,当写入显示数据 RAM 时,可分别显示 CGROM 与CGRAM 的字型;此模块可显示三种字型,分别是半角英、数字型(16*8)、CGRAM 字型及 CGROM 的中文字型。

三种字型的选择,由在 DDRAM 中写入的编码选择,在0000H—0006H 的编码中(其代码分别是0000、0002、0004、0006 共4 个)将选择 CGRAM 的自定义字型,02H—7FH 的编码中将选择半角英数字的字型,至于A1 以上的编码将自动的结合下一个位元组,组成两个位元组的编码形成中文字型的编码BIG5(A140—D75F),GB(A1A0-F7FFH)。

12864液晶显示器(ST7920)显示程序(并口)

12864液晶显示器(ST7920)显示程序(并口)

12864液晶显示器(ST7920)显示程序(并口) 附字模软件作者:纪小年16 七月2009 时间:下午10:25 and have 10 条评论前两天写了一个ST7920控制12864显示的串口程序,今天瞎逛的时候发现了这个超强悍的并口程序,转载一下。

来源:CnChina做了比较详细的注释,看不懂的可以问我。

下面的图片中12864所显示的logo就是我用这个程序得到的。

附程序:/******************************************************************** **********Copyright 2007All rights reserved.文件名: .c模块名称:st7920 并行方式驱动12864液晶驱动功能概要:st7920显示驱动取代版本:0.0.1修改人:pulan完成日期:2007.07.08升级说明:createCPU: stc89c58 主频:11.0592M液晶型号:128*64 生产厂家:驱动芯片:st7920********************************************************************* *********/#include#define uint unsigned int#define uchar unsigned char#define x1 0x80 //1000 0000#define x2 0x88 //1000 1000#define y 0x80 //1000 0000#define comm 0 //定义传送指令代码为0#define dat 1 //定义传送数据代码为1sbit RS = P2^0; //H=数据; L=指令;sbit RW = P2^1; //H=读操作; L=写操作;sbit E = P2^3; //使能端sbit PSB= P2^4; //H=并口; L=串口;sbit RST= P2^2; //复位信号低电平有效sbit busy=P0^7; //LCD忙信号void wr_lcd (uchar dat_comm,uchar content);void chk_busy (void);void delay (uint us);uchar code tab1[]={"本系列中文模块内""任意位置反白显示""置二级字库,可在""使用更方便更灵活"};uchar code tab31[]={"金鹏科技有限公司""Golden Palm TECH"};uchar code tab32[]={/*-- 调入了一幅图像:F:\梁\画图\HOCO12832.bmp --*//*-- 宽度x高度=128x32 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x18,0x0C,0x00,0x00,0x01,0x00,0x00 ,0x00,0x00,0x01,0xFF,0x80,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x13,0x10,0x03 ,0xFE,0x00,0x03,0xFF,0xC0,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x3F,0x30,0x1F ,0xFF,0xC0,0x03,0xFF,0xE0,0x00,0x00,0x00,0x00,0x8C,0x03,0xF0,0x00,0x7F,0xE0,0x7C ,0x01,0xE0,0x03,0xFF,0xF0,0x00,0x00,0x00,0x01,0x36,0x06,0xC0,0x00,0x5F,0xC0,0xFF ,0xFC,0x60,0x01,0xFF,0xF0,0x00,0x00,0x00,0x02,0x1B,0x0F,0x80,0x00,0xFF,0x01,0xFE ,0x0F,0x30,0x00,0xEF,0xF0,0x00,0x00,0x00,0x02,0x6D,0x9F,0x00,0x00,0x3E,0x03,0xFF ,0xF1,0x90,0x00,0xFF,0xF8,0x00,0x00,0x00,0x04,0x36,0xFE,0x00,0x01,0xFF,0x07,0xFF ,0xFC,0x90,0x00,0xEF,0xFF,0xFF,0x80,0x00,0x04,0xDB,0x7E,0x00,0x03,0xFF,0x87,0xFF ,0xFC,0xD0,0x00,0x0F,0xFF,0xFF,0xC0,0x00,0x04,0x6D,0xFC,0x00,0x07,0xFF,0x8F,0xFF ,0xFE,0x50,0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x36,0xFC,0x10,0x07,0xFF,0x8F,0xFF ,0xFE,0x90,0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x1B,0xF8,0x10,0x07,0xFF,0xCF,0xFF ,0xFE,0x80,0x00,0x0F,0xFF,0xFF,0xF0,0x00,0x04,0x0F,0xF8,0x10,0x07,0xFF,0xFF,0xFF ,0xFA,0x00,0x00,0x07,0xFF,0xFF,0xF0,0x00,0x04,0x07,0xF0,0x10,0x07,0xFF,0xFF,0xFF ,0xFA,0x00,0x00,0xFF,0xFF,0xFF,0xF8,0x00,0x02,0x03,0xF0,0x20,0x07,0xFF,0xFF,0xFF ,0xBA,0x00,0x00,0xFD,0xFF,0xFF,0xFC,0x00,0x02,0x03,0xF0,0x20,0x03,0xFF,0xFF,0xDF ,0xB8,0x00,0x00,0xC1,0xC0,0x3F,0xFC,0x00,0x01,0x01,0xE0,0x40,0x00,0xFF,0xFF,0xDF ,0xB0,0x00,0x00,0x81,0xC0,0x3F,0xCE,0x00,0x00,0x81,0xE0,0x80,0x00,0x7F,0xFF,0xDF ,0xA0,0x00,0x00,0x81,0x80,0x1D,0xCF,0x00,0x00,0x41,0xE1,0x00,0x00,0x3F,0xFF,0x9B ,0x00,0x00,0x01,0x83,0x80,0x1F,0xC7,0x80,0x00,0x21,0xE2,0x00,0x00,0x1F,0xFD,0xB6 ,0x00,0x00,0x01,0xC3,0x00,0x0E,0xE6,0x80,0x00,0x19,0xEC,0x00,0x00,0x07,0xFE,0x20 ,0x00,0x00,0x00,0xC3,0x00,0x07,0x67,0x40,0x00,0x07,0xF0,0x00,0x00,0x03,0x3E,0x00 ,0x00,0x00,0x00,0x02,0x00,0x03,0xE7,0xA0,0x00,0x00,0x00,0x00,0x00,0x02,0x8E,0x00 ,0x00,0x00,0x00,0x06,0x00,0x03,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,0x00 ,0x00,0x00,0x00,0x06,0x00,0x07,0x03,0x00,0x77,0x46,0x74,0x24,0x80,0x06,0x04,0x00 ,0x00,0x00,0x00,0x1C,0x00,0x06,0x00,0x00,0x55,0x45,0x54,0x57,0x80,0x00,0x00,0x00 ,0x00,0x00,0x00,0x1C,0x00,0x0E,0x00,0x00,0x45,0x45,0x74,0x57,0x80,0x08,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x00,0x55,0x45,0x44,0x74,0x80,0xF0,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x77,0x76,0x47,0x54,0x80,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00};uchar code tab5[]={/*-- 调入了一幅图像:F:\梁\画图\COCK.bmp --*//*-- 宽度x高度=128x64 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0x80,0x00,0x0F,0xFF,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x43,0x01,0x80,0x00,0x7F,0xFF,0xF0,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0xFF,0x07,0x00,0x07,0xFF,0xFF,0xFE,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0x3F,0xFC,0x1E,0x00,0x1F,0xFF,0xFF,0xFF,0x80,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xBF,0xFF,0xFC,0x00,0x7F,0xFC,0x00,0x7F,0xC0,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF0,0x00,0xFF,0xC0,0x00,0x0F,0xE0,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xE0,0x03,0xFF,0xFF,0xFC,0x01,0xF0,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xDF,0xFF,0xC0,0x07,0xFF,0xFF,0xFF,0x80,0xF0,0x00 ,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0x00,0x0F,0xFF,0xFF,0xFF,0xE0,0x38,0x00 ,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xF8,0x00,0x1F,0xFF,0xF0,0x03,0xF8,0x38,0x00 ,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xE0,0x00,0x3F,0xFF,0xFF,0xC0,0x7C,0x18,0x00 ,0x00,0x00,0x00,0x00,0x00,0x04,0x7F,0xF0,0x00,0x3F,0xFF,0xFF,0xF8,0x1E,0x08,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xF8,0x00,0x7F,0xFF,0xFF,0xFE,0x0F,0x08,0x00 ,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFC,0x00,0xFF,0xFF,0xFF,0xFF,0x87,0x08,0x00 ,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFE,0x00,0xFF,0xFF,0xFF,0xFF,0x83,0x88,0x00 ,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xC3,0x88,0x00 ,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00 ,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF1,0x88,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF3,0x08,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0x07,0xFF,0xFF,0xFF,0xFF,0xF2,0x10,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xF0,0x20,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x70,0x00,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0x7F,0x20,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0x7F,0x20,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x7E,0x20,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x3E,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFF,0x3C,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFE,0x38,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x38,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x30,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x1F,0x7C,0x20,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x1E,0x78,0x00,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFE,0x1E,0xF0,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xDA,0x3C,0xE0,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF2,0x30,0x80,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF1,0x20,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x72,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x04,0xD8,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x0C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x0F,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,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};/******************************************************************** *********************** 函数名称:init_lcd* 功能描述:初始化LCD********************************************************************* *********************/void init_lcd (void){RST = 1;PSB = 1;wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据基本指令操作wr_lcd(comm,0x01); //0000 0001 清屏——将DDRAM填满"20H",并且设定DDRAM的地址计数器为"00H"wr_lcd(comm,0x06); //0000 0110 进入点设定——指定在数据的读取与写入时,设定游标的移动方向wr_lcd(comm,0x0c); //0000 1100 游标或显示移位控制——开显示,关游标}/******************************************************************** *********************** 函数名称:chn_disp* 功能描述:显示汉字或字符********************************************************************* *********************/void chn_disp(uchar code *chn){uchar i,j; //i为横坐标,j为纵坐标wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据基本指令操作wr_lcd(comm,0x80); //1000 0000 设定DDRAM地址——0000000for(j=0;j<4;j++) //写四行数据{for(i=0;i<16;i++)wr_lcd(dat,chn[j*16+i]);}}/******************************************************************** *********************** 函数名称:chn_disp1* 功能描述:上半屏显示汉字或字符********************************************************************* *********************/void chn_disp1(uchar code *chn){uchar i,j;wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据基本指令操作wr_lcd(comm,0x80); //1000 0000 设定第一行的DDRAM 地址——0x80j=0; //第一行for(i=0;i<16;i++)wr_lcd(dat,chn[j*16+i]);wr_lcd(comm,0x90); //1001 0000 设定第二行的DDRAM 地址——0x90j=1; //第二行for(i=0;i<16;i++)wr_lcd(dat,chn[j*16+i]);}/******************************************************************** *********************** 函数名称:img_disp* 功能描述:显示图形********************************************************************* *********************/void img_disp(uchar code *img){uchar i,j;for(j=0;j<32;j++) //绘制上半屏{for(i=0;i<8;i++){wr_lcd(comm,0x34); //0011 0100 扩充功能设定——8位数据扩充指令操作绘图开wr_lcd(comm,y+j); //1xxx xxxx 设定绘图RAM——先设定垂直(列)地址AC6 AC5…AC0wr_lcd(comm,x1+i); //1000 0xxx 设定绘图RAM——再设定水平(行)地址AC3AC2AC1AC0wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据基本指令操作wr_lcd(dat,img[j*16+i*2]);wr_lcd(dat,img[j*16+i*2+1]);}}for(j=32;j<64;j++) //绘制下半屏{for(i=0;i<8;i++){wr_lcd(comm,0x34); //0011 0100 扩充功能设定——8位数据扩充指令操作绘图开wr_lcd(comm,y+j-32); //1xxx xxxx 设定绘图RAM——先设定垂直(列)地址AC6 AC5…AC0wr_lcd(comm,x2+i); //1000 1xxx 设定绘图RAM——再设定水平(行)地址AC3AC2AC1AC0wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据基本指令操作wr_lcd(dat,img[j*16+i*2]);wr_lcd(dat,img[j*16+i*2+1]);}}wr_lcd (comm,0x36); //0011 0110 扩充功能设定——8位数据扩充指令操作绘图关}/******************************************************************** *********************** 函数名称:img_disp1* 功能描述:下半屏显示图形********************************************************************* *********************/void img_disp1(uchar code *img){uchar i,j;for(j=0;j<32;j++){for(i=0;i<8;i++){wr_lcd(comm,0x34);wr_lcd(comm,y+j);wr_lcd(comm,x2+i);wr_lcd(comm,0x30);wr_lcd(dat,img[j*16+i*2]);wr_lcd(dat,img[j*16+i*2+1]);}}wr_lcd(comm,0x36);}/******************************************************************** *********************** 函数名称:lat_disp* 功能描述:显示点阵********************************************************************* *********************/void lat_disp(uchar data1,uchar data2){uchar i,j,k,x;x=x1; //1000 0000for(k=0;k<2;k++) //第一次循环x=1000 0000 第二次循环x=1000 1000{for(j=0;j<16;j++){for(i=0;i<8;i++){wr_lcd(comm,0x34); //0011 0100 扩充功能设定——8位数据扩充指令操作绘图开wr_lcd(comm,y+j*2);wr_lcd(comm,x+i);wr_lcd(comm,0x30);wr_lcd(dat,data1);wr_lcd(dat,data1);}for(i=0;i<8;i++){wr_lcd(comm,0x34);wr_lcd(comm,y+j*2+1);wr_lcd(comm,x+i);wr_lcd(comm,0x30);wr_lcd(dat,data2);wr_lcd(dat,data2);}}x=x2;}wr_lcd(comm,0x36);}/******************************************************************** *********************** 函数名称:con_disp* 功能描述:当data1=0xff,data2=0xff时,在x0,y0处反白显示16xl*yl ********************************************************************* *********************/void con_disp(uchar data1,uchar data2,uchar x0,uchar y0,uchar xl,uchar yl){uchar i,j;for(j=0;j< pre> 。

12864液晶显示资料及程序

12864液晶显示资料及程序

12864液晶显示资料及程序控制器2010-12-30 10:39:29 阅读36 评论0 字号:大中小订阅硬件连接方式是:并口直接访问。

这是汉字显示程序:#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(uchardata_add);void read_page(uchardata_add);void delays(ucharcont);void main(){while(1){set12864(); //初始化12864write_page(0); //写入一页数据read_page(0x30); //读出一页数据到内部RAMdelays(2); //延时2swrite_page(64); //写入下一页数据delays(2); //延时2s}}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(uchardata_add){bit flag=1; //12864空闲标志位ucharnum=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(uchardata_add){bit flag=1; //12864空闲标志位ucharnum=64; //64个循环,连续写入32个汉字或是64个西文字符write_command(0x80);for(;num>0;num--){while(flag) //检查12864是否空闲flag="XBYTE"[comre]&0x80;DBYTE[data_add++]=XBYTE[datare]; //空闲传送数据}}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,0x00,0x00,0x00,0x00,0x00,0x01,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00, 0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00, 0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00, 0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x80,0x00,0x00,0x00, 0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0xFF,0xFF,0xFF, 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x07,0xFF,0xFF, 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x0B,0xFF, 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x1F, 0x01,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00, 0x01,0xFF,0xFF,0xFF,0xF3,0x79,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00, 0x03,0xFF,0xFF,0xFF,0xE6,0x62,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE1,0x60,0x00,0x68, 0x01,0xFF,0xFF,0xFE,0x00,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE1,0x00,0x00,0x0E, 0x01,0xFF,0xFF,0xF8,0x00,0x4B,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x8E,0x08,0x79,0x07,0xFF,0xFF,0xF0,0x00,0x41,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE6,0xC0,0x07,0x61, 0xC3,0xFF,0xFE,0xC0,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xED,0xEF,0x3F, 0x83,0xFF,0xFE,0x60,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xC0,0xFF,0xFD,0xFC,0x6C,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xF0,0x7F,0xF3,0xFF,0xFE,0x60,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xF3,0xFF,0xFF,0x50,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9, 0xFB,0xFF,0xF1,0xF8,0x8C,0xD8,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFB,0x6F,0xD9, 0xC2,0x3F,0xF8,0x40,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xF6,0xDF,0x1E,0xFF, 0xFF,0x7F,0xFC,0x38,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x64,0x2F,0x6F,0xFF, 0xFD,0x7B,0xFC,0x1F,0xE0,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x5F,0x7C,0xEE,0xFF, 0xC7,0xFF,0xBC,0x0F,0xFF,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xDF,0xFE,0xEF,0xFF, 0xFF,0xE7,0xDC,0x07,0xE7,0xF8,0x12,0x7F,0xFF,0xFF,0xFF,0xFF,0x47,0xFF,0xFF,0xFF, 0xFF,0xE7,0x80,0x03,0xF4,0x00,0x00,0x5F,0xFF,0xFF,0xFE,0xFE,0xE3,0xFF,0xFF,0xFF, 0xFF,0xFE,0xC0,0x01,0xC0,0x00,0x00,0x1B,0xFF,0xFF,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF, 0x7F,0xEE,0xC0,0x00,0xC0,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFE,0x98,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xEF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x20,0x0E,0x60,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0x05,0x80,0xE0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x09,0x80,0xA0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x2A,0xC0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, 0xBF,0xF3,0xC0,0x00,0x00,0x00,0x00,0x00,0xFF,0xF7,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8, 0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, 0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0xFF,0xC0,0xFF,0xFF,0xFF,0xFF,0xC0,0x1F, 0xFF,0xFF,0x80,0x00,0x40,0x00,0x00,0x00,0xFF,0x80,0xFF,0xFF,0xFF,0x80,0x07,0xFF,0xFF,0xFF,0xC0,0x00,0xC0,0x00,0x00,0x01,0xFF,0x01,0xFF,0xFF,0xF8,0x00,0xFF,0xFF, 0xFF,0xFF,0xE0,0x63,0x80,0x00,0x00,0x01,0xFE,0x01,0xFF,0x18,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x01,0xCC,0x01,0xFE,0x00,0x07,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x07,0xA0,0x03,0xFC,0x00,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x05,0xC0,0x03,0xC8,0x00,0x7F,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x88,0x0C,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x0C,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0xC0,0x7F,0xFF,0xFF, 0xFF,0xFF,0xF8,0x07,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x0F,0xFF,0xFE,0xFF,0xFF,0xD0,0x07,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x03,0xFF,0xF8,0xFF,0xFC,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xC0, 0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0xFF,0xF8,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x1F,0xFE,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x78,0x02,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x03,0xF0,0x78,0x00,0x00,0x00,0x00,0x00,0x02,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x27,0xC0,0x00,0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01 };void set12864();void setxy(ucharx,uchar y);void write_command(uchar command);void write_16byte(uintdata_add);void delays(uchar count);void main(){ucharx,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(ucharx,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(uintdata_add){bit flag="1"; //12864空闲标志位ucharnum="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);}。

12864液晶显示源程序(方法2)

12864液晶显示源程序(方法2)

main函数:*****12864显示********//***作者:曹江*****//*****时间:2008 8 25 ********/#include<Lcd.h>#include<absacc.h>#include "AT89X51.h"//函数名:main() 主函数//函数参数:无//返回值:无void main(){reset(); //调用复位函数dison_off(1); //开lcd显示set_startline(0); // 从第0行开始从上至下滑动显示clear(); //清屏while(1){display();}}lcd.c子函数:#include "AT89X51.h"#include "Lcd.h"#include "data.h"#define uint unsigned int//函数名:delay() 延时函数//函数参数:uint v//返回值:无void delay(uint v){ uint i;while(v!=0){v--;for(i=125;i>0;i--);}}//函数名:busy_check() 检测忙状态左//函数参数:无//返回值:无void busy_check(void){unsigned char busy;while(busy&0x80){busy=0xff;}}//函数名:reset()复位函数//函数参数:无//返回值:无void reset(){P3_2=0; //接lcd复位端口RSTdelay(1);P3_2=1;delay(1);}//函数名:wcode(c,cs1,cs2)写指令函数//函数参数:uchar c, uchar cs1,uchar cs2//返回值:无void wcode(ucharc,uchar cs1,uchar cs2){busy_check();P3_4=cs1;P3_3=cs2;P3_7=0; //接lcd的rs端P3_6=0; //接lcd的rw端P1=c; //lcd数据端d0-d7P3_5=0; //接lcd的e端delay(5);P3_5=1;delay(5);P3_5=0;}//函数名:wdata(c,cs1,cs2)写数据函数//函数参数:uchar c, uchar cs1,uchar cs2//返回值:无void wdata(ucharc,uchar cs1,uchar cs2){busy_check();P3_4=cs1;P3_3=cs2;P3_7=1;P3_6=0;P1=c;P3_5=0;delay(1);P3_5=1;delay(1);P3_5=0;}//函数名:set_startline(i)设置起始行函数//函数参数:uchar i//返回值:无void set_startline(uchar i)//每次加一使其从第0行开始从上至下滑动显示{i=0xc0+i;wcode(i,0,0); //调用写指令函数}//函数名:set_adr(x,y)设置页值,起始列值函数//函数参数:uchar x,uchar y//返回值:无void set_adr(uchar x ,uchar y){x=x+0xb8; //X位址即页page起始0xb8y=y+0x40; //Y位址即列起始0x40wcode(x,0,0);//调用写函数wcode(y,0,0);}//函数名:dison_off(uint o)开关显示函数//函数参数:uint o//返回值:无void dison_off(uchar o){o=o+0x3e;wcode(o,0,0);}//函数名:clear() 清屏函数//函数参数:无//返回值:无void clear(){uchari,loop;for(i=0;i<8;i++){set_adr(i,0);for(loop=0;loop<64;loop++)wdata(0x00,0,0); //左右半屏同时写0}}//函数名:chinese(x,y,n,cs1,cs2) 汉字函数//函数参数:x,y,n,cs1,cs2 注:x,y为页和列号;n为字号;cs1,cs2为左右屏显示//返回值:无void chinese(ucharx,uchary,ucharn,uchar cs1,uchar cs2){ uchari,loop;for(i=0;i<2;i++){set_adr(x+i,y);//一字分上下两页写for(loop=0;loop<16;loop++){wdata(Chinese_Charcter[n][16*i+loop],cs1,cs2);}}}//函数名:display() 显示函数//函数参数:无//返回值:无void display(){uchar i;for(i=0;i<0xff;i++) //汉字上下滚屏显示{set_startline(i);chinese(0,32,0,1,0); //第0行第1个字“长”,屏左边显示chinese(0,48,1,1,0); //第0行第2个字“江”,屏左边显示chinese(0,0,2,0,1); //第0行第3个字“大”,屏右边显示chinese(0,16,3,0,1); //第0行第4个字“学”,屏右边显示chinese(2,16,4,1,0); //第1行第5个字“电”,屏左边显示chinese(2,32,5,1,0); //第1行第5个字“子”,屏左边显示chinese(2,48,6,1,0); //第1行第6个字“信”,屏左边显示chinese(2,0,7,0,1); //第1行第5个字“息”,屏右边显示chinese(2,16,8,0,1); //第1行第7个字“学”,屏右边显示chinese(2,32,9,0,1); //第1行第8个字“院”,屏右边显示chinese(4,32,10,1,0); //第2行第9个字“电”,屏左边显示chinese(4,48,11,1,0); //第2行第10个字“气”,屏左边显示chinese(4,0,12,0,1); //第2行第11个字“工”,屏右边显示chinese(4,16,13,0,1); //第2行第12个字“程”,屏右边显示chinese(4,32,14,0,1); //第2行第13个字“系”,屏右边显示chinese(6,48,15,1,0); //第6行第21个字“曹”,屏左边显示chinese(6,0,16,0,1); //第6行第22个字“江”,屏右边显示delay(10);i+=5;}}data.h:#ifndef _DATA_H_#define _DATA_H_//**********显示文字部分*********////左右分屏写,同页同行内按左到右顺序写extern uchar code Chinese_Charcter[25][32]={{/*-- 文字: 长--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x80,0x80,0x80,0x80,0xFF,0xA0,0xA0,0x90,0x90,0x88,0x84,0x82,0x80,0x80,0x80,0x00, 0x00,0x00,0x00,0x00,0xFF,0x40,0x21,0x12,0x04,0x08,0x10,0x30,0x60,0x20,0x00,0x00, },{/*-- 文字: 江--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x60,0x01,0xC6,0x30,0x00,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,0x00, 0x04,0x04,0x7E,0x01,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x00, },{/*-- 文字: 大--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,0xA0,0x20,0x20,0x20,0x20,0x20,0x20,0x00, 0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x08,0x30,0x60,0xC0,0x40,0x00, },{/*-- 文字: 学--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x00, 0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00, },{/*-- 文字: 电--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00, 0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00, },{/*-- 文字: 子--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xE2,0x12,0x0A,0x06,0x02,0x00,0x80,0x00,0x00, 0x01,0x01,0x01,0x01,0x01,0x41,0x81,0x7F,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00, },{/*-- 文字: 信--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x80,0x40,0x30,0xFC,0x07,0x0A,0xA8,0xA8,0xA9,0xAE,0xAA,0xA8,0xA8,0x08,0x08,0x00, 0x00,0x00,0x00,0x7F,0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0x00, },{/*-- 文字: 息--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0xFC,0x54,0x54,0x56,0x55,0x54,0x54,0x54,0xFC,0x00,0x00,0x00,0x00, 0x00,0x20,0x38,0x01,0x3D,0x41,0x41,0x45,0x59,0x41,0x41,0x71,0x00,0x08,0x30,0x00, },{/*-- 文字: 学--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x00, 0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00, },{/*-- 文字: 院--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0xFE,0x02,0x32,0x4A,0x86,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x0C,0x04,0x00, 0xFF,0x00,0x02,0x04,0x83,0x41,0x31,0x0F,0x01,0x01,0x7F,0x81,0x81,0x81,0xF1,0x00, },{/*-- 文字: 电--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00, 0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00, },{/*-- 文字: 气--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x20,0x10,0x8C,0xA7,0xA4,0xA4,0xA4,0xA4,0xA4,0xA4,0xA4,0x24,0x04,0x04,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x30,0x40,0xF0,0x00, },{/*-- 文字: 工--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, },{/*-- 文字: 程--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x12,0xD2,0xFE,0x91,0x11,0x80,0xBF,0xA1,0xA1,0xA1,0xA1,0xBF,0x80,0x00,0x00, 0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x44,0x44,0x7F,0x44,0x44,0x44,0x44,0x40,0x00, },{/*-- 文字: 系--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/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, },{/*-- 文字: 曹--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x02,0x02,0xFA,0xAA,0xAA,0xAA,0xFF,0xAA,0xAA,0xFF,0xAA,0xAA,0xAA,0xFA,0x02,0x00, 0x00,0x00,0x00,0x7E,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x7E,0x00,0x00,0x00, },{/*-- 文字: 江--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x60,0x01,0xC6,0x30,0x00,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,0x00, 0x04,0x04,0x7E,0x01,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x00, },};#endif仿真效果图:。

12864液晶显示程序

12864液晶显示程序
void lcd_wcmd(uchar command,uchar wait_en)
{
if(wait_en) //若wait_en为1,则要检测LCD忙信号
lcd_busy();
PORTC &=~(1<<LCD_RS);
PORTC &=~(1<<LCD_RW);
This program was produced by the
CodeWizardAVR V2.04.4a Advanced
Automatic Program Generator
?Copyright 1998-2009 Pavel Haiduc, HP InfoTech s.r.l.

**********************************************************/
void lcd_init(void)
{ DDRB=0XFF; //设置PA输出 PORTB=0XFF; //全部加上上拉电阻
DDRC=0XFF; //设置PC为输出
PORTC=0XFF; //全部加上上拉电阻
delay_ms(30); //等待上电稳定
PORTC|=(1<<LCD_PSB); //并口方式
PORTC &=~(1<<LCD_RST); //液晶复位
{X=0x80;}
else if (X==2) //第二行
{X=0x90;}
else if (X==3) //第三行
{X=0x88;}
else if (X==4) //第四行
{X=0x98;}
PORTC |=(1<<LCD_EN);

12864液晶显示程序

12864液晶显示程序

12864液晶显示程序#include <reg51.h>#include <intrins.h>sbit RS = P2^5;sbit RW = P2^6;sbit E = P2^7;sbit RES = P3^5;#define Lcd_Bus P0 //MCU P1<------> LCM#define FIRST_ADDR 0 //定义字符/汉字显示起始位置unsigned char code zk[]={0x08,0x20,0x1c,0x10,0x1c,0x1c,0xff,0x9e,0x7f,0x1e,0x1c,0x1f,0x3e,0x1f,0x3e,0x1f, 0x77,0x1f,0x41,0x3f,0x00,0x7e,0x00,0xfe,0x83,0xfc,0x7f,0xf8,0x3f,0xf0,0x0f,0xc0, };unsigned char code BMP1[]={/*-- 调入了一幅图像:D:\3033B\3033.bmp --*//*-- 宽度x高度=128x64 --*//*--总共52行数据,每行16个数据--*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x0C,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x08,0x00,0x00,0x00,0x00,0x00,0x07,0xF1,0x00,0x03,0x01,0x00,0xF0,0x00,0x00,0x00, 0x18,0x00,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x03,0x81,0x08,0x98,0x00,0x00,0x00, 0x10,0x1F,0x07,0x06,0x00,0x00,0x08,0x01,0x00,0x04,0x81,0x11,0x88,0x00,0x00,0x00, 0x10,0x21,0x0D,0x83,0xE3,0xC0,0x0F,0x02,0x00,0x04,0xC1,0x31,0x30,0x00,0x00,0x00, 0x10,0x21,0x18,0x83,0x06,0x40,0x09,0x82,0x00,0x0F,0xC1,0x21,0xE0,0x00,0x00,0x00, 0x10,0x2E,0x11,0x86,0x06,0x40,0x00,0x86,0x00,0x08,0x43,0xC3,0xE0,0x00,0x00,0x00, 0x30,0x30,0x11,0x86,0x04,0x40,0x41,0x84,0x10,0x18,0x63,0x82,0x18,0x00,0x00,0x00, 0x20,0x1E,0x1F,0x84,0x04,0x60,0x7E,0x04,0x08,0x10,0x23,0x04,0x0E,0x00,0x00,0x00, 0x3F,0x83,0x00,0xE0,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x38,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x6C,0x3C,0x00,0x20,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x42,0x22,0x03,0xFD,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x40,0x62,0x00,0x22,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x46,0x42,0x00,0x22,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x44,0x42,0x00,0x23,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x7C,0x26,0x00,0x2D,0xB0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x0C,0x3C,0x00,0x38,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x04,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x06,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x30,0x00,0x00,0x00,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x01,0xE0,0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x08,0x0C,0x30,0xF1,0x08,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x08,0x08,0x0C,0x31,0x91,0x08,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x08,0x08,0x1A,0x71,0x01,0x08,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x08,0x13,0xD1,0x01,0x08,0x00, 0x00,0x00,0x08,0x11,0x0A,0x00,0x20,0x20,0x04,0x04,0x18,0x11,0x91,0x01,0x08,0x00, 0x00,0x00,0x04,0x11,0x12,0x31,0x22,0x20,0x04,0x04,0x10,0x11,0x13,0x01,0x08,0x00, 0x00,0x00,0x02,0x1B,0x92,0x31,0x26,0x20,0x04,0x04,0x10,0x10,0x12,0x01,0x08,0x00, 0x3F,0xFF,0xFF,0x0A,0x91,0x73,0x25,0x60,0x04,0x44,0x10,0x10,0x12,0x01,0x08,0x00, 0x00,0x00,0x02,0x0A,0xB1,0x4A,0x35,0x40,0x04,0x34,0x30,0x10,0x13,0x01,0x08,0x00, 0x00,0x00,0x04,0x0E,0x61,0xCA,0x19,0x40,0x04,0x1C,0x20,0x10,0x11,0x19,0x98,0x00, 0x00,0x00,0x08,0x04,0x60,0xCC,0x19,0xCC,0x06,0x0E,0x20,0x10,0x11,0xF0,0xFC,0xC0, 0x00,0x00,0x00,0x04,0x60,0x8C,0x18,0x8C,0x03,0xF3,0xBF,0x80,0x00,0x00,0x00,0xC0, 0x00,0x00,0x00,0x00,0x40,0x80,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,0x0F,0x83,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x06,0xC3,0xFC,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x08,0x22,0x44,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x08,0x22,0x42,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x08,0x26,0x42,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x08,0x24,0x42,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x64,0x42,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0xC4,0x44,0x42,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x03,0x84,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};unsigned char code BMP[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x04,0x20,0x00,0x00,0x00,0x00, 0x1F,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x42,0x00,0x00,0x00,0x00, 0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x40,0x84,0x00,0x00,0x00,0x00, 0x00,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0xE0,0x04,0x00,0x08,0x80,0x60,0x00,0x00, 0x00,0x1F,0xFF,0xC0,0x00,0x00,0x00,0x01,0x10,0x02,0x1F,0xC1,0x01,0xD0,0x00,0x38, 0x00,0x00,0x00,0x01,0xFC,0x00,0x00,0x00,0x10,0x00,0x70,0x72,0x01,0x0C,0x00,0x68, 0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x06,0x13,0x08,0x40,0x08,0x03,0x06,0x00,0xCC, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x09,0x84,0x80,0x0C,0x1E,0x03,0x89,0x86, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0xC1,0x80,0x04,0x68,0x00,0xFF,0x02, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x41,0x00,0x00,0xC0,0x00,0x60,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x61,0x00,0x00,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x31,0x00,0x00,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x0C,0x00,0x00,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x01,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x06,0x00,0x01,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x38,0x00,0x00,0x00,0xC0,0x00,0x03,0x00,0x02,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0xE8,0x00,0x00,0x01,0x80,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x1A,0x08,0x00,0x00,0x03,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x08,0x00,0x00,0x02,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x08,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x10,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x3C,0x18,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x01,0xC0,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x03,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x04,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x04,0x00,0x02,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0xF4,0x00,0x02,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x03,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x79,0xF8,0x10,0x20,0x00, 0x02,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x09,0x08,0x10,0x20,0x00, 0x02,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x09,0x08,0x10,0x20,0x00, 0x06,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x79,0xF8,0x10,0x20,0x00, 0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0xFD,0xFE,0x00, 0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x43,0xFC,0x10,0x20,0x00, 0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x03,0xFF,0xF0,0x42,0x44,0x10,0x60,0x00, 0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x7A,0x44,0x38,0x70,0x00, 0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x0B,0xFC,0x74,0xB0,0x00, 0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x08,0x40,0x54,0xA8,0x00, 0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x08,0x48,0x91,0x28,0x00, 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x44,0x12,0x26,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x7E,0x14,0x24,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2B,0xC4,0x10,0x20,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x20,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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 chk_busy(){ RS=0;RW=1;E=1;Lcd_Bus=0xff;while((Lcd_Bus&0x80)==0x80);E=0;}/*------------------延时子程序-----------------------------*/void delay(unsigned int t){ unsigned int i,j;for(i=0;i<t;i++)for(j=0;j<10;j++);}/*------------------写命令到LCD------------------------------*/void write_com(unsigned char cmdcode){chk_busy();RS=0;RW=0;E=1;Lcd_Bus=cmdcode;delay(5);////////////////////在数据写入的时候加入适当的延时E=0;delay(5);}/*-------------------写数据到LCD----------------------------*/void write_data(unsigned char Dispdata){chk_busy();RS=1;RW=0;E=1;Lcd_Bus=Dispdata;delay(5);///////////////////在数据写入的时候加入适当的延时E=0;delay(5);}/*------------------初始化LCD屏--------------------------*/void lcdreset(){ delay(2000);write_com(0x30);delay(10); //选择基本指令集write_com(0x30); //选择8bit数据流delay(5);write_com(0x0c); //开显示(无游标、不反白)delay(10);write_com(0x01); //清除显示,并且设定地址指针为00Hdelay(500);write_com(0x06); //指定在资料的读取及写入时,设定游标的移动方向及指定显示的移位delay(0);}/*------------------自定义一个字符代码(一个星星和月亮)--------------------------*/void CGRAM(){ int i;write_com(0x30);write_com(0x40);for(i=0;i<16;i++){write_data(zk[i*2]);write_data(zk[i*2+1]);}}/*------------------显示字符串--------------------------*/void hzkdis(unsigned char code *s){ while(*s>0){ write_data(*s);s++;delay(50);}}/*------------------首屏显示--------------------------*/void ceshi(){write_com(0x01);//清除显示,并且设定地址指针为00Hdelay(5);write_com(0x80);//第一行(如果是地址是:80H,即LCD的第一行的第一个位置显示)hzkdis("----强林单片机");write_com(0x90);//第二行(如果是地址是:90H,即LCD的第二行的第一个位置显示)hzkdis("--技术项目交易网");write_com(0x88);//第三行(如果是地址是:88H,即LCD的第二行的第一个位置显示)hzkdis("LCD12864点阵液晶");write_com(0x9A);//第四行(如果是地址是:98H,即LCD的第二行的第一个位置显示)hzkdis("测试程序");}/*------------------显示图片------------------------2005.11.14.21:20修改---benladn911---*/void Disp_Img(unsigned char code *img){ unsigned int j=0;unsigned char x,y,i;for(i=0;i<9;i+=8)for(y=0;y<32;y++)/*原来为 y<26 ,上下两个半屏不能正常对接显示,导致显示的图片中间有空隙*/ for(x=0;x<8;x++){ write_com(0x36);//功能设置---8BIT控制界面,扩充指令集write_com(y+0x80); //行地址write_com(x+0x80+i); //列地址write_com(0x30);write_data(img[j++]);write_data(img[j++]);}}/*------------------清整个GDRAM空间----------------------------*/void clrgdram(){ unsigned char x,y;for(y=0;y<64;y++)for(x=0;x<16;x++){ write_com(0x34);write_com(y+0x80); //行地址write_com(x+0x80); //列地址write_com(0x30);write_data(0x00);write_data(0x00);}}/*------------------整屏写入数据:全亮,或者竖条-----------------------------*/void lcdfill(unsigned char disdata){ unsigned char x,y;for(y=0;y<32;y++)for(x=0;x<16;x++){ write_com(0x36);write_com(y+0x80); //行地址write_com(x+0x80); //列地址write_com(0x30);write_data(disdata);write_data(disdata);}write_com(0x34);write_com(0x36);}/*------------------显示横-----------------------------*/void Disp_H_Line(){ unsigned char x,y;unsigned char k=0x00;for(y=0;y<32;y++){ k=~k;for(x=0;x<16;x++){ write_com(0x36);write_com(y+0x80); //行地址write_com(x+0x80); //列地址write_com(0x30);write_data(k);write_data(k);};}write_com(0x34);write_com(0x36);}/*------------------显示边框-------------------------------*/void Frame(){unsigned char x,y;lcdfill(0x00);for(x=0;x<9;x+=8)for(y=0;y<32;y++){ write_com(0x36);write_com(y+0x80); //行地址write_com(x+0x80); //列地址write_com(0x30);write_data(0x80);write_data(0x00);write_com(0x36);write_com(y+0x80); //行地址write_com(x+0x87); //列地址write_com(0x30);write_data(0x00);write_data(0x01);}for(y=0;y<2;y++)for(x=0;x<8;x++){write_com(0x36);write_com(y*31+0x80); //行地址write_com(x+0x80+8*y); //列地址write_com(0x30);write_data(0xff);write_data(0xff);}write_com(0x34);write_com(0x36);}/*------------------在第7列的位置加入两条竖线--------------------------*/ void shuxian(){ unsigned char x,y;for(x=0;x<9;x+=8)for(y=0;y<32;y++){ write_com(0x36);write_com(y+0x80); //行地址write_com(x+0x86); //列地址write_com(0x30);write_data(0x00);write_data(0x14);};}/*------------------清屏命令--------------------------*/void clrscreen(){write_com(0x01);delay(10);}/*------------------唐诗《静夜思》--------------------------*/void gushi_display(){ write_com(0x30);clrscreen();write_com(0x80+FIRST_ADDR);hzkdis("床前明月光,");write_com(0x90+FIRST_ADDR);hzkdis("疑是地上霜。

LCD lgm12864 程序代码

LCD lgm12864  程序代码

LCD lgm12864 程序代码/**************************************LCD:lgm12864,LCD control IC:KS0108**************************************/#define uchar unsigned char#define uint unsigned int#define DataPort P0 //LCD:D0-D7sbit RS=P2^1; //Data or Instrument Selectsbit RW=P2^2; //Write or Readsbit E=P2^3; // Enable singlesbit CS1=P2^4; //Master chip enablesbit CS2=P2^5;sbit RST=P2^6; //Lcm reset/*数字数组*/unsigned char code suzidot[160] ={/*0 CHAR_30 */0x00,0xE0,0xF0,0x18,0x08,0x18,0xF0,0xE0,0x00,0x0F,0x1F,0x30,0x20,0x30,0x1F,0x0F, /*1 CHAR_31 */0x00,0x10,0x10,0xF8,0xF8,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x3F,0x20,0x20,0x00, /*2 CHAR_32 */0x00,0x70,0x78,0x08,0x08,0x88,0xF8,0x70,0x00,0x30,0x38,0x2C,0x26,0x23,0x31,0x30, /*3 CHAR_33 */0x00,0x30,0x38,0x88,0x88,0xC8,0x78,0x30,0x00,0x18,0x38,0x20,0x20,0x31,0x1F,0x0E, /*4 CHAR_34 */0x00,0x00,0xC0,0xE0,0x30,0xF8,0xF8,0x00,0x00,0x07,0x07,0x24,0x24,0x3F,0x3F,0x24, /*5 CHAR_35 */0x00,0xF8,0xF8,0x88,0x88,0x88,0x08,0x08,0x00,0x19,0x39,0x21,0x20,0x31,0x1F,0x0E, /*6 CHAR_36 */0x00,0xE0,0xF0,0x98,0x88,0x98,0x18,0x00,0x00,0x0F,0x1F,0x31,0x20,0x31,0x1F,0x0E, /*7 CHAR_37 */0x00,0x38,0x38,0x08,0xC8,0xF8,0x38,0x08,0x00,0x00,0x00,0x3F,0x3F,0x00,0x00,0x00, /*8 CHAR_38 */0x00,0x70,0xF8,0x88,0x08,0x88,0xF8,0x70,0x00,0x1C,0x3E,0x23,0x21,0x23,0x3E,0x1C, /*9 CHAR_39 */0x00,0xE0,0xF0,0x18,0x08,0x18,0xF0,0xE0,0x00,0x00,0x31,0x33,0x22,0x33,0x1F,0x0F };/*盐CD1CE */0x80,0x88,0x88,0x88,0xFF,0x48,0x48,0x48,0x00,0xFF,0x00,0x08,0x30,0x60,0x00,0x00, 0x40,0x41,0x40,0x7E,0x42,0x42,0x7E,0x42,0x42,0x7E,0x42,0x42,0x7E,0x40,0x40,0x00,/*城CB3C7 */0x10,0x10,0xFF,0x10,0x10,0xF8,0x48,0x48,0xC8,0x08,0xFF,0x08,0x0A,0xEC,0x48,0x00, 0x04,0x0C,0x07,0x42,0x32,0x0F,0x08,0x58,0x4F,0x20,0x13,0x0C,0x33,0x40,0x38,0x00,/*工CB9A4 */0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,/*学CD1A7 */0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00,/*院CD4BA */0xFE,0x02,0x32,0x4A,0x86,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x0C,0x04,0x00, 0xFF,0x00,0x02,0x04,0x83,0x41,0x31,0x0F,0x01,0x01,0x7F,0x81,0x81,0x81,0xF1,0x00,};unsigned char code hzdottime[] ={/*年CC4EA */0x00,0x20,0x10,0xCC,0x47,0x44,0x44,0xFC,0x44,0x44,0x44,0x64,0x46,0x04,0x00,0x00, 0x04,0x04,0x04,0x07,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x06,0x04,0x00,/*月CD4C2 */0x00,0x00,0x00,0x00,0xFE,0x22,0x22,0x22,0x22,0x22,0x22,0xFF,0x02,0x00,0x00,0x00, 0x00,0x80,0x40,0x30,0x0F,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x00,0x00,0x00,0x00, /*日CC8D5 */0x00,0x00,0x00,0xFE,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFF,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x7F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7F,0x00,0x00,0x00,0x00, /*时CCAB1 */0x00,0xFC,0x84,0x84,0x84,0xFE,0x14,0x10,0x90,0x10,0x10,0x10,0xFF,0x10,0x10,0x00,0x00,0x3F,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x23,0x40,0x80,0x7F,0x00,0x00,0x00,/*分CB7D6 */0x00,0x80,0x40,0x20,0x98,0x86,0x80,0x80,0x83,0x8C,0x90,0x20,0xC0,0x80,0x80,0x00, 0x01,0x00,0x80,0x40,0x20,0x1F,0x00,0x40,0x80,0x40,0x3F,0x00,0x00,0x01,0x00,0x00,/*秒CC3EB */0x20,0x24,0x24,0xA4,0xFE,0xA3,0x22,0x80,0x70,0x00,0xFF,0x00,0x10,0x20,0x60,0x00, 0x10,0x08,0x06,0x01,0xFF,0x00,0x81,0x80,0x40,0x20,0x17,0x08,0x04,0x03,0x00,0x00,/*周CD6DC */0x40,0x20,0x1F,0x00,0x00,0x7E,0x22,0x22,0x22,0x3F,0x42,0x80,0x7F,0x00,0x00,0x00,/*一CD2BB */0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*二CB6FE */0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0C,0x08,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x18,0x10,0x00,/*三CC8FD */0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0xC4,0x86,0x04,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x00,/*四CCBC4 */0x00,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFE,0x04,0x00,0x00,0x7F,0x20,0x28,0x24,0x23,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x7F,0x00,0x00,/*五CCEE5 */0x00,0x04,0x84,0x84,0x84,0x84,0xFC,0x84,0x84,0x84,0x84,0xC4,0x86,0x84,0x00,0x00,0x40,0x40,0x40,0x40,0x78,0x47,0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x60,0x40,0x00,/*六CC1F9 */0x20,0x20,0x20,0x20,0x20,0x22,0x2C,0x38,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x00,0x00,0x40,0x20,0x18,0x06,0x03,0x00,0x00,0x00,0x01,0x02,0x0C,0x38,0x70,0x00,0x00,/*星CD0C7 */0x00,0x00,0xBE,0x2A,0x2A,0x2A,0x2A,0xEA,0x2A,0x2A,0x2A,0x2A,0xBF,0x02,0x00,0x00, 0x48,0x44,0x4B,0x49,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x4D,0x49,0x61,0x40,0x00,/*期CC6DA */0x00,0x08,0xFF,0xA8,0xA8,0xA8,0xFF,0x08,0x00,0xFE,0x22,0x22,0x22,0xFF,0x02,0x00, 0x84,0x44,0x37,0x04,0x04,0x14,0xA7,0x44,0x24,0x1F,0x02,0x42,0x82,0x7F,0x00,0x00};void Delay(void){ _nop_();_nop_();_nop_();_nop_();_nop_();}/*写一个字节数据或命令*/void out_byte(uchar byte,bit RW0,bit RS0){Delay();Delay();Delay();//Delay();RW=RW0;RS=RS0;Delay();DataPort=byte;Delay();E=1; Delay(); //LCD使能E=0;Delay();}void SetLine(uchar line){ line=line & 0x07; // 0<=line<=7line=line|0xb8; //1011 1xxxout_byte(line,0,0);//写行地址命令}//设定列地址--Y 0-63void SetColumn(uchar column){column=column &0x3f; // 0=<column<=63 column=column | 0x40; //01xx xxxxout_byte(column,0,0); //写列地址命令}//设定显示开始行--XXvoid SetStartLine(uchar startline) //0--63 {startline=startline & 0x3f;startline=startline|0xc0; //1100 0000out_byte(startline,0,0);}//选择屏幕//screen: 0-全屏,1-左屏,2-右屏void SelectScreen(uchar screen){switch(screen){case 0: CS1=1;Delay(); //全屏CS2=1;Delay();break;case 1: CS1=1;Delay(); //左屏CS2=0;Delay();break;case 2: CS1=0;Delay(); //右屏CS2=1;Delay();break;}}//清屏//screen: 0-全屏,1-左屏,2-右屏void ClearScreen(uchar screen){uchar i,j;SelectScreen(screen);{ SetLine(i);for(j=0;j<64;j++){out_byte(0x00,0,1); //写数据0x00清屏}}}void ClearScreen123(void){uchar i;ClearScreen(1);for(i=0;i<20;i++); //清屏ClearScreen(2);for(i=0;i<20;i++);}//显示8*8点阵//旋转90度:字模被竖着切分//lin:行(0-7), column: 列(0-7)//address : 字模区首地址void Show88(uchar lin,uchar column,uchar *str){uchar i;SetLine(lin);SetColumn(column<<3); //每隔八点为一列,共0-7列for(i=0;i<8;i++) out_byte(*(str+i) ,0,1);}//显示8*16字符//screen:屏幕选择//lin:行(0-3), column: 列(0-7)void ShowChar(uchar screen,uchar lin,uchar column,uchar *ch) { lin=lin<<1;SelectScreen(screen);Show88(lin ,column,ch);Show88(lin+1,column,ch+8);}//显示一个汉字//screen:屏幕选择//lin:行(0-3), column: 列(0-7)//hzcode: 汉字代码(自定义的)void ShowHZ(uchar screen,uchar lin,uchar column,uchar hzcode[]) { lin=lin<<1; //lin*2SelectScreen(screen);Show88(lin,column,hzcode);Show88(lin,column+1,hzcode+8);Show88(lin+1,column+1,hzcode+24);}//连续显示汉字-lin:行(0-3), column: 列(0-7)//N:一行连续显示汉字个数void ShowHZL(uchar screen,uchar lin,uchar column,uchar N,uchar hz[]) {uchar i;uchar idata n0,n1,n2,col;col=column<<3;n0=(64-col)/16; //一屏可显示汉字个数(<=4)if(N<=n0){for(i=0;i<N;i++){ShowHZ(screen,lin,column,hz+i*32);//hz+i*32表示连续的汉字column=column+2;}}else if(N>n0) //超出一屏可显示汉字个数(<=4){for(i=0;i<n0;i++) //当前屏显示n0个字{ShowHZ(screen,lin,column,hz+i*32);column=column+2;}n1=N-n0; //剩余字数if(++screen>2) return; //在下一屏显示剩余字数,如屏幕超出则返回col=0; //在下一屏0列开始显示剩余字数if(n1<=4){for(i=0;i<n1;i++){ShowHZ(screen,lin,col,(hz+n0*32)+i*32);col=col+2;}}else if(n1>4) //超出一屏可显示汉字个数(<=4){for(i=0;i<4;i++){ShowHZ(screen,lin,col,(hz+n0*32)+i*32);col=col+2;}n2=n1-4; //剩余字数if(++screen>2) return;col=0;for(i=0;i<n2;i++){ShowHZ(screen,lin,col,(hz+n0*32+128)+i*32);col=col+2;}}//连续显示数字或字母//N:一行连续显示字符个数void ShowCharL(uchar screen,uchar lin,uchar column,uchar N,uchar ch[]) {uchar i;uchar idata n0,n1,n2,col;col=column<<3;n0=(64-col)/8; //一屏可显示字符个数(<=8)if(N<=n0){for(i=0;i<N;i++){ShowChar(screen,lin,column,ch+i*16);column=column+1;}}else if(N>n0){for(i=0;i<n0;i++){ShowChar(screen,lin,column,ch+i*16);column=column+1;}n1=N-n0; //剩余字数if(++screen>2) return;col=0;if(n1<=8){for(i=0;i<n1;i++){ShowChar(screen,lin,col,(ch+n0*16)+i*16);col=col+1;}}else if(n1>8){for(i=0;i<8;i++){ShowChar(screen,lin,col,(ch+n0*16)+i*16);col=col+1;}n2=n1-8; //剩余字数if(++screen>2) return;col=0;for(i=0;i<n2;i++){ShowChar(screen,lin,col,(ch+n0*16+128)+i*16);col=col+1;}}//读显示数据uchar ReadByte(){uchar dat;//CheckState();RS=1; RW=1;DataPort=0xff;E=1;dat=DataPort;Delay();//for(i=0;i<10;i++);E=0;return(dat);}//反显一个8*8字块//lin:行(0-3), column: 列(0-7)void ReverseShow88(uchar lin,uchar column){uchar i;uchar tab[8];SetLine(lin);//读上部8列,每个方块8*8大小SetColumn(column<<3);tab[0]=ReadByte(); //空读!!!!! //?for(i=0;i<8;i++) tab[i]=~ReadByte();//写回SetLine(lin);SetColumn(column<<3);for(i=0;i<8;i++) out_byte(tab[i] ,0,1);}//反显一个字符8*16//lin:行(0-3), column: 列(0-7)void ReverseShowChar(uchar screen,uchar lin,uchar column) {lin=lin<<1;SelectScreen(screen);ReverseShow88(lin ,column);ReverseShow88(lin+1,column);}//lin:行(0-3), column: 列(0-7)void ReverseShowHZ(uchar screen,uchar lin,uchar column){lin=lin<<1;SelectScreen(screen);ReverseShow88(lin ,column );ReverseShow88(lin ,column+1);ReverseShow88(lin+1,column );ReverseShow88(lin+1,column+1);}//连续反白显示汉字//N:一行连续显示汉字个数void ReverseShowHZL(uchar screen,uchar lin,uchar column,uchar N) {uchar i;uchar idata n0,n1,n2,col;col=column<<3;n0=(64-col)/16; //一屏可显示汉字个数(<=4)if(N<=n0){for(i=0;i<N;i++){ReverseShowHZ( screen, lin, column);column=column+2;}}else if(N>n0){for(i=0;i<n0;i++){ReverseShowHZ( screen, lin, column);column=column+2;}n1=N-n0; //剩余字数if(++screen>2) return;col=0;if(n1<=4){for(i=0;i<n1;i++){ReverseShowHZ( screen, lin, col);col=col+2;}}else if(n1>4){for(i=0;i<4;i++){ReverseShowHZ( screen, lin, col);}n2=n1-4; //剩余字数if(++screen>2) return;col=0;for(i=0;i<n2;i++){ReverseShowHZ( screen, lin, col);col=col+2;}}}}void ShowSz(uchar screen0,uchar lin,uchar column,uchar szcode) {switch(szcode){case 0: ShowChar(screen0, lin, column,suzidot); break;case 1: ShowChar(screen0, lin, column,suzidot+16); break;case 2: ShowChar(screen0, lin, column,suzidot+32); break;case 3: ShowChar(screen0, lin, column,suzidot+48); break;case 4: ShowChar(screen0, lin, column,suzidot+64); break;case 5: ShowChar(screen0, lin, column,suzidot+80); break;case 6: ShowChar(screen0, lin, column,suzidot+96); break;case 7: ShowChar(screen0, lin, column,suzidot+112);break;case 8: ShowChar(screen0, lin, column,suzidot+128);break;case 9: ShowChar(screen0, lin, column,suzidot+144);break;default:ShowChar(screen0, lin, column,suzidot+128);//ReverseShowChar(screen0,lin,column); //反白显示'8' }}void iniLCD(void){uint i;for(i=0;i<10000;i++);RST=0;for(i=0;i<1000;i++);RST=1;SelectScreen(0);out_byte(0x3e,0,0); //关显示for(i=0;i<=100;i++);ClearScreen(0); for(i=0;i<=100;i++);//清屏SelectScreen(0);for(i=0;i<=100;i++);out_byte(0x3f,0,0); for(i=0;i<=100;i++);//开显示SelectScreen(0);for(i=0;i<=100;i++);SetStartLine(0); //开始行:0LCD lgm12864}- 11 -。

12864液晶屏汇编程序

12864液晶屏汇编程序

12864液晶屏汇编程序[ 作者:佚名 | 转贴自:本站原创 | 点击数:211 | 更新时间:2005-3-28 | 文章录入:qwll20000 ] XCS BIT 00H ;显示器片选0=CS1,1=CS2 ;20H-2FH为位寻址区,位地址从00H-7FH BZPD BIT 01H ;0=上8X8半字,1=下8X8半字HHBZ BIT 02H ;换行标志HZDH BIT 03H ;0=显示汉字,1=显示动画LCD_RW BIT P3.0LCD_DI BIT P3.1LCD_E BIT P3.3LCD_CS1 BIT P3.5LCD_CS2 BIT P3.4LCD_OPEN DA TA 30HLCD_LINE DATA 31HLCD_PAGE DATA 32HLCD_Y DA TA 33HYCPD DA TA 34H ;左右半屏溢出判断HHPD DA TA 35H ;换行判断XWPD DA TA 36H ;写完一整屏判断ORG 0000HMOV SP,#40HSETB XCS ;选择CS2MOV LCD_OPEN,#01H ;开显示器1,关显示器0LCALL LCDOPENMOV LCD_LINE,#00H ;设置起始行LCALL SETLINEMOV LCD_PAGE,#00H ;设置页地址 LCALL SETPAGEMOV LCD_Y,#00H ;设置列地址 LCALL SETYLJMP CLRST1CLR4:INC LCD_PAGECLRST1:LCALL SETPAGEMOV R7,#40HCLR5:MOV A,#0FFH ;显示校验LCALL LCDWRDATADJNZ R7,CLR5MOV A,LCD_PAGECJNE A,#07H,CLR4MOV LCD_LINE,#00HLCALL SETLINEMOV LCD_PAGE,#00HLCALL SETPAGEMOV LCD_Y,#00HLCALL SETYLJMP CLRST2CLR6:INC LCD_PAGECLRST2:LCALL SETPAGEMOV R7,#40HCLR7:MOV A,#00H ;清显示LCALL LCDWRDATADJNZ R7,CLR7MOV A,LCD_PAGECJNE A,#07H,CLR6CLR XCS ;选择CS1MOV LCD_OPEN,#01H ;开显示器1, 关显示器0 LCALL LCDOPENMOV LCD_LINE,#00HLCALL SETLINE ;设置起始行MOV LCD_PAGE,#00HLCALL SETPAGE ;设置页地址MOV LCD_Y,#00HLCALL SETY ;设置列地址LJMP CLRST3CLR0:INC LCD_PAGECLRST3:LCALL SETPAGEMOV R7,#40HCLR1:MOV A,#0FFH ;显示校验LCALL LCDWRDATADJNZ R7,CLR1MOV A,LCD_PAGECJNE A,#07H,CLR0MOV LCD_LINE,#00HLCALL SETLINEMOV LCD_PAGE,#00HLCALL SETPAGEMOV LCD_Y,#00HLCALL SETYLJMP CLRST4CLR2:INC LCD_PAGECLRST4:LCALL SETPAGEMOV R7,#40HCLR3:MOV A,#00H ;清显示LCALL LCDWRDATADJNZ R7,CLR3MOV A,LCD_PAGECJNE A,#07H,CLR2;初始化完毕************************************************************************* CLR HZDHWRLCD:JNB HZDH,XZFXDH:MOV DPTR,#DHDOT ;写动画或图片LJMP DH0XZF:MOV DPTR,#HZDOT ;写字符(汉字或字母或符号)MOV XWPD,#00HHZ0:CLR XCSMOV LCD_LINE,#00H ;置起始行LCALL SETLINEMOV LCD_PAGE,#00HLCALL SETPAGE ;置页MOV LCD_Y,#00H ;置列LCALL SETYMOV HHPD,#00HHZ7:MOV YCPD,#00HHZ8:CLR BZPDHZ3:MOV R0,#08H ;写左上8个Y列HZ1:MOV A,#00HMOVC A,@A+DPTRLCALL LCDWRDATAINC DPTRINC LCD_YDJNZ R0,HZ1JB BZPD,HZ2CLR C ;Y列减8, 即返回扫描MOV A,LCD_YSUBB A,#08HMOV LCD_Y,ALCALL SETYINC LCD_PAGE ;页地址加1,即换第2页扫描 LCALL SETPAGESETB BZPDLJMP HZ3HZ2:DEC LCD_PAGE ;返回到第1页中,准备下一个半字扫描 LCALL SETPAGEINC YCPDMOV A,YCPDCJNE A,#08H,HZ8JB XCS,HZ9SETB XCS ;换屏LCALL SETPAGEMOV LCD_Y,#00H ;置列LCALL SETYLJMP HZ7HZ9:CLR XCS ;写完一行后从CS2返回到CS1中INC LCD_PAGEINC LCD_PAGELCALL SETPAGE ;下一行开始MOV LCD_Y,#00HLCALL SETYINC HHPDMOV A,HHPDCJNE A,#04H,HZ7INC XWPD ;换第二幅画面MOV A,XWPDCJNE A,#02H,HZ0LJMP$DH0:MOV XWPD,#00HDH1:CLR XCSMOV LCD_LINE,#00H ;置起始行 LCALL SETLINEMOV LCD_PAGE,#00HLCALL SETPAGE ;置页MOV LCD_Y,#00H ;置列LCALL SETYMOV HHPD,#00HDH2:MOV R0,#40H ;写上64个Y列 DH3:MOV A,#00HMOVC A,@A+DPTRLCALL LCDWRDATAINC DPTRDJNZ R0,DH3JB XCS,DH4SETB XCSLCALL SETPAGEMOV LCD_Y,#00HLCALL SETYLJMP DH2DH4:CLR XCS ;写完一行后从CS2返回到CS1中 INC LCD_PAGELCALL SETPAGE ;下一行开始MOV LCD_Y,#00HLCALL SETYINC HHPDMOV A,HHPDCJNE A,#08H,DH2INC XWPD ;换第二幅画面MOV A,XWPDCJNE A,#02H,DH1LJMP$LCDWRINST:NOPJB XCS,INS0CLR LCD_CS1SETB LCD_CS2LJMP INS1INS0:SETB LCD_CS1CLR LCD_CS2INS1:SETB LCD_ECLR LCD_DICLR LCD_RWMOV P1,ALCALL DLY10CLR LCD_ELCALL DLY10RETLCDWRDATA:NOPJB XCS,DA T0CLR LCD_CS1SETB LCD_CS2LJMP DA T1DA T0:SETB LCD_CS1CLR LCD_CS2DA T1:SETB LCD_ESETB LCD_DICLR LCD_RWMOV P1,ALCALL DLY10CLR LCD_ELCALL DLY10NOPRETLCDOPEN:MOV A,LCD_OPEN ;开显示器 ANL A,#3FHORL A,#3EHLCALL LCDWRINSTNOPRETSETLINE:MOV A,LCD_LINEORL A,#0C0H ;设置起始行LCALL LCDWRINSTRETSETPAGE:MOV A,LCD_PAGEANL A,#0BFHORL A,#0B8H ;设置页地址 LCALL LCDWRINSTNOPRETSETY:MOV A,LCD_YANL A,#7FHORL A,#40HNOP ;设置列地址LCALL LCDWRINSTNOPRETDL Y10:NOPMOV R5,#01HDL1:MOV R4,#01HDL2:MOV R6,#0FHDL3:DJNZ R6,DL3DJNZ R4,DL2DJNZ R5,DL1NOPRETHZDOT:;新 CD0C2DB 000H,044H,04CH,07CH,0D7H,0E6H,07CH,05CH DB 000H,022H,01AH,04EH,0FFH,07FH,00EH,09AH DB 044H,0FEH,0FCH,046H,0C2H,0C3H,062H,040H DB 060H,03FH,01FH,000H,0FFH,0FFH,000H,000H;年 CC4EADB 000H,020H,010H,018H,0ECH,0CFH,04AH,048H DB 000H,004H,004H,004H,007H,007H,004H,004H DB 0F8H,0F8H,048H,048H,068H,04CH,008H,000H DB 0FFH,0FFH,004H,004H,004H,004H,006H,004H;快 CBFECDB 000H,0C0H,060H,0FFH,0FEH,030H,060H,008H DB 000H,000H,000H,0FFH,07FH,080H,041H,071H DB 008H,0FFH,0FEH,008H,0F8H,0FCH,008H,000H DB 03DH,00FH,007H,00DH,039H,071H,0E1H,041H;乐 CC0D6DB 000H,000H,080H,080H,0FEH,0FCH,084H,084H DB 000H,040H,020H,030H,01CH,00EH,024H,040H DB 0FEH,0F6H,082H,083H,0C2H,080H,000H,000H DB 0FFH,07FH,000H,002H,00CH,018H,070H,020H;欢 CBBB6DB 000H,034H,0C4H,004H,0C4H,0FCH,03EH,024H DB 000H,040H,038H,00FH,007H,03CH,098H,060H DB 018H,00EH,0EFH,0CAH,048H,038H,01CH,008H DB 030H,01CH,00FH,007H,01CH,070H,0E0H,040H;迎 CD3ADDB 000H,040H,046H,0DCH,0E8H,040H,0FEH,0FCH DB 000H,040H,0E0H,03FH,01FH,032H,067H,0C3H DB 006H,003H,0FDH,0FCH,004H,0FCH,0FEH,004H DB 0C2H,0C1H,0FFH,0DFH,0C2H,0C7H,0C3H,040H;使 CCAB9DB 000H,080H,060H,0F8H,0EFH,006H,008H,0F8H DB 000H,000H,000H,0FFH,07FH,080H,080H,043H DB 0E8H,028H,0FFH,0FEH,028H,0E8H,0FCH,028H DB 065H,039H,01FH,037H,061H,063H,0C1H,040H;用 CD3C3DB 000H,000H,000H,0FFH,0FEH,022H,022H,022H DB 000H,080H,070H,03FH,00FH,002H,002H,002H DB 0FEH,0FEH,022H,022H,022H,0FEH,0FFH,002H DB 07FH,03FH,002H,042H,042H,0FFH,07FH,000H;杭 CBABCDB 000H,010H,0D0H,0FFH,0FEH,090H,010H,008H DB 000H,006H,001H,0FFH,07FH,001H,083H,040H DB 0E8H,0C9H,04FH,04EH,0C8H,0E8H,04CH,008H DB 07FH,03FH,000H,000H,07FH,0FFH,0C0H,070H;州 CD6DDDB 000H,010H,0E0H,0C0H,0FFH,0FEH,010H,0E0H DB 000H,080H,041H,070H,03FH,00FH,000H,001H DB 0C0H,0FEH,0FCH,030H,0E0H,0C0H,0FFH,0FEH DB 000H,03FH,01FH,000H,001H,000H,0FFH,07FH;求 CC7F3DB 000H,000H,008H,068H,0C8H,088H,008H,0FFH DB 000H,010H,070H,038H,00DH,026H,041H,0FFH DB 0FEH,088H,0CBH,07EH,02CH,008H,000H,000H DB 07FH,003H,006H,01CH,038H,070H,020H,000H;是 CCAC7DB 000H,080H,080H,080H,0FFH,0BEH,0AAH,0AAH DB 000H,080H,060H,038H,00FH,01AH,030H,020H DB 0AAH,0AAH,0AAH,0FEH,0BFH,082H,0C0H,080H DB 07FH,07FH,044H,0C4H,0C6H,0C4H,0C0H,040H;医 CD2BDDB 000H,000H,0FFH,0FEH,042H,0A2H,0BAH,09EH DB 000H,040H,0FFH,07FH,060H,050H,058H,04CH DB 096H,0F2H,0F2H,092H,09AH,0D3H,082H,000H DB 046H,043H,041H,046H,04CH,058H,068H,040H;学 CD1A7DB 000H,010H,038H,01CH,00BH,04EH,048H,04BH DB 000H,000H,004H,004H,004H,004H,044H,044HDB 04EH,0C8H,0ECH,04FH,00AH,038H,01CH,008H DB 0FFH,07FH,004H,004H,004H,006H,004H,000H;科 CBFC6DB 000H,024H,0A4H,0FEH,0FEH,0A3H,022H,0C0H DB 000H,00CH,003H,0FFH,07FH,001H,00BH,008H DB 08CH,038H,010H,0FFH,0FEH,000H,000H,000HDB 00BH,005H,004H,0FFH,07FH,002H,003H,002H;技 CBCBCDB 000H,010H,010H,0FFH,0FEH,010H,098H,048H DB 000H,00CH,046H,0FFH,07FH,001H,080H,040H DB 0C8H,048H,07FH,07EH,0C8H,0E8H,04CH,008H DB 061H,037H,01CH,01EH,037H,061H,0E0H,040H;有 CD3D0DB 000H,084H,044H,064H,034H,0FCH,0EFH,026H DB 000H,000H,000H,000H,000H,0FFH,07FH,009H DB 024H,024H,024H,0E4H,0F4H,024H,006H,004H DB 009H,009H,049H,0FFH,07FH,000H,000H,000H;限 CCFDEDB 000H,0FFH,0FEH,042H,0BEH,01FH,002H,0FFH DB 000H,0FFH,0FFH,008H,01FH,00FH,040H,0FFH DB 0FEH,092H,092H,092H,0FEH,0FFH,002H,000H DB 07FH,061H,036H,01CH,039H,06EH,0E4H,040H;公 CB9ABDB 000H,000H,080H,0C0H,070H,03EH,00FH,082H DB 000H,001H,000H,060H,0F0H,078H,06EH,067H DB 0C0H,080H,00FH,03EH,070H,0E0H,0C0H,080H DB 021H,022H,026H,03CH,0F8H,070H,001H,000H;司 CCBBEDB 000H,000H,010H,0D2H,092H,092H,092H,092H DB 000H,000H,000H,01FH,00FH,008H,008H,008HDB 01FH,00FH,000H,040H,040H,0FFH,07FH,000H;地 CB5D8DB 000H,020H,020H,0FEH,0FCH,020H,060H,0F8H DB 000H,010H,030H,01FH,01FH,008H,004H,07FH DB 0F0H,020H,0FFH,0FEH,010H,0F0H,0F8H,010H DB 0FFH,0C0H,0C7H,0C7H,0C2H,0C7H,0F3H,040H;址 CD6B7DB 000H,020H,020H,0FEH,0FCH,020H,020H,0E0H DB 000H,010H,030H,03FH,01FH,058H,048H,07FH DB 0C0H,000H,000H,0FFH,0FEH,040H,060H,040H DB 07FH,040H,040H,07FH,07FH,040H,060H,040H;: CA3BADB 000H,000H,000H,000H,000H,000H,000H,000H DB 000H,000H,036H,036H,000H,000H,000H,000H DB 000H,000H,000H,000H,000H,000H,000H,000H DB 000H,000H,000H,000H,000H,000H,000H,000H;通 CCDA8DB 000H,040H,046H,0DCH,0E8H,040H,000H,0F9H DB 000H,040H,0E0H,03FH,01FH,030H,060H,0FFH DB 0F1H,055H,0FDH,0F9H,057H,0F3H,0F9H,010H DB 0DFH,0C2H,0DFH,0CFH,0D2H,0FFH,0DFH,040H;惠 CBBDDDB 000H,000H,002H,0FEH,0FAH,0AAH,0AAH,0FFHDB 0FFH,0AAH,0AAH,0FAH,0FEH,00AH,000H,000H DB 0FBH,0D2H,0C2H,0F2H,04FH,016H,070H,020H;北 CB1B1DB 000H,020H,020H,020H,020H,0FEH,0FEH,000H DB 000H,020H,060H,020H,010H,0FFH,0FFH,000H DB 000H,0FFH,0FEH,082H,0C0H,060H,038H,010H DB 000H,07FH,0FFH,0C1H,0C0H,0C0H,0F0H,040H;路 CC2B7DB 000H,07FH,03EH,0E2H,0BEH,07FH,002H,010H DB 000H,07CH,060H,03FH,03FH,012H,00BH,001H DB 08CH,0DFH,066H,074H,0DCH,08EH,004H,000H DB 0FFH,07EH,042H,042H,0FEH,07FH,003H,001H;2 CHAR_32DB 008H,00CH,084H,0C4H,064H,03CH,018H,000H DB 00EH,00FH,009H,008H,008H,00CH,00CH,000H;8 CHAR_38DB 0B8H,0FCH,044H,044H,044H,0FCH,0B8H,000H DB 007H,00FH,008H,008H,008H,00FH,007H,000H;号 CBAC5DB 000H,080H,080H,080H,0BFH,09EH,092H,092H DB 000H,000H,000H,000H,004H,00EH,007H,005H DB 092H,092H,092H,0BEH,09FH,082H,0C0H,080H DB 024H,044H,0E4H,07CH,01EH,004H,000H,000H;电 CB5E7DB 000H,000H,0F8H,0F0H,090H,090H,090H,0FFH DB 000H,000H,00FH,007H,004H,004H,004H,07FH DB 0FEH,090H,090H,090H,0F0H,0F8H,010H,000H DB 0FFH,0C4H,0C4H,0C4H,0CFH,0C7H,0F0H,040H;话 CBBB0DB 000H,040H,046H,0DCH,0E8H,040H,020H,024H DB 000H,000H,020H,07FH,03FH,010H,008H,0FFH DB 024H,024H,0FEH,0FEH,026H,023H,032H,020H DB 07EH,042H,043H,043H,042H,0FEH,07FH,002H;: CA3BADB 000H,000H,000H,000H,000H,000H,000H,000H DB 000H,000H,036H,036H,000H,000H,000H,000H DB 000H,000H,000H,000H,000H,000H,000H,000H DB 000H,000H,000H,000H,000H,000H,000H,000H;0 CHAR_30DB 0F8H,0FCH,004H,0C4H,024H,0FCH,0F8H,000H DB 007H,00FH,009H,008H,008H,00FH,007H,000H;5 CHAR_35DB 07CH,07CH,044H,044H,0C4H,0C4H,084H,000H DB 004H,00CH,008H,008H,008H,00FH,007H,000H;7 CHAR_37DB 00CH,00CH,004H,084H,0C4H,07CH,03CH,000HDB 000H,000H,00FH,00FH,000H,000H,000H,000H;1 CHAR_31DB 000H,010H,018H,0FCH,0FCH,000H,000H,000H DB 000H,008H,008H,00FH,00FH,008H,008H,000H;- CHAR_2DDB 080H,080H,080H,080H,080H,080H,080H,000H DB 000H,000H,000H,000H,000H,000H,000H,000H;8 CHAR_38DB 0B8H,0FCH,044H,044H,044H,0FCH,0B8H,000H DB 007H,00FH,008H,008H,008H,00FH,007H,000H;2 CHAR_32DB 008H,00CH,084H,0C4H,064H,03CH,018H,000H DB 00EH,00FH,009H,008H,008H,00CH,00CH,000H;6 CHAR_36DB 0F0H,0F8H,04CH,044H,044H,0C0H,080H,000H DB 007H,00FH,008H,008H,008H,00FH,007H,000H;0 CHAR_30DB 0F8H,0FCH,004H,0C4H,024H,0FCH,0F8H,000H DB 007H,00FH,009H,008H,008H,00FH,007H,000H;4 CHAR_34DB 0C0H,0E0H,0B0H,098H,0FCH,0FCH,080H,000H DB 000H,000H,000H,008H,00FH,00FH,008H,000H;7 CHAR_37DB 00CH,00CH,004H,084H,0C4H,07CH,03CH,000HDB 000H,000H,00FH,00FH,000H,000H,000H,000H;1 CHAR_31DB 000H,010H,018H,0FCH,0FCH,000H,000H,000HDB 000H,008H,008H,00FH,00FH,008H,008H,000H;5 CHAR_35DB 07CH,07CH,044H,044H,0C4H,0C4H,084H,000HDB 004H,00CH,008H,008H,008H,00FH,007H,000HDHDOT:;-------------------------------------------------------------------------------DB000H,000H,000H,000H,000H,000H,000H,000H,007H,0E7H,0E3H,0E1H,0E1H,0E1H,0E1H,0C1H, DB0C1H,081H,081H,081H,083H,083H,083H,083H,087H,087H,08FH,08FH,09FH,0BFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F3H,0F3H,0F1H,0E1H,061H,061H,020H, DB030H,030H,0B0H,0B0H,0B0H,0B8H,0B8H,0BCH,0BCH,03EH,03EH,03FH,03FH,07FH,07FH,07FH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FEH,0FEH,0FCH,0FCH,0FCH,0FEH,0FFH, DB0F7H,0E3H,0E7H,0EFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,000H,000H,000H, DB000H,000H,000H,000H,000H,000H,000H,000H,000H,001H,07FH,0FFH,0F3H,083H,083H,081H,DB001H,001H,000H,080H,080H,000H,002H,002H,002H,006H,004H,0A5H,0EDH,0EDH,0EBH,0DBH, DB0F7H,0BFH,07FH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F7H,089H,080H,082H,0C0H,080H, DB000H,000H,000H,000H,000H,088H,0C0H,0F8H,0F8H,0F8H,0F0H,0F0H,0E0H,0C0H,0C0H,0F0H, DB0F8H,0F8H,0FCH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,00FH,000H,000H,000H, DB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,07FH,0FFH,0FFH,0FFH,0FFH,DB0FFH,0FEH,0FFH,0FFH,0FFH,0FFH,0FEH,0FEH,0FEH,0FEH,0FEH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,03FH,00FH,003H,000H,000H,000H,000H,000H, DB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,03FH,03FH,07FH,0BFH,03FH,03FH, DB03FH,01FH,01FH,00FH,007H,007H,001H,000H,000H,000H,000H,000H,000H,000H,000H,000H, DB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,003H,03FH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,01FH,000H,000H,07CH,0FFH,0FFH,078H, DB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,DB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,003H,0FFH,DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0E3H,0E3H,0C3H,087H,08FH,01FH,01FH,0BFH,0BFH,0FFH,0FFH, DB0FFH,0F7H,0F3H,0F3H,0FBH,0FBH,0FBH,0FBH,0FBH,0FBH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,07FH,07FH,07FH,07FH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,00FH,000H,000H,000H,000H,000H,000H,000H, DB000H,000H,000H,000H,000H,000H,0E0H,0F8H,0FCH,0FEH,0FEH,0FEH,0FEH,0FEH,0FCH,0FCH, DB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,0F8H,0FFH,DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,DB0FFH,0FDH,0F9H,0F3H,0E7H,0C7H,087H,007H,007H,0C7H,087H,087H,08FH,08FH,08FH,0CFH, DB0CFH,0DFH,0FFH,09FH,0DFH,0DFH,0FFH,0CFH,0EFH,0EFH,0FFH,0FFH,0CFH,0CFH,0E7H,0E7H, DB0E3H,0E3H,0E3H,0F1H,0F9H,0F9H,0F8H,0FCH,0FCH,0FEH,0FEH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,03FH,00FH,007H,000H,000H,000H,000H,000H,000H,000H,000H,000H,DB000H,000H,000H,000H,000H,000H,000H,007H,027H,07FH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,DB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,0E0H,0FCH,0FFH,0FFH,DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0F8H,0F1H,0F3H,0E7H,0CFH,0CFH,0DFH,0DFH, DB09FH,09FH,0BFH,0BFH,0BFH,09FH,0DFH,0DFH,0DFH,0CFH,0EFH,0FFH,0FFH,0FFH,0FBH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, DB0FFH,0F7H,0FDH,0FCH,0FCH,0FEH,0FFH,0FCH,0C0H,000H,000H,000H,000H,000H,000H,000H, DB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H,0F1H,0FFH,0FFH,。

12864显示程序

12864显示程序
void Conversion(uint temp_data)
{
Wan=temp_data/10000+0x30 ;
temp_data=temp_data%10000;
Qian=temp_data/1000+0x30 ;
temp_data=temp_data%1000;
Delay5us();
ADXL345_SCL = 0;
Delay5us();
}
ADXL345_RecvACK();
}
/**************************************
{
ADXL345_SDA = 1;
ADXL345_SCL = 1;
Delay5us();
ADXL345_SDA = 0;
Delay5us();
}
void ADXL345_SendACK(bit ack)
{
ADXL345_SDA = ack;
ADXL345_SCL = 1;
Delay5us();
void ADXL345_Single_Write(uchar REG_Address,uchar REG_data)
{
ADXL345_Start();
ADXL345_SendByte(SlaveAddress);
ADXL345_SendByte(REG_Address);
#include<reg52.h>
#include<intrins.h>
#include<math.h>
#include<stdio.h>

多种12864液晶屏显示程序

多种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液晶屏显示温度日期时间程序

12864液晶屏显示温度日期时间程序
sbit key2=P3^3;
sbit key3=P3^6;
sbit beep=P0^5;
//------------------------------------------------------------------
// ds1302定义
//-----------------------------------------------------------------
unsigned char dat1 = 0;
for (i=8;i>0;i--)
{
DQ = 0; // 给脉冲信号
dat1>>=1;
DQ = 1; // 给脉冲信号
if(DQ)
dat1|=0x80;
delay(5);
}
return(dat1);
//set time--second,munite,hour,day,month,week,year
//-----------------------------------------------------------------
//*****************************************************************
//往DS31302中写入一字节
//*****************************************************************
void writebyte_ds1302(uchar ds1302_data)
{
uchar i;
uchar temp_data=ds1302_data;

12864的液晶显示程序(无字库)

12864的液晶显示程序(无字库)

12864的液晶显示程序(无字库)12864.h#ifndef __12864_H__#define __12864_H__#include#include/***************************************利用I/O口模拟点阵液晶所需时序点阵液晶控制端口定义,需根据硬件适当改变****************************************/sbit LCD_RS = P2^0;//控制端口定义sbit LCD_RW = P2^1;sbit LCD_E = P2^2;sbit LCD_CSA = P2^3;//H选通,即高电平有效sbit LCD_CSB = P2^4;#define LCD_Data P0//LCD数据端口8位#define R 1#define L 2/*****************************************函数声明*****************************************/void ReadStatusLCD(unsigned char select);//从LCD读出忙标志位unsigned char ReadDataLCD(unsigned char select);//从LCD 读出数据void WriteDataLCD(unsigned char WDLCD,unsigned char select);//向LED写入数据void WriteCommandLCD(unsigned char WCLCD , unsigned char BusyC,unsigned char select);//向LCD写入命令void LcdReset(void) ;//初始化函数,完成液晶模块的初始设置void clear_LCD(unsigned char select);//清屏函数void Clr_All_Lcd(void);//全清屏函数void set_XY(unsigned char Column,unsigned char Page);//设置数据写入或读出的地址,通过页号和列数可以唯一确定一个地址void xy_Write(unsigned char Column,unsigned char Page,unsigned char dataW);//向指定行列写数据void LcmPutDots(unsigned char Column,unsigned char Page, unsigned char DotByte );//显示点void whiteword(unsigned char Column,unsigned char Page, const unsigned char puts[][16] );//显示16×16点阵的编码void WhiteWord_Com(unsigned char Column,unsigned char Page,unsigned char C_num,unsigned char V_num, unsigned char * puts );//通用的显示函数void Drawing_dot(unsigned char x,unsigned char y);void Drawing_line_vertical(unsigned x);#endif12864.c/****************************************************LCD12864点阵液晶屏,通过I/O口直接控制,采用模拟时序控制****************************************************/#include"12864.h"#include/*********************************************************** 功能:从LCD读取状态位变量:select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/ void ReadStatusLCD(unsigned char select){switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_Data = 0xff;//置位输入口,已实现输入LCD_RS=0;LCD_RW=1;LCD_E=1;//高电平读取数据//_nop_(); //若晶振速度高,可在此作延时处理while(LCD_Data&0x80);//最高位为忙标志,检测忙信号状态LCD_E=0;//_nop_(); //若晶振速度高,可在此作延时处理}/*********************************************************** 功能:从LCD读取数据变量:select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/ unsigned char ReadDataLCD(unsigned char select){unsigned char dataR;LCD_Data = 0xff;//置位输入口,已实现输入switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_RW=1;LCD_RS=1;LCD_E = 1;// 操作允许脉冲信号,高电平读出//_nop_(); //若晶振速度高,可在此作延时处理dataR = LCD_Data;LCD_E= 0;return dataR;}/***********************************************************功能:向LCD写入数据参数:WDLCD待写入的字符数据select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/void WriteDataLCD(unsigned char WDLCD,unsigned char select){switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}ReadStatusLCD(select);//检测忙标志LCD_RS = 1;LCD_RW = 0;LCD_Data = WDLCD;LCD_E = 1;//_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 0; //下降沿写入数据//_nop_(); //若晶振速度高,可在此作延时处理}/***********************************************************功能:向LCD写入命令参数:WDLCD待写入的字符数据BusyC是否要检查忙标志位选择标志,1为进行,0为不检测select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/void WriteCommandLCD(unsigned char WCLCD , unsigned char BusyC,unsigned char select) {if(BusyC) ReadStatusLCD(select);//根据需要检测忙switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_Data = WCLCD;LCD_RS = 0;LCD_RW = 0;LCD_E = 1;//_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 0;}/************************************************************** **************** 功能:清显示RAM区(清屏)参数:select为驱动控制器选择1为左2为右*************************************************************** **************** */void clear_LCD(unsigned char select){unsigned char i,j;for(i=0;i<8;i++){ //8页,换页清零WriteCommandLCD( 0xb8|i,1 ,select);//页面地址设置,并分别写入左右模块中WriteCommandLCD( 0x40,1 ,select);//列地址设置,设置为0列,并分别写入左右三个模块中for(j=0;j<64;j++){ //页内清零WriteDataLCD( 0 ,select);}}}/************************************************************** *************** 功能:清LCD左右屏*************************************************************** **************/ void Clr_All_Lcd(void){clear_LCD(1);clear_LCD(2);}/************************************************************** **************** 功能:LCD初始化,分为左,右模块初始化参数:select为驱动控制器选择1为左2为右*************************************************************** **************** */void LcdReset(void){unsigned char i;for(i=0;i<5;i++){WriteCommandLCD( 0xc0,0 ,R);//设置显示起始行为第一行,并分别写入左右模块中,不检测忙标志WriteCommandLCD( 0xc0,0 ,L);//_nop_(); //若晶振速度高,可在此作延时处理}WriteCommandLCD( 0xc0,1 ,R);//设置显示起始行为第一行,并分别写入左右模块中,检测忙标志WriteCommandLCD( 0xc0,1 ,L);WriteCommandLCD( 0x3f,1 ,R);//开显示设置,并分别写入左右模块中WriteCommandLCD( 0x3f,1 ,L);clear_LCD(R);//清左屏clear_LCD(L);//清右屏}/************************************************************** **************** 功能:设置数据写入或读出的地址,通过页号和列数可以唯一确定一个地址参数:Column表示列号,Page表示页号*************************************************************** **************** */void set_XY(unsigned char Column,unsigned char Page){unsigned char x,y;unsigned char select;switch (Column&0x40) //完成左右屏的判断,根据列号完成区分,<64为左屏,>=64为右屏{case 0x00: {select = 1;ReadStatusLCD(select);break;}/*为左区*/case 0x40: {select = 2;ReadStatusLCD(select);break;}/*为右区*/}x = Column&0x3F|0x40; /* col.and.0x3f.or.Set Y Address*/ y = Page&0x07|0xB8; /* row.and.0x07.or.set Page */WriteCommandLCD( y,1 ,select);//设置页面地址WriteCommandLCD( x,1 ,select);//设置列地址}/************************************************************** **************** 功能:根据地址值(页数和列号),写入数据,即写入显示缓冲区,便可以显示在LCD屏上参数:Column表示列号,Page表示页号,dataW表示待写入的数据*************************************************************** **************** */void xy_Write(unsigned char Column,unsigned char Page,unsigned char dataW){set_XY(Column,Page);LCD_RW=0;LCD_RS=1;_nop_();//若晶振速度高,可在此作延时处理LCD_Data = dataW;// 送数据_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 1;_nop_(); //若晶振速度高,可在此作延时处理LCD_E= 0; // 操作允许脉冲信号,下降沿写入}/************************************************************** **************** 功能:用于显示点阵参数:Column表示列号,Page表示页号,*************************************************************** **************** */void LcmPutDots(unsigned char Column,unsigned char Page, unsigned char DotByte ){unsigned char i;i=Column;for(;Page<8;Page++){for(;Column<128;Column++){xy_Write(Column,Page,DotByte);//DotByte = ~DotByte;}Column=i;}}/************************************************************** **************** 功能:在指定列,指定页显示待显示的点阵编码,用于显示16*16点阵码参数:Column表示列号,Page表示页号,puts待显示的点阵编码首指针*************************************************************** **************** */void whiteword(unsigned char Column,unsigned char Page, const unsigned char puts[][16] ){unsigned char i,j;for(i=0;i<2;i++)//此处的2为控制点阵行数,实际点阵行数为2*8=16行,此处的16(对应的点行数)应为8的倍数{for(j=0;j<16;j++)//此处控制每行显示的列数{xy_Write(Column+j,Page+i,puts[i][j]);}}}/****************************************************************************** 功能:在指定列,指定页显示待显示指定点阵的编码参数:Column表示列号,Page表示页号,C_num为显示点阵的行数(物理行8的倍数),V_num 为列(物理列)puts待显示的点阵编码首指针*************************************************************** **************** */void WhiteWord_Com(unsigned char Column,unsigned char Page,unsigned char C_num,unsigned char V_num, unsigned char * puts){unsigned char i,j;for(i=0;i<(C_num/8);i++)//此处的2为控制点阵行数,实际点阵行数为2*8=16行,此处的16(对应的点行数)应为8的倍数{for(j=0;j<="">{xy_Write(Column+j,Page+i,*(puts+i*V_num+j));//注意地址的变化规律}}}/************************************************************** **************** 功能:绘点参数:Column表示列号,Page表示页号,C_num为显示点阵的行数(物理行8的倍数),V_num 为列(物理列)puts待显示的点阵编码首指针*************************************************************** **************** */void Drawing_dot(unsigned char x,unsigned char y){unsigned char y_byte,x_bit,y_bit,reverse_y;//此处y_byte为page,y_bit为具体行号,x_bit 为行号unsigned char dot;reverse_y=63-y;x_bit=x;y_byte=reverse_y/8;y_bit=y%8;// for(;x_bit<128;x_bit++)if(y_bit==0) dot=0x80;if(y_bit==1) dot=0x40;if(y_bit==2) dot=0x20;if(y_bit==3) dot=0x10;if(y_bit==4) dot=0x08;if(y_bit==5) dot=0x04;if(y_bit==6) dot=0x02;if(y_bit==7) dot=0x01;xy_Write(x_bit,y_byte,dot);/* reverse_y=64-y;if(y_bit==7) y_byte=y_byte-1;y_bit=y%8;if(y_byte==(-1)) break;*/}/************************************************************** **************** 功能:绘垂直直线参数:x表示列号*************************************************************** **************** */void Drawing_line_vertical(unsigned char x){xy_Write(x,0,0xff);xy_Write(x,1,0xff);xy_Write(x,2,0xff);xy_Write(x,3,0xff);xy_Write(x,4,0xff);xy_Write(x,5,0xff);xy_Write(x,6,0xff);xy_Write(x,7,0xff);}主程序.c/************************************************************** **************** ****************12864液晶屏上显示"南京绝妙科技发展有限公司,025-******** 开发板欢迎使用","0~9",刷新后重显。

OLED12864参数数据

OLED12864参数数据

二、模块引脚说明引脚名称方向说明引脚名称方向说明1 VSS - GND(0V)11 DB4 I 数据42 VDD - Supply Voltage For Logic (+5v) 12 DB5 I 数据53 VO - Supply Voltage For LCD 13 DB6 I 数据64 RS (CS) O H: Data L: Instruction Code 14 DB7 I 数据75 R/W (SID) O H: Read L: Write15 PSB O H: Parallel Mode L: Serial Mode6 E (SCLK) O Enable Signal16 NC - 空脚7 DB0 I 数据0 17 /RST O Reset Signal 低电平有效8 DB1 I 数据1 18 NC - 空脚9 DB2 I 数据2 19 LEDA - 背光源负极(LED-0V)10 DB3 I 数据3 20 LEDK - 背光源正极(LED+5V)ITEM NOMINAL DIMEN UNIT模块体积93×78×12.5 mm视域70.7×38.8 mm行列点阵数128×64 dots点距离0.52×0.52 mm点大小0.48×0.48 mm三、液晶硬件接口1、逻辑工作电压(VDD):4.5~5.5V2、电源地(GND):0V3、工作温度(Ta):0~60℃(常温) / -20~75℃(宽温)4、电气特性见附图1 外部连接图(参考附图2)模块有并行和串行两种连接方法(时序如下):1、8位并行连接时序图MPU写资料到模块V V I H1 I L1R SR/WED B0-D B7A SA HA HP WD S WH RCTTTTTTTTV a l i dd a t aMPU从模块读出资料RSR/WE2、串行连接时序图四、用户指令集指令表—2:(RE=1:扩充指令集)HS12864-12串口接线方式:备注:1、当模块在接受指令前,微处理顺必须先确认模块内部处于非忙碌状态,即读取BF标志时BF需为0,方可接受新的指令;如果在送出一个指令前并不检查BF标志,那么在前一个指令和这个指令中间必须延迟一段较长的时间,即是等待前一个指令确实执行完成,指令执行的时间请参考指令表中的个别指令说明。

12864液晶屏幕使用说明及程序

12864液晶屏幕使用说明及程序

12864使用说明一、串/并接口1.1 串口接口管脚信号*注释1:如在实际应用中仅使用并口通讯模式,可将PSB 接固定高电平。

*注释2:模块内部接有上电复位电路,因此在不需要经常复位的场合可将该端悬空。

*注释3:如背光和模块共用一个电源,可以将模块上的JA、JK 用焊锡短接。

1.2 并行接口管脚信号*注释1:如在实际应用中仅使用并口通讯模式,可将PSB 接固定高电平。

*注释2:模块内部接有上电复位电路,因此在不需要经常复位的场合可将该端悬空。

*注释3:如背光和模块共用一个电源,可以将模块上的JA、JK 用焊锡短接。

二、模块主要硬件构成说明控制器接口信号说明:2.1、RS,R/W的配合选择决定控制界面的4种模式:2.2、E信号●忙标志BFBF 标志提供内部工作情况.BF=1 表示模块在进行内部操作,此时模块不接受外部指令和数据.BF=0 时, 模块为准备状态,随时可接受外部指令和数据.利用STATUS RD 指令,可以将BF 读到DB7 总线,从而检验模块之工作状态.●字型产生ROM(CGROM)字型产生ROM(CGROM)提供8192 个此触发器是用于模块屏幕显示开和关的控制。

DFF=1 为开显示(DISPLAY ON),DDRAM 的内容就显示在屏幕上,DFF=0 为关显示(DISPLAY OFF)。

DFF 的状态是指令DISPLAY ON/OFF 和RST 信号控制的。

●显示数据RAM(DDRAM)模块内部显示数据 RAM 提供 64×2 个位元组的空间,最多可控制 4 行 16 字(64 个字)的中文字型显示,当写入显示数据 RAM 时,可分别显示 CGROM 与CGRAM 的字型;此模块可显示三种字型,分别是半角英、数字型(16*8)、CGRAM 字型及 CGROM 的中文字型。

三种字型的选择,由在 DDRAM 中写入的编码选择,在0000H—0006H 的编码中(其代码分别是 0000、0002、0004、0006 共 4 个)将选择 CGRAM 的自定义字型,02H—7FH 的编码中将选择半角英数字的字型,至于A1 以上的编码将自动的结合下一个位元组,组成两个位元组的编码形成中文字型的编码BIG5(A140—D75F),GB(A1A0-F7FFH)。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
oled12864_wr_cmd(0xd9);//--set pre-charge period
oled12864_wr_cmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
oled12864_wr_cmd(0xda);//--set com pins hardware configuration
}
}
OLED12864_CS = 1;
}
/*********************LCD复位************************************/
void oled12864_cls(void)
{
unsigned char y,x;
OLED12864_CS = 0;//使能片选
static u8 pre_x,pre_y;
tmp2 = (y%8);
tmp2 = 1 << tmp2;
y >>= 3;
if(white_black)
{
tmp1 = oled_buf[y][x];//取得当前值
tmp1 |= tmp2;
}
else
{
tmp1 = oled_buf[y][x];
tmp1 &= (!tmp2);
oled12864_wr_cmd(0xa6);//--set normal display
oled12864_wr_cmd(0xa8);//--set multiplex ratio(1 to 64)
oled12864_wr_cmd(0x3f);//--1/64 duty
oled12864_wr_cmd(0xd3);//-set display offsetShift Mapping RAM Counter (0x00~0x3F)
}
oled_buf[y][x] = tmp1;
}
//放一个8×6字符串
//注意column是0~128,row是0~7
void oled12864_put_86char(char column6, char row ,char *ch)
{
char ncount = 0;
char c;
char max_ncount = (X_WIDTH - column6) / 6;
for(y=0;y<8;y++)
{
oled12864_wr_cmd(0xb0+y);
oled12864_wr_cmd(0x01);
oled12864_wr_cmd(0x10);
for(x=0;x<X_WIDTH;x++)
oled12864_wr_cmd(0);
}
OLED12864_CS = 1;
}
/*********************LCD初始化************************************/
{
u16Tmp = oled_buf[y][x];
//oled12864_delay(10000);
//while( SPI1->SR & 0x0080 );//等待BSY变成0
for(nCount=0;nCount<9;nCount++);
SPI1->DR = u16Tmp;
//oled12864_wr_data( oled_buf[y][x] );
OLED12864程序.哥瞎写的
/*___________________________OLED12864.c_____*/
#include "stm32f4xx.h"
#include "oled12864.h"
#include "codetab.h"
#define DEFAULT_PRT_START_ROW 2//默认显示字符串的起始行数
{
n_count--;
}
}
/*********************LCD全屏************************************/
void oled12864_fill_full(unsigned char bmp_dat)
{
unsigned char y,x;
OLED12864_CS = 0;//使能片选
column6++;
oled_buf[row][column6] = F6x8[c][2];
column6++;
oled_buf[row][column6] = F6x8[c][3];
column6++;
oled_buf[row][column6] = F6x8[c][4];
column6++;
oled_buf[row][column6] = F6x8[c][5];
default_prt_nowrow = DEFAULT_PRT_START_ROW;
OLED12864_CS = 1;
}
//无x,y值审查
//white为1,black为0
void oled12864_draw_point(u8 x, u8 y, u8 white_black)
{
u8 tmp1,tmp2;
oled12864_wr_cmd(0xa6);// Disable Inverse Display On (0xa6/a7)
oled12864_wr_cmd(0xaf);//--turn on oled panel
oled12864_fill_full(0x02); //初始清屏
oled12864_set_pos(0,0);
oled12864_wr_cmd(0x3f);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F)
oled12864_wr_cmd(0x81);//--set contrast control register
#define OLED12864_DC_CMD OLED12864_DC_L
#define OLED12864_RST PAout(3)
#define OLED12864_CS PAout(4)
#define OLED12864_CS_H GPIOA->BSRRL = 1<<4
#define OLED12864_CS_L GPIOA->BSRRH = 1<<4
#define OLED12864_DC PAout(8)
#define OLED12864_DC_H GPIOA->BSRRL = 1<<8
#define OLED12864_DC_L GPIOA->BSRRH = 1<<8
#define OLED12864_DC_DATA OLED12864_DC_H
for(y=0;y<8;y++)
{
oled12864_wr_cmd(0xb0+y);
oled12864_wr_cmd(0x01);
oled12864_wr_cmd(0x10);
for(x=0;x<X_WIDTH;x++)
{
//oled12864_delay(10000);
oled12864_wr_data(bmp_dat);
#define DEFAULT_PRT_END_ROW 7 //默认显示字符串的中止行数
u8 default_prt_nowrow;
u8 oled_buf[8][128];
/*********延时函数**********/
void oled12864_delay(int n_count)
{
while(n_count)
oled12864_wr_cmd(0xcf); // Set SEG Output Current Brightness
oled12864_wr_cmd(0xa0);//--Set SEG/Column Mapping 0xa0左右反置0xa1正常
oled12864_wr_cmd(0xc0);//Set COM/Row Scan Direction 0xc0上下反置0xc8正常
#define OLED_SPI //用手动SPI方式
#define OLED_HIGH 1
#define OLED_LOW 0
#define OLED_DC_C 0
#define OLED_DC_D 1
#define XLevelL0x00
#define XLevelH0x10
#define XLevel((XLevelH&0x0F)*16+XLevelL)
default_prt_nowrow = DEFAULT_PRT_START_ROW;
oled12864_put_86char(0,default_prt_nowrow,"--------------------");
}
//oled内容按oled_buf[]刷新
void oled12864_refresh(void)
oled12864_wr_cmd(0x00);//-not offset
oled12864_wr_cmd(0xd5);//--set display clock divide ratio/oscillator frequency
oled12864_wr_cmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
相关文档
最新文档