当前位置:首页 > 单片机 > 单片机
[导读]// HS12864-15B - 并行方式 // 带字库 // 芯片 ATMEGA16L // 时钟 4MHz 内部 // 采用系统自带延时程序 // 功能1:汉字及字母的显示,汉字不能错位 // 功能2:图形显示,显示横线、竖线、边框、128*64图像、64*6

// HS12864-15B - 并行方式

// 带字库
// 芯片 ATMEGA16L
// 时钟 4MHz 内部
// 采用系统自带延时程序
// 功能1:汉字及字母的显示,汉字不能错位
// 功能2:图形显示,显示横线、竖线、边框、128*64图像、64*64图像
// 注意:采用了文本区和图形区清零函数,汉字和图形显示切换时要注意,基本指令集和扩充指令集的转换
// 保存图像的数组最后不能有逗号

#include
#include

#define LCD_Bus PORTC // 数据总线
#define rs PORTD.2 // 数据&指令选择,H:写数据,L:写指令
#define rw PORTD.3 // 读&写选择,H:read,L:write
#define e PORTD.4 // 读写使能
#define psb PORTD.5 // psb=H,并口模式, psb=L,串口模式
#define rst PORTD.6 // LCD复位,低有效
#define bf 7 // 忙闲状态标志位,PORTC.7,H:内部正执行操作,L:空闲
#define run PORTB.7 // 运行标志

void init_lcd(void); // 初始化
void chk_busy(void); // 检测忙闲
void wr_data(unsigned char dat); // 写数据到LCD
void wr_comm(unsigned char comm); // 写命令到LCD
void wr_str(unsigned char flash *s); // 向LCD写字符串,长度64字符之内(32个汉字),指针要指向ROM
void hz_disp(void); // 写汉字或字母
void img_disp (unsigned char flash *img); // 显示图片128*64
void img_disp2(unsigned char flash *img); // 显示图片64*64 左半屏
void img_disp3(unsigned char flash *img); // 显示图片64*64 右半屏
void LcdClearTXT(void); // 文本区RAM清零
void LcdClearBMP(void); // 图形区RAM清零
void lcdfill(unsigned char disdata); // 整屏全亮或显示竖条
void Disp_H_Line(void); // 显示横条
void frame(void); // 显示边框

flash unsigned char ex1[] = {"泰 山电 子"}; //字符串以结束
flash unsigned char ex2[] = {" 欢 迎 您 "};
flash unsigned char ex3[] = {"Tai Shan Dian Zi"};
flash unsigned char ex4[] = {"Wellcome to you!"};
flash unsigned char ex5[] = {"黄河远上白云间"};
flash unsigned char ex6[] = {"一片孤城万仞山"};
flash unsigned char ex7[] = {"羌笛何须怨杨柳"};
flash unsigned char ex8[] = {"春风不度玉门关"};
flash unsigned char ex9[] = {"TAI SHAN DIAN ZI"};
flash unsigned char ex10[] = {"Designer:Charlie"};

flash unsigned char tab[]={
/*-- 调入了一幅图像:联通图标 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,0XC0,0X01,0XFF,0XFC,0X00,
0X00,0X3F,0XFF,0XFC,0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F8,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
};

flash unsigned char tab2[]={
/*-- 调入了一幅图像:移动图标 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,0XFF,0XFF,0XFF,0XFF,0XFF,0XF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FF,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
};
flash 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,0XFF,0X80,0X1F,0XFF,0XE0,0X7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XC0,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
};

flash unsigned char tab4[]={
/*-- 调入了一幅图像:联通图标 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
};

void main(void)
{
delay_ms(200);
PORTB = 0xff;
DDRB = 0xff; // PB.7输出,作为运行标志
init_lcd(); // LCD初始化,并清屏
LcdClearTXT(); // 文本区RAM清零
LcdClearBMP(); // 图形区RAM清零
run = 0; // 运行标志亮
while(1)
{

hz_disp(); // 显示汉字或字母
LcdClearTXT(); // 文本区RAM清零

lcdfill(0xff); // 显示全亮
delay_ms(3000);

Disp_H_Line(); // 显示横条
delay_ms(3000);

lcdfill(0xaa); // 显示竖条
delay_ms(3000);

frame(); // 显示边框
delay_ms(3000);

img_disp(tab); // 显示联通图标128*64
delay_ms(3000);

img_disp(tab2); // 显示移动图标128*64
delay_ms(3000);

img_disp2(tab3); // 显示移动图标64*64
img_disp3(tab4); // 显示联通图标64*64
delay_ms(3000);

LcdClearBMP(); // 图形区RAM清零
}
}
/*------------------LCD初始化-----------------*/
void init_lcd(void)
{
PORTD = 0xff;
PORTC = 0xff;
DDRD = 0xff; // PD输出,控制线
DDRC = 0xff; // PC输出,数据线
rst = 0;
delay_us(50);
rst = 1;
delay_us(100);
psb = 1; // 并行
wr_comm(0x30); // 基本指令,8位数据模式
delay_us(3);
wr_comm(0x0C); // 显示开,游标关,反白关
delay_us(3);
wr_comm(0x01); // 清除显示,并且设定地址指针为00H
delay_us(3);
wr_comm(0x06); // 指定在资料的读取及写入时,设定游标的移动方向及指定显示的移位
}
/*--------------检测LCD忙闲---------------*/
void chk_busy(void)
{
LCD_Bus = 0xff;
rs = 0;
rw = 1;
delay_us(2);
e = 1;
DDRC &= ~(1< delay_us(2);
while((PINC&(1< e = 0;
DDRC |= 1< delay_us(2);
}
/*------------写命令到LCD--------------*/
void wr_comm(unsigned char comm)
{
chk_busy();
rs = 0;//H:写数据,L:写指令
rw = 0;
e = 0;
delay_us(2);
LCD_Bus = comm;//内容
delay_us(3);
e = 1;
delay_us(2);
e = 0;
}
/*------------写数据到LCD--------------*/
void wr_data(unsigned char dat)
{
chk_busy();
rs = 1;//H:写数据,L:写指令
rw = 0;
e = 0;
delay_us(2);
LCD_Bus = dat;//内容
delay_us(3);
e = 1;
delay_us(2);
e = 0;
}
/*-------向LCD写一个字符串,长度64字符之内---------- */
void wr_str(unsigned char flash *s)
{
while(*s>0)
{
wr_data(*s);
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 = 1;
delay_ms(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 = 0;
delay_ms(3000);
wr_comm(0x01); // 清除显示
/*-显示2行字母-*/
wr_comm(0x80);
wr_str(ex9);
wr_comm(0x88);
wr_str(ex10);
delay_ms(3000);
wr_comm(0x01); // 清除显示
}
/*-------------------------- 显示图片,128*64 --------------------------- */
void img_disp(unsigned char flash *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_data(img[j++]); // 高字节
wr_data(img[j++]); // 低字节
wr_comm(0x30); // 功能设置:8位控制界面,基本指令集,绘图显示关
}
}
}
}
/*------------------------ 显示图片,64*64 --------------------------- */
void img_disp2(unsigned char flash *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_data(img[j++]); // 高字节
wr_data(img[j++]); // 低字节
wr_comm(0x30); // 功能设置:8位控制界面,基本指令集,绘图显示关
}
}
}
}
/*----------------------- 显示图片,64*64 ----------------------------- */
void img_disp3(unsigned char flash *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_data(img[j++]); // 高字节
wr_data(img[j++]); // 低字节
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_data(disdata);
wr_data(disdata);
}
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_data(k);
wr_data(k);
}
}
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_data(0x80);
wr_data(0x00);

wr_comm(0x36);
wr_comm(y+0x80); // 行地址
wr_comm(x+0x87); // 列地址
wr_comm(0x30);
wr_data(0x00);
wr_data(0x01);
}
}
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_data(0xff);
wr_data(0xff);
}
}
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_data(0x20);
}
/*-----------------图形区清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_data(0);
}
}

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

9月2日消息,不造车的华为或将催生出更大的独角兽公司,随着阿维塔和赛力斯的入局,华为引望愈发显得引人瞩目。

关键字: 阿维塔 塞力斯 华为

加利福尼亚州圣克拉拉县2024年8月30日 /美通社/ -- 数字化转型技术解决方案公司Trianz今天宣布,该公司与Amazon Web Services (AWS)签订了...

关键字: AWS AN BSP 数字化

伦敦2024年8月29日 /美通社/ -- 英国汽车技术公司SODA.Auto推出其旗舰产品SODA V,这是全球首款涵盖汽车工程师从创意到认证的所有需求的工具,可用于创建软件定义汽车。 SODA V工具的开发耗时1.5...

关键字: 汽车 人工智能 智能驱动 BSP

北京2024年8月28日 /美通社/ -- 越来越多用户希望企业业务能7×24不间断运行,同时企业却面临越来越多业务中断的风险,如企业系统复杂性的增加,频繁的功能更新和发布等。如何确保业务连续性,提升韧性,成...

关键字: 亚马逊 解密 控制平面 BSP

8月30日消息,据媒体报道,腾讯和网易近期正在缩减他们对日本游戏市场的投资。

关键字: 腾讯 编码器 CPU

8月28日消息,今天上午,2024中国国际大数据产业博览会开幕式在贵阳举行,华为董事、质量流程IT总裁陶景文发表了演讲。

关键字: 华为 12nm EDA 半导体

8月28日消息,在2024中国国际大数据产业博览会上,华为常务董事、华为云CEO张平安发表演讲称,数字世界的话语权最终是由生态的繁荣决定的。

关键字: 华为 12nm 手机 卫星通信

要点: 有效应对环境变化,经营业绩稳中有升 落实提质增效举措,毛利润率延续升势 战略布局成效显著,战新业务引领增长 以科技创新为引领,提升企业核心竞争力 坚持高质量发展策略,塑强核心竞争优势...

关键字: 通信 BSP 电信运营商 数字经济

北京2024年8月27日 /美通社/ -- 8月21日,由中央广播电视总台与中国电影电视技术学会联合牵头组建的NVI技术创新联盟在BIRTV2024超高清全产业链发展研讨会上宣布正式成立。 活动现场 NVI技术创新联...

关键字: VI 传输协议 音频 BSP

北京2024年8月27日 /美通社/ -- 在8月23日举办的2024年长三角生态绿色一体化发展示范区联合招商会上,软通动力信息技术(集团)股份有限公司(以下简称"软通动力")与长三角投资(上海)有限...

关键字: BSP 信息技术
关闭
关闭