12864(带字库)串行显示汉字和图形 ICC程序
扫描二维码
随时随地手机看文章
// HS12864-15B - 串行方式 - 显示汉字 - 图形
// 带字库
// 芯片 ATMEGA16L
// 时钟 4MHz 内部
// 功能1:汉字及字母的显示,汉字不能错位
// 功能2:图形显示,显示横线、竖线、边框、128*64图像、64*64图像,图形显示较慢
// 注意:采用了文本区和图形区清零函数,汉字和图形显示切换时要注意,基本指令集和扩充指令集的转换
// 保存图像的数组最后不能有逗号
#include
#define cs 2 // PORTD.2,片选信号
#define sid 3 // PORTD.3,串行数据线
#define sclk 4 // PORTD.4,时钟线
#define psb 5 // PORTD.5, psb=H,并口模式, psb=L,串口模式
#define rst 6 // PORTD.6, LCD复位,低有效
#define run 7 // PORTB.7,运行标志
#define CS_SET PORTD |= 1< void delay_nms(unsigned int); // 延时 n ms const unsigned char ex1[] = {"泰 山 学 院"}; //字符串以 结束 const unsigned char tab[]={ const unsigned char tab2[]={ const unsigned char tab4[]={ void main() Disp_H_Line(); // 显示横条 lcdfill(0xaa); // 显示竖条 frame(); // 显示边框 img_disp(tab); // 显示联通图标128*64 img_disp(tab2); // 显示移动图标128*64 img_disp2(tab3); // 显示移动图标64*64 LcdClearBMP(); // 图形区RAM清零 wr_comm(0x36);
void init_lcd(void); // 初始化
void chk_busy(void); // 检测忙闲
void wr_da
void wr_comm(unsigned char comm); // 写命令到LCD
void wr_str(unsigned char const *s); // 向LCD写字符串,长度64字符之内(32个汉字) ,指针要指向ROM
//void wr_str(const unsigned char *s); // const的位置在unsigned char的前后都可以
void hz_disp(void); // 写汉字或字母
void img_disp (unsigned char const *img); // 显示图片128*64
void img_disp2(unsigned char const *img); // 显示图片64*64 左半屏
void img_disp3(unsigned char const *img); // 显示图片64*64 右半屏
void LcdClearTXT(void); // 文本区RAM清零
void LcdClearBMP(void); // 图形区RAM清零
void lcdfill(unsigned char disdata); // 整屏全亮或显示竖条
void Disp_H_Line(void); // 显示横条
void frame(void); // 显示边框
const unsigned char ex2[] = {"物 电 学 院"};
const unsigned char ex3[] = {"电子创新实验室"};
const unsigned char ex4[] = {" 欢 迎 您 "};
const unsigned char ex5[] = {"黄河远上白云间"};
const unsigned char ex6[] = {"一片孤城万仞山"};
const unsigned char ex7[] = {"羌笛何须怨杨柳"};
const unsigned char ex8[] = {"春风不度玉门关"};
const unsigned char ex9[] = {"TAI SHAN DIAN ZI"};
const unsigned char ex10[] = {"Designer:Charlie"};
/*-- 调入了一幅图像:联通图标 4567.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,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X07,0XFF,0X00,0X00,0X1F,0XFC,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X3F,0XFF,0XE0,0X00,0XFF,0XFF,0X80,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0XFF,0XFF,0XF8,0X03,0XFF,0XFF,0XE0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XFE,0X0F,0XFF,0XFF,0XF8,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0XFF,0XFF,0XFF,0XBF,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFF,0X8F,0XFF,0XFF,0XFE,0X3F,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFC,0X03,0XFF,0XFF,0XF0,0X07,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XF8,0X00,0XFF,0XFF,0XE0,0X07,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XF8,0X00,0X3F,0XFF,0X80,0X03,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFC,0X00,0X7F,0XFF,0XC0,0X07,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFC,0X01,0XFF,0XFF,0XF0,0X0F,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0XFF,0X07,0XFF,0XFF,0XFC,0X1F,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0XFF,0XC7,0XFF,0XFF,0XF8,0X7F,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X03,0XFF,0XE1,0XFF,0X1F,0XF1,0XFF,0XF8,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0XFF,0XF8,0X7C,0X0F,0XC3,0XFF,0XE0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X7F,0XFE,0X10,0X03,0X0F,0XFF,0XC0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X1F,0XFF,0X00,0X00,0X3F,0XFF,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X7E,0X00,0X00,0X07,0XFF,0XC0,0X00,0X7F,0XFC,0X00,0X00,0X0F,0X80,0X00,
0X00,0X07,0XFF,0XF0,0X00,0X63,0XFF,0XF0,0X01,0XFF,0XF0,0XC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0XC0,
0X00,0X1F,0XFF,0XFC,0X01,0XF0,0XFF,0XF8,0X07,0XFF,0XE1,0XE0,0X07,0XFF,0XFF,0X00,
0X00,0X07,0XFF,0XE0,0X00,0X43,0XFF,0XE0,0X01,0XFF,0XF8,0XC0,0X00,0XFF,0XF8,0X00,
0X00,0X00,0X00,0X00,0X00,0X0F,0XFF,0XC0,0X00,0X7F,0XFC,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X1F,0XFF,0X00,0X00,0X3F,0XFF,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X7F,0XFC,0X30,0X03,0X0F,0XFF,0XC0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X01,0XFF,0XF8,0XFC,0X0F,0XC3,0XFF,0XE0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X03,0XFF,0XE1,0XFF,0X3F,0XF1,0XFF,0XF8,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0XFF,0X87,0XFF,0XFF,0XF8,0X7F,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFF,0X07,0XFF,0XFF,0XFC,0X1F,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFC,0X01,0XFF,0XFF,0XF0,0X0F,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X1F,0XF8,0X00,0X7F,0XFF,0XC0,0X07,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X1F,0XF8,0X00,0X7F,0XFF,0X80,0X03,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XF8,0X00,0XFF,0XFF,0XE0,0X07,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFC,0X03,0XFF,0XFF,0XF0,0X0F,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X0F,0XFF,0X9F,0XFF,0XFF,0XFE,0X7F,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0XFF,0XFF,0XFF,0X3F,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XFC,0X0F,0XFF,0XFF,0XF0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0XFF,0XFF,0XF8,0X03,0XFF,0XFF,0XE0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X3F,0XFF,0XE0,0X00,0XFF,0XFF,0X80,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X07,0XFE,0X00,0X00,0X1F,0XFC,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00
};
/*-- 调入了一幅图像:移动图标 123456.bmp --*/
/*-- 宽度x高度=128x64 --*/
0X00,0X00,0X00,0X00,0X00,0X00,0X0F,0XFF,0XFF,0XF8,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X0F,0XFF,0XFF,0XFF,0XFF,0XF0,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X01,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X3F,0XFF,0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0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XE0,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X1F,0XFF,0XFF,0XFF,0XFF,0XF8,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X3F,0XFF,0XFF,0XFE,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XCF,0XE6,0X00,0X00,0X00,0X00,0X00,0X00,0X00
};
const unsigned char tab3[]={
/*-- 调入了一幅图像:移动图标 1234.bmp --*/
/*-- 宽度x高度=64x64 --*/
0X00,0X00,0X00,0X3F,0XFE,0X00,0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XC0,0X00,0X00,
0X00,0X00,0X0F,0XFF,0XFF,0XF8,0X00,0X00,0X00,0X00,0X7F,0XFF,0XFF,0XFE,0X00,0X00,
0X00,0X00,0XFF,0XFF,0XFF,0XFF,0X80,0X00,0X00,0X03,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,
0X00,0X07,0XFF,0XF0,0X07,0XFF,0XF0,0X00,0X00,0X0F,0XFF,0XE0,0X01,0XFF,0XF8,0X00,
0X00,0X1F,0XFF,0X80,0X00,0XFF,0XFC,0X00,0X00,0X7F,0XFF,0X00,0X00,0X7F,0XFE,0X00,
0X00,0X7F,0XFE,0X00,0X00,0X1F,0XFF,0X00,0X00,0XFF,0XFC,0X00,0X78,0X0F,0XFF,0X80,
0X01,0XFF,0XF0,0X01,0XFE,0X07,0XFF,0XC0,0X03,0XFF,0XE0,0X03,0XFF,0X83,0XFF,0XC0,
0X03,0XFF,0XC0,0X0F,0XFF,0XC0,0XFF,0XE0,0X07,0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,
0X3F,0XC0,0XF8,0X00,0X07,0XC0,0X07,0XFC,0X1F,0XF0,0X3E,0X00,0X0F,0X80,0X0F,0XFC,
0X1F,0XF8,0X1F,0X00,0X3F,0X00,0X1F,0XF8,0X0F,0XFC,0X0F,0X80,0X7E,0X00,0X3F,0XF8,
0X0F,0XFE,0X07,0XE1,0XFC,0X00,0XFF,0XF0,0X07,0XFF,0X81,0XFF,0XF8,0X01,0XFF,0XF0,
0X07,0XFF,0XC0,0XFF,0XE0,0X03,0XFF,0XE0,0X03,0XFF,0XE0,0X7F,0XC0,0X07,0XFF,0XE0,
0X01,0XFF,0XF0,0X3F,0X80,0X1F,0XFF,0XC0,0X00,0XFF,0XF8,0X00,0X00,0X3F,0XFF,0X80,
0X00,0XFF,0XFE,0X00,0X00,0X7F,0XFF,0X00,0X00,0X7F,0XFF,0X00,0X00,0XFF,0XFE,0X00,
0X00,0X3F,0XFF,0X80,0X01,0XFF,0XFC,0X00,0X00,0X1F,0XFF,0XC0,0X07,0XFF,0XF8,0X00,
0X00,0X07,0XFF,0XF0,0X0F,0XFF,0XF0,0X00,0X00,0X03,0XFF,0XFC,0X3F,0XFF,0XE0,0X00,
0X00,0X01,0XFF,0XFF,0XFF,0XFF,0X80,0X00,0X00,0X00,0X7F,0XFF,0XFF,0XFE,0X00,0X00,
0X00,0X00,0X1F,0XFF,0XFF,0XFC,0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XE0,0X00,0X00,
0X00,0X00,0X00,0X7F,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X0B,0XD0,0X00,0X00,0X00
};
/*-- 调入了一幅图像:联通图标 45678.bmp --*/
/*-- 宽度x高度=64x64 --*/
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,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,0XF0,0X03,0XE0,0X00,0X00,
0X00,0X00,0X07,0XFC,0X0F,0XF8,0X00,0X00,0X00,0X00,0X0F,0XFE,0X1F,0XFC,0X00,0X00,
0X00,0X00,0X1F,0XFF,0X3F,0XFE,0X00,0X00,0X00,0X00,0X1F,0XFF,0XFF,0XFE,0X00,0X00,
0X00,0X00,0X1F,0XBF,0XFF,0X7E,0X00,0X00,0X00,0X00,0X3E,0X1F,0XFC,0X1F,0X00,0X00,
0X00,0X00,0X3E,0X0F,0XFC,0X1F,0X00,0X00,0X00,0X00,0X3E,0X07,0XF8,0X1F,0X00,0X00,
0X00,0X00,0X3E,0X07,0XF8,0X1F,0X00,0X00,0X00,0X00,0X3E,0X0F,0XFC,0X3F,0X00,0X00,
0X00,0X00,0X1F,0X1F,0XFE,0X3E,0X00,0X00,0X00,0X00,0X1F,0X9F,0XFE,0X7E,0X00,0X00,
0X00,0X00,0X0F,0XCF,0X3C,0XFC,0X00,0X00,0X00,0X00,0X0F,0XE6,0X19,0XFC,0X00,0X00,
0X00,0X00,0X07,0XF0,0X13,0XF8,0X00,0X00,0X00,0X00,0X03,0XF0,0X07,0XF0,0X00,0X00,
0X00,0X70,0X01,0XF8,0X07,0XE0,0X03,0X80,0X01,0XFC,0X0C,0XFC,0X0F,0XC8,0X0F,0XE0,
0X07,0XFE,0X0C,0XFE,0X1F,0XCC,0X1F,0XF0,0X07,0XFF,0X1E,0X7F,0X3F,0X9E,0X3F,0XF8,
0X0F,0XFF,0XBF,0X3F,0XFF,0X3F,0X7F,0XFC,0X0F,0XFF,0XFF,0X1F,0XFE,0X3F,0XFF,0XFC,
0X1F,0X8F,0XFE,0X0F,0XFC,0X1F,0XFC,0X7E,0X1F,0X07,0XFC,0X0F,0XF8,0X0F,0XF8,0X3E,
0X1F,0X03,0XF8,0X07,0XF8,0X07,0XF0,0X3E,0X1F,0X03,0XF8,0X07,0XF8,0X07,0XF0,0X3E,
0X1F,0X07,0XFC,0X0F,0XFC,0X0F,0XF8,0X3E,0X1F,0X8F,0XFE,0X1F,0XFC,0X1F,0XFC,0X7E,
0X0F,0XFF,0XFF,0X1F,0XFE,0X3F,0XFF,0XFC,0X0F,0XFF,0XBF,0X3F,0X7F,0X3F,0X7F,0XFC,
0X07,0XFF,0X1E,0X7F,0X3F,0X9E,0X3F,0XF8,0X03,0XFE,0X0C,0XFE,0X1F,0XCC,0X1F,0XF0,
0X01,0XFC,0X01,0XFC,0X0F,0XE8,0X0F,0XE0,0X00,0X00,0X03,0XF8,0X07,0XE0,0X00,0X00,
0X00,0X00,0X03,0XF0,0X07,0XF0,0X00,0X00,0X00,0X00,0X07,0XE4,0X13,0XF8,0X00,0X00,
0X00,0X00,0X0F,0XEE,0X39,0XFC,0X00,0X00,0X00,0X00,0X1F,0XCF,0X7C,0XFC,0X00,0X00,
0X00,0X00,0X1F,0X9F,0XFE,0X7E,0X00,0X00,0X00,0X00,0X3F,0X1F,0XFE,0X3E,0X00,0X00,
0X00,0X00,0X3E,0X0F,0XFC,0X3F,0X00,0X00,0X00,0X00,0X3E,0X07,0XF8,0X1F,0X00,0X00,
0X00,0X00,0X3E,0X07,0XF8,0X1F,0X00,0X00,0X00,0X00,0X3E,0X0F,0XFC,0X1F,0X00,0X00,
0X00,0X00,0X3E,0X1F,0XFC,0X3F,0X00,0X00,0X00,0X00,0X3F,0XBF,0XFF,0X7E,0X00,0X00,
0X00,0X00,0X1F,0XFF,0X7F,0XFE,0X00,0X00,0X00,0X00,0X1F,0XFE,0X3F,0XFC,0X00,0X00,
0X00,0X00,0X0F,0XFE,0X1F,0XFC,0X00,0X00,0X00,0X00,0X07,0XFC,0X0F,0XF8,0X00,0X00,
0X00,0X00,0X01,0XF0,0X03,0XE0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00
};
{
delay_nms(200);
init_lcd(); // LCD初始化,并清屏
LcdClearTXT(); // 文本区RAM清零
LcdClearBMP(); // 图形区RAM清零
DDRB |= 1<
{
hz_disp(); // 显示汉字或字母
LcdClearTXT(); // 文本区RAM清零
lcdfill(0xff); // 显示全亮
delay_nms(3000);
run_neg;
delay_nms(3000);
run_neg;
delay_nms(3000);
run_neg;
delay_nms(3000);
run_neg;
delay_nms(3000);
run_neg;
delay_nms(3000);
run_neg;
img_disp3(tab4); // 显示联通图标64*64
delay_nms(3000);
run_neg;
}
}
/*----------------向LCD发送1个字节---------------*/
void LCD_send_byte(unsigned char a)
{
unsigned char i,j;
for(i=0;i<8;i++)
{
SCLK_CLR;
j=1;while(--j);
if(a&0x80)
SID_SET;
else
SID_CLR;
j=1;while(--j);
a = a<<1;
SCLK_SET;
j=1;while(--j);
SCLK_CLR;
j=1;while(--j);
}
}
/*------------------LCD读数据-------------------*/
unsigned char LCD_read_byte(void)
{
unsigned char i,j,dat,dat2;
dat=dat2=0;
DDRD &= ~(1<
for(i=0;i<8;i++) // 读高字节
{
dat = dat<<1;
SCLK_CLR;
j=1;while(--j);
SCLK_SET;
j=1;while(--j);
if((PIND&(1<
j=1;while(--j);
}
for(i=0;i<8;i++) // 读低字节
{
dat2 = dat2<<1;
SCLK_CLR;
j=1;while(--j);
SCLK_SET;
j=1;while(--j);
if((PIND&(1<
j=1;while(--j);
}
dat = (dat&0xf0) + (dat2&0x0f);
DDRD |= 1<
return dat;
}
/*--------------检测LCD忙闲---------------*/
void chk_busy(void)
{
unsigned char dat,j;
do
{
CS_SET;
j=1;while(--j);
LCD_send_byte(0xfc);
dat = LCD_read_byte();
j=1;while(--j);
CS_CLR;
j=1;while(--j);
}while(dat&0x80);
}
/*------------------LCD初始化-----------------*/
void init_lcd(void)
{
unsigned char j;
PORTD = 0xff;
DDRD = 0xff; // PD输出,提供LCD控制信号
SCLK_CLR;
CS_CLR;
RST_CLR;
delay_nms(2);
RST_SET;
delay_nms(10);
PSB_CLR; // 串行
j=2;while(--j);
wr_comm(0x30); // 基本指令,8位数据模式
wr_comm(0x0C); // 显示开,游标关,反白关
wr_comm(0x01); // 清除显示,并且设定地址指针为00H
wr_comm(0x06); // 指定在资料的读取及写入时,设定游标的移动方向及指定显示的移位
}
/*------------写命令到LCD--------------*/
void wr_comm(unsigned char comm)
{
unsigned char temp,j;
chk_busy(); // 检测LCD忙闲
CS_SET;
j=1;while(--j);
LCD_send_byte(0xf8); // 写命令
temp = comm&0xf0;
LCD_send_byte(temp); // 写高字节
temp=(comm&0x0f)<<4;
LCD_send_byte(temp); // 写低字节
j=1;while(--j);
CS_CLR;
}
/*------------写数据到LCD--------------*/
void wr_da
{
unsigned char temp,j;
chk_busy(); // 检测LCD忙闲
CS_SET;
j=1;while(--j);
LCD_send_byte(0xfa); // 写数据
temp = dat&0xf0;
LCD_send_byte(temp); // 写高字节
temp = (dat&0x0f)<<4;
LCD_send_byte(temp); // 写低字节
j=1;while(--j);
CS_CLR;
}
/*-------向LCD写一个字符串,长度64字符之内---------- */
void wr_str(unsigned char const *s)
{
while(*s>0)
{
wr_da
s++;
}
}
/*------------显示汉字或字母--------------*/
void hz_disp(void)
{
wr_comm(0x30); // 基本指令,8位数据模式
wr_comm(0x01); // 清除显示,并且设定地址指针为00H
/*-显示4行汉字-*/
wr_comm(0x80); // 第 1 行
wr_str(ex1);
wr_comm(0x90); // 第 2 行
wr_str(ex2);
wr_comm(0x88); // 第 3 行
wr_str(ex3);
wr_comm(0x98); // 第 4 行
wr_str(ex4);
run_neg;
delay_nms(3000); // 延时
wr_comm(0x01); // 清除显示
/*-显示4行汉字-*/
wr_comm(0x80);
wr_str(ex5);
wr_comm(0x90);
wr_str(ex6);
wr_comm(0x88);
wr_str(ex7);
wr_comm(0x98);
wr_str(ex8);
run_neg;
delay_nms(3000);
wr_comm(0x01); // 清除显示
/*-显示2行字母-*/
wr_comm(0x80);
wr_str(ex9);
wr_comm(0x88);
wr_str(ex10);
run_neg;
delay_nms(3000);
wr_comm(0x01); // 清除显示
}
/*---------------- 显示图片,128*64 ------------------- */
void img_disp(unsigned char const *img)
{
unsigned char i,x,y;
unsigned int j=0;
for(i=0;i<9;i=i+8) // i=0,控制上半屏,i=8,控制下半屏
{
for(y=0;y<32;y++) // y控制行地址
{
for(x=0;x<8;x++) // x控制列地址
{
wr_comm(0x36); // 功能设置:8位控制界面,扩充指令集,绘图显示开
wr_comm(0x80+y); // 行地址
wr_comm(0x80+x+i); // 列地址 x+i=0~7, 上半屏,x+i=8~15,下半屏
wr_da
wr_da
wr_comm(0x30); // 功能设置:8位控制界面,基本指令集,绘图显示关
}
}
}
}
/*---------------- 显示图片,64*64 ------------------- */
void img_disp2(unsigned char const *img) // 左半屏
{
unsigned char i,x,y;
unsigned int j=0;
for(i=0;i<9;i=i+8) // i=0,控制上半屏,i=8,控制下半屏
{
for(y=0;y<32;y++) // y控制行地址
{
for(x=0;x<4;x++) // x控制列地址
{
wr_comm(0x36); // 功能设置:8位控制界面,扩充指令集,绘图显示开
wr_comm(0x80+y); // 行地址
wr_comm(0x80+x+i); // 列地址 x+i=0~7, 上半屏,x+i=8~15,下半屏
wr_da
wr_da
wr_comm(0x30); // 功能设置:8位控制界面,基本指令集,绘图显示关
}
}
}
}
/*---------------- 显示图片,64*64 ------------------- */
void img_disp3(unsigned char const *img) // 右半屏
{
unsigned char i,x,y;
unsigned int j=0;
for(i=0;i<9;i=i+8) // i=0,控制上半屏,i=8,控制下半屏
{
for(y=0;y<32;y++) // y控制行地址
{
for(x=4;x<8;x++) // x控制列地址
{
wr_comm(0x36); // 功能设置:8位控制界面,扩充指令集,绘图显示开
wr_comm(0x80+y); // 行地址
wr_comm(0x80+x+i); // 列地址 x+i=0~7, 上半屏,x+i=8~15,下半屏
wr_da
wr_da
wr_comm(0x30); // 功能设置:8位控制界面,基本指令集,绘图显示关
}
}
}
}
/*-------------- 整屏填充,全亮,或者竖条 ---------------------- */
void lcdfill(unsigned char disdata) //整屏写入数据:全亮,或者竖条
{
unsigned char x,y;
for(y=0;y<32;y++)
{
for(x=0;x<16;x++)
{
wr_comm(0x36);
wr_comm(y+0x80); // 行地址
wr_comm(x+0x80); // 列地址
wr_comm(0x30);
wr_da
wr_da
}
wr_comm(0x34);
wr_comm(0x36);
}
}
/*------------------ 显示横条 -----------------------------*/
void Disp_H_Line(void)
{ unsigned char x,y;
unsigned char k=0x00;
for(y=0;y<32;y++)
{ k=~k;
for(x=0;x<16;x++)
{
wr_comm(0x36);
wr_comm(y+0x80); // 行地址
wr_comm(x+0x80); // 列地址
wr_comm(0x30);
wr_da
wr_da
}
}
wr_comm(0x34);
wr_comm(0x36);
}
/*------------------ 显示边框 -------------------------------*/
void frame(void)
{
unsigned char x,y;
lcdfill(0x00);
for(x=0;x<9;x+=8)
{
for(y=0;y<32;y++)
{
wr_comm(0x36);
wr_comm(y+0x80); // 行地址
wr_comm(x+0x80); // 列地址
wr_comm(0x30);
wr_da
wr_da
wr_comm(y+0x80); // 行地址
wr_comm(x+0x87); // 列地址
wr_comm(0x30);
wr_da
wr_da
}
}
for(y=0;y<2;y++)
{
for(x=0;x<8;x++)
{
wr_comm(0x36);
wr_comm(y*31+0x80); // 行地址
wr_comm(x+0x80+8*y); // 列地址
wr_comm(0x30);
wr_da
wr_da
}
}
wr_comm(0x34);
wr_comm(0x36);
}
/*----------------文本区清RAM函数----------------*/
void LcdClearTXT(void)
{
unsigned char i;
wr_comm(0x30); // 8BitMCU,基本指令集合
wr_comm(0x80); // AC归起始位
for(i=0;i<64;i++)
wr_da
}
/*-----------------图形区清RAM函数-----------------*/
void LcdClearBMP(void)
{
unsigned char i,j;
wr_comm(0x34); // 8Bit扩充指令集,即使是36H也要写两次
wr_comm(0x36); // 绘图ON,基本指令集里面36H不能开绘图
for(i=0;i<32;i++) // 12864实际为256x32
{
wr_comm(0x80|i); // 行位置
wr_comm(0x80); // 列位置
for(j=0;j<32;j++) // 256/8=32 byte
wr_da
}
}
void delay_nms(unsigned int k) // 延时 n ms
{
while(k) // 4M晶振,一个循环1ms
{
int i;
i=700;
while(i--);
k=k-1;
}
}