12864是128*64点阵液晶模块的点阵数简称,业界约定俗成的简称。主要控制芯片一般为ST7920或与之兼容的IC。
大家在网上搜索12864时,总会发现带不带字库,它们的分别:带字库版不需要用点阵生成器把汉字变成点阵后再输入,直接输入汉字内码即可显示出对应汉字,无字库版想要显示汉字,只能自己按照点阵方式驱动。
提供 8 位,4 位并行接口及串行接口可选
并行接口适配 M6800 时序 自动电源启动复位功能
内部自建振荡源
64×16 位字符显示 RAM(DDRAM 最多 16 字符×4 行,LCD 显示范围 16×2 行)
2M 位中文字型 ROM(CGROM),总共提供 8192 个中文字型(16×16 点阵)
16K 位半宽字型 ROM(HCGROM),总共提供 126 个西文字型(16×8 点阵)
64×16 位字符产生 RAM(CGRAM)
引脚功能图:[attach]496[/attach]
[attach]499[/attach]
/*
Arduino驱动LCD12864显示
BY YFRobot
*/
#include "LCD12864RSPI.h"
#define AR_SIZE( a ) sizeof( a ) / sizeof( a[0] )
unsigned char show0[]="YFROBOT"; //YFROBOT
unsigned char show1[]= { 0xB9, 0xA4, 0xD7, 0xF7, 0xCA, 0xD2 }; //工作室
unsigned char show2[]="Touch You Future"; //Touch You Future
unsigned char logo[] = // 扬帆Logo
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
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,0x00,0x00,0x00,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
0x8C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,
0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,
0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,
0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,
0x07,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,
0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,
0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xE0,
0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xE0,
0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,
0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xC0,
0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,
0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x80,
0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,
0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,
0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,
0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,
0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,
0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,
0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,
0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,
0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x01,
0xC0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x01,
0xC1,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x01,
0xC7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x01,
0xBC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x04,
0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x1C,
0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x7C,
0x14,0xCE,0xEE,0x6F,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,
0x15,0x4A,0xA8,0xA5,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x0F,
0x09,0x4A,0xEE,0xA5,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x0C,
0x08,0xEA,0x28,0x75,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,
0x08,0x00,0xE8,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x20,
0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,
0x0F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,
0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,
0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,
0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xF8,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
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 setup(){
LCDA.Initialise(); // 屏幕初始化
delay(100);
}
void LOGO(){
LCDA.CLEAR();//清屏
delay(100);
LCDA.DrawFullScreen(logo); //全屏显示logo
}
void NAME(){
LCDA.CLEAR();//清屏
delay(100);
LCDA.DisplayString(0,0,show0,AR_SIZE(show0));//第一行第一格开始,显示"YFROBOT"
delay(100);
LCDA.DisplayString(0,4,show1,AR_SIZE(show1));//第一行第五个字开始,显示文字"工作室"
delay(100);
LCDA.DisplayString(2,0,show2,AR_SIZE(show2));//第三行第一格开始,显示"Touch You Future"
}
void loop(){
LOGO();
delay(3000);
NAME();
delay(3000);
}
首先英文字母不需要麻烦,直接输出就可以;然后介绍下如何获取汉字内码,我们打开汉字内码获取工具(由ardyPro所写,很好用;本帖也有下载链接),然后输入想要显示的汉字,例如:“工作室”;点击转换,转换结果就会出现内码了,如下图,其中“0xB9, 0xA4,”就是“共”字的内码,将其复制到程序中就可以使用了~~
汉字一个字占两个字符,相当于两个英文字母的大小,所以我们程序中LCDA.DisplayString(0,4,show1,AR_SIZE(show1));//第一行第五个字开始,显示文字"工作室" 的语句是从第五个字开始显示,因为“YFROBOT”占用了7个字符,就相当于占用了4个汉字的位置!
下面我来介绍下图片是如何获取的,你需要个图片取模工具(本帖最后有下载链接),打开它,然后找到你想要显示的图片,这里我就以上面程序中的图片为例了!
图片如下:
然后我们将我们的图片经过一些处理:将其尺寸改小,能拖到128*64的空白图片中就可以,我们原图的尺寸为1181*1181,所以我将其改为64*64,这样肯定可以拖到128*64图片中,用户在使用其他尺寸图片时原理一样的,如果你想要显示的大点,那你就让图片的边缘接近128*64的大小就可以了!我们看下我们改好的图片(下图中已经将原图改小并且已经将其拖入128*64空白图片中,图中能看到的就是128*64图片的现状):
[attach]509[/attach]第一步:去色(如果原图是黑白的更好就不需要这个步骤了)
第二步:调节对比度(为了更清楚的显示)
第三步:调节图片模式(从原来的RGB颜色改为位图,其中可能不能直接改为位图,要先改为灰度);下图为从灰度状态改为位图时弹出的对话框,选择“50% 阈值”,这个出来的效果相对比较好。
[attach]510[/attach]原图尺寸(左):1181*1181
效果图尺寸(右):128*64 记得将效果图保存,格式为BMP
[attach]511[/attach]下面我们打开图片取模工具,设置“C语言”、“输出大小:X为128,Y为64”,然后点击“载入图片”,载入我们已经处理好的图片,如下图(关键参数已经用红框标出,如果图片黑白相反,可以勾选输出大小下方的“黑白取反”,然后再次载入图片):
[attach]512[/attach]如果对载入的图片不满意,还可以自己进行修改,鼠标左键为加黑点,右键为去黑点!!
在确定好图片之后,点击“数据保存”保存为“.h”格式。然后打开你保存的“XXXX.h”文件,文件中的数组(类似下图)就是我们想要的东西了,将它复制到程序中,就可以显示刚才处理的图片了!!!!
[attach]513[/attach][attach]497[/attach]
汉字内码获取工具:[attach]498[/attach]
扩展阅读:[attach]495[/attach]
[attach]500[/attach]
[attach]504[/attach]
楼主自己弄着玩的图片,还不错:13不带刀 发表于 2015-7-30 01:57
你的程序我一编译就提示错误,也没提示什么地方错
13不带刀 发表于 2015-7-30 13:40
对了,楼主,我用的板式MINI,这会不会有影响
13不带刀 发表于 2015-7-30 21:13
谢谢楼主,程序编译成功了,但是什么都没显示-.-!,能在麻烦哈您不?我的用的事MINI,所以很看不清楚怎么连 ...
摆渡堂主 发表于 2015-8-21 09:59
请问,arduino可以驱动240128液晶吗?咋整?
kzch 发表于 2015-12-18 16:10
楼主,问你一下,你的程序里那个工作室没有类似取模软件取的代码,而是LCDA.DisplayString(0,0,show0,AR_SI ...
AllBlue 发表于 2015-7-30 14:19
你用的版本现在不支持wiring.h了,本帖用的IDE是1.0.X版。
库文件需要更新了!将LCD12864RSPI.cpp中的#i ...
dongbryant 发表于 2016-4-20 19:20
已经有了库文件了啊,这是怎么回事呢
chnwjian 发表于 2016-4-25 14:02
试了下楼主的程序,显示文字的那一页可以正常显示,但显示图片的时候屏幕就如上图那样,不清楚是怎么回事 ...
AllBlue 发表于 2016-4-26 08:22
图片是你自己编辑的还是程序中的?按理说,能显示文字,就能显示图片的
道源和尚 发表于 2016-8-24 23:25
问楼主一个问题,如何再离开电脑的情况下仍然显示?
我用电池供电时,屏幕只是闪闪发光。。。没有显示写入 ...
道源和尚 发表于 2016-8-25 13:23
下载好了,连接电脑的话,屏幕正常显示,但是用电池的话,就显示不了了。。。
这很尴尬。。。
道源和尚 发表于 2016-8-25 14:02
这个样子的
道源和尚 发表于 2016-8-25 14:11
屏幕亮的,但是不显示文字和图片,电池电压是9V
道源和尚 发表于 2016-8-25 15:10
楼主再问你一个问题,如何才能让显示屏停驻在最后一个画面,而不是不断地循环?
bool flag = false;
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
if(flag){
flag = true;
}else
//只循环这个
}
丶破晓灬 发表于 2016-9-26 16:17
有没有新的库?用于并行的编译显示 wiring 有错 不知道怎么改啊
fjiangqing 发表于 2016-10-22 20:51
奇怪我下了好几个都有错误
d:\Arduino_Hex\SPI1.cpp.o: In function `setup':
C:\Program Files (x86)\Ar ...
AllBlue 发表于 2016-9-30 13:45
将库文件中.cpp的代码
#include
tiantianyouyou 发表于 2019-5-2 08:07
我一编译就提示错误
Arduino31731 发表于 2019-7-10 10:54
不是UNO?
出现这个情况:exit status 1
为开发板 Arduino/Genuino Uno 编译时出错。
欢迎光临 YFROBOT创客社区 (http://82.157.198.105/) | Powered by Discuz! X3.1 |