查看: 18872|回复: 12

Mini12864

[复制链接]

该用户从未签到

发表于 2013-2-4 22:44 | 显示全部楼层 |阅读模式
本帖最后由 Kiwi 于 2013-2-4 22:56 编辑

感谢奈何海参送的12864,{:soso_e142:}东西隔了一天就到了,比想象中要小~下面简单给大家介绍一下~

1.原理:首先是液晶屏显字的原理,简单的来说,液晶屏的每个点都有对应的一个寄存器空间,就像一个个小格子,只要这个格子里面存了1,屏幕上对应的点就是黑的,存的是0,这个点就是空白的,所以想要点亮LCD,我们要做的就是在对应的寄存器空间里写进1.

2.接口定义mini12864只支持串行输入(一位一位把数据发出),如下:
101201xaxchg2925nd2crc.jpg
CS  片选 低有效
R    给芯片复位,低有效     
A    数据和命令选择,L 命令 H  数据
C   时钟
D   数据
-    GND
+   5V
L    背光,低有效   

3.通信命令:mini12864采用串行数据通讯,这种通讯方式速度相比并行稍差,但是相对节约IO口,单片机通过发送一组数据
来完成对12864的控制,数据格式如下

RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
RS:寄存器选择,低为命令寄存器,高为数据寄存器
R/W:表示对芯片进行读操作还是写操作,串行模式下无需关心
D7-D0:8个数据位,并行模式下为同时放好8根线上的数据后一起发出,串行模式下为逐个发送,高位先发
命令表格:

17E23F73-19EA-47FA-9972-1FB213355C98.png
4B88CCC3-F10F-48C2-8BE4-B985D5E859C1.png
EC43BB95-A520-45A6-BDE4-831C19D5000F.png
0EBBC9B2-E97E-4E75-AFD7-FDA182EA3901.png

4.通讯方式:说到通讯方式就需要降到时序图,12864串行模式下的时序还是比较简单的,如下:
85663C1D-DC9F-4B1F-A53D-0C27E19E2DFB.png
简单介绍一下,希望对没有接触过时序图的同学有帮助
2次竖着的虚线之间是一次完整的通讯,首先虚线的最开头就是CS变低,这个表示通讯一开始,片选就要拉低,MCU告诉液晶我选中你了,要开始和你通讯了,在通信结束前,片选一直是底的,此时第二条SDI数据线表示可高可低,没有关系接下去看到SCK时钟线,再往右推,时钟线第一次被拉低,此时数据线需要放上数据的最高位了,在数据被摆好后,时钟线被拉高,数据的最高位D7就被发送出去了,也就是说时钟被拉低放好要发的数据,然后再拉高,数据就出去了,如此反复到底8次 D0,当D0放好被拉高的同时,12864会检查CD寄存器选择线,以确定这8个数据是发送给自己的执行命令还是要显示的数据,一般我们会在片选拉低选中芯片之后就把CD线的状态放好,这样一次通信就完成了,结束之后不要忘记把片选再拉高,释放对LCD的控制.

5.地址:接下去就是液晶屏的寄存器中,究竟哪个地址代表屏幕上的哪个点,由于之前ZX_1923大大的帖子中已经很强大的阐述了如何作图,和对点的操作,我这里大致讲一下平时用的工作在显字的模式下的使用,显示屏被分为了8个大页(其实就是行 -.-)从上到下为P0-P7,横向对应127个列,L0-L126,发送地址的时候,页地址是直接16进制数发送的,而列地址是被拆成2个16进制数,高4位与底4位分开发送,具体地址可以见数据手册或者我的函数.

6.函数:因为要讲给入门的同学听,所以我并没有用库,而是自己写了底层驱动(但是后来发觉和库里面基本一样 =.=),有部分懒得写了,借鉴了库,但是我自己写了2个直接可以拿来显示数字和字符串的函数,对于需要拿屏幕来做温度等模块返回值的同学有点用,基本思路是这样的,网上找了一个按照ASC可见字符的顺序排列的取模数组,就更具需要显示的字符的ASC码转换成数组的序号,但是有坑爹的...因为网上找的数组的取模方向问题...现出来的字是横着的...屏幕要竖着使用...各位童鞋高兴的话可以自己去取模...
注解已经写的很清楚了,希望对新手有帮助!老鸟无视
D86F675A-88BB-45D6-8B35-D7DF0D5F8B51.png

[mw_shl_code=c,true]/* 不带字库UC1701X 普通IO口驱动*/
const unsigned char ASCII8_16[]=      //可见ASC码 取模表
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18,0x18, 0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x6C,0x6C,0xFE,0x6C,0x6C, 0x6C,0xFE,0x6C,0x6C,0x00,0x00,0x00,0x00,
0x18,0x18,0x7C,0xC6,0xC2,0xC0,0x7C,0x06, 0x86,0xC6,0x7C,0x18,0x18,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xC2,0xC6,0x0C,0x18, 0x30,0x60,0xC6,0x86,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x6C,0x6C,0x38,0x76,0xDC, 0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,
0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0C,0x18,0x30,0x30,0x30,0x30, 0x30,0x30,0x18,0x0C,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0x18,0x0C,0x0C,0x0C,0x0C, 0x0C,0x0C,0x18,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x66,0x3C,0xFF, 0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E, 0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x18,0x18,0x18,0x30,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x06,0x0C,0x18, 0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0xCE,0xD6,0xD6, 0xE6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18, 0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0x06,0x0C,0x18,0x30, 0x60,0xC0,0xC6,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0x06,0x06,0x3C,0x06, 0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x0C,0x1C,0x3C,0x6C,0xCC,0xFE, 0x0C,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00,
0x00,0x00,0xFE,0xC0,0xC0,0xC0,0xFC,0x0E, 0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x60,0xC0,0xC0,0xFC,0xC6, 0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0xFE,0xC6,0x06,0x06,0x0C,0x18, 0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7C,0xC6, 0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7E,0x06, 0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00, 0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00, 0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x60, 0x30,0x18,0x0C,0x06,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00, 0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x60,0x30,0x18,0x0C,0x06, 0x0C,0x18,0x30,0x60,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0x0C,0x18,0x18, 0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7C,0xC6,0xC6,0xDE,0xDE, 0xDE,0xDC,0xC0,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xFE, 0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x66, 0x66,0x66,0x66,0xFC,0x00,0x00,0x00,0x00,
0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xC0, 0xC0,0xC2,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0xF8,0x6C,0x66,0x66,0x66,0x66, 0x66,0x66,0x6C,0xF8,0x00,0x00,0x00,0x00,
0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68, 0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68, 0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xDE, 0xC6,0xC6,0x66,0x3A,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xFE,0xC6, 0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0x3C,0x18,0x18,0x18,0x18,0x18, 0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x1E,0x0C,0x0C,0x0C,0x0C,0x0C, 0xCC,0xCC,0xCC,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0xE6,0x66,0x6C,0x6C,0x78,0x78, 0x6C,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x60,0x60,0x60,0x60,0x60, 0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xEE,0xFE,0xFE,0xD6,0xC6, 0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xE6,0xF6,0xFE,0xDE,0xCE, 0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x6C,0xC6,0xC6,0xC6,0xC6, 0xC6,0xC6,0x6C,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x60, 0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6, 0xC6,0xD6,0xDE,0x7C,0x0C,0x0E,0x00,0x00,
0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x6C, 0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0x60,0x38,0x0C, 0x06,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x7E,0x7E,0x5A,0x18,0x18,0x18, 0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6, 0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6, 0xC6,0x6C,0x38,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xD6, 0xD6,0xFE,0x6C,0x6C,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xC6,0x6C,0x6C,0x38,0x38, 0x6C,0x6C,0xC6,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0x66,0x66,0x66,0x66,0x3C,0x18, 0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0xFE,0xC6,0x86,0x0C,0x18,0x30, 0x60,0xC2,0xC6,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x3C,0x30,0x30,0x30,0x30,0x30, 0x30,0x30,0x30,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0xC0,0xE0,0x70,0x38, 0x1C,0x0E,0x06,0x02,0x00,0x00,0x00,0x00,
0x00,0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C, 0x0C,0x0C,0x0C,0x3C,0x00,0x00,0x00,0x00,
0x10,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,
0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0xE0,0x60,0x60,0x78,0x6C,0x66, 0x66,0x66,0x66,0xDC,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC0, 0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x1C,0x0C,0x0C,0x3C,0x6C,0xCC, 0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xFE, 0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x6C,0x64,0x60,0xF0,0x60, 0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC, 0xCC,0xCC,0xCC,0x7C,0x0C,0xCC,0x78,0x00,
0x00,0x00,0xE0,0x60,0x60,0x6C,0x76,0x66, 0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18, 0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x06,0x06,0x00,0x0E,0x06,0x06, 0x06,0x06,0x06,0x06,0x66,0x66,0x3C,0x00,
0x00,0x00,0xE0,0x60,0x60,0x66,0x6C,0x78, 0x78,0x6C,0x66,0xE6,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18, 0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xEC,0xFE,0xD6, 0xD6,0xD6,0xD6,0xD6,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66, 0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6, 0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66, 0x66,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00,
0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC, 0xCC,0xCC,0xCC,0x7C,0x0C,0x0C,0x1E,0x00,
0x00,0x00,0x00,0x00,0x00,0xDC,0x76,0x62, 0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0x60, 0x38,0x0C,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x10,0x30,0x30,0xFC,0x30,0x30, 0x30,0x30,0x36,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xCC,0xCC,0xCC, 0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66, 0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6, 0xD6,0xD6,0xFE,0x6C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC6,0x6C,0x38, 0x38,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6, 0xC6,0xC6,0xC6,0x7E,0x06,0x0C,0xF8,0x00,
0x00,0x00,0x00,0x00,0x00,0xFE,0xCC,0x18, 0x30,0x60,0xC6,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x0E,0x18,0x18,0x18,0x70,0x18, 0x18,0x18,0x18,0x0E,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x18, 0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x70,0x18,0x18,0x18,0x0E,0x18, 0x18,0x18,0x18,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x76,0xDC,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xC6,0xFE,0x00,0x00,0x00,0x00,0x00, };

#define cs_mini12864 12   //片选 低电平片选
#define rst_mini12864 11 //物理重置.低电平有效
#define rs_mini12864 10   //寄存器选择 1:数据寄存器 0:指令寄存器
#define sck_mini12864 9 //时钟
#define sda_mini12864 8 //数据
//上面的脚可以自己修改
#define  Display  0xAF     //显示开启
#define  Power    0x2F           //电源全开
#define  VO       0x24     //对比度调节            
#define  AllPoint 0xA4           //非全屏显示
#define  ADCset   0xA1            //负向,131-4
#define  COMset   0xc0            //com0-com63
#define  ELECTVO  0x81     //亮度调节         调节颜色         不同的模块需要不同的  ELECTSET
#define  ELECTSET 0x2a           //亮度数值         调节颜色         不同的模块需要不同的        数值
#define  BIASSET  0xA2    //占空比1/9


void send_8bit_mini12864(unsigned char d)  //传8位数据,高位先传
{
        for(int i=0;i<8;i++)                    //循环8次,每次发送1个最高位
        {
                digitalWrite(sck_mini12864,0);       //时钟拉低,一位数据开始
                if(d&0x80)                          //与上10000000,最高位如果是1,就数据位就高
                        digitalWrite(sda_mini12864,1);
                else                                //与上10000000,最高位如果是0,就数据位就低
                        digitalWrite(sda_mini12864,0);
                digitalWrite(sck_mini12864,1);       //一位数据发送完毕,时钟拉高
                d<<=1;                              // d|ddddddd0    抛掉最高位,其余数据左移一位,最低位填0
        }
}

void write_cmd_mini12864(unsigned char cmd)  //写命令
{
        digitalWrite(cs_mini12864,0); //片选拉低,选中芯片
        digitalWrite(rs_mini12864,0); //rs为低,写入命令
        send_8bit_mini12864(cmd);     //写入8位命令
}

void write_dat_mini12864(unsigned char dat)  //写数据
{
        digitalWrite(cs_mini12864,0); //片选拉低,选中芯片
        digitalWrite(rs_mini12864,1); //rs为高,写入数据
        send_8bit_mini12864(dat);          //写入8位数据
}

void mini12864_cl()         //清屏,其实就是把所有的地址全部填成0
{         
  unsigned char x,y;
  for(y=0;y<8;y++)
  {   
    write_cmd_mini12864(0xb0+y);
    write_cmd_mini12864(0x10);               
    write_cmd_mini12864(0x00);
    for(x=0;x<132;x++)  write_dat_mini12864(0);
  }        
}

void mini12864_Init()   //初始化
{

  pinMode(cs_mini12864,OUTPUT);   //设置各个I/O为输出
  pinMode(rst_mini12864,OUTPUT);  
  pinMode(rs_mini12864,OUTPUT);
  pinMode(sck_mini12864,OUTPUT);
  pinMode(sda_mini12864,OUTPUT);  
  
  digitalWrite(cs_mini12864,LOW);  
  digitalWrite(rst_mini12864,LOW);          //物理重置
  delay(200);
  digitalWrite(rst_mini12864,HIGH);
  delay(1000);        
  write_cmd_mini12864(0xe2);                //软件重置
  delay(200);

//以下为初始设置,具体请参考数据手册

  write_cmd_mini12864(0x24);//对比度
  write_cmd_mini12864(0xa2);//BR=1/9
  write_cmd_mini12864(0xa0);//set seg direction
  write_cmd_mini12864(0xc8);//set com direction
  write_cmd_mini12864(0x2f);//set power control
  write_cmd_mini12864(0x40);//set scroll line
  write_cmd_mini12864(0x81);//SET ELECTRONIC VOLUME
  write_cmd_mini12864(0x20);//set pm: 通过改变这里的数值来改变电压
  //write_cmd(0xa6);//set inverse display           a6 off, a7 on
  //write_cmd(0xa4);//set all pixel on
  write_cmd_mini12864(0xaf);//开显示

  mini12864_cl();  //清屏
}

void write_add(unsigned char p, unsigned char l)  //页列转换
{
  write_cmd_mini12864(0xb0+p);                         //先给页数据 0-7,从上到下,页码是直接读取8位数据作为地址   
  write_cmd_mini12864(0x10+(8*l/16));        //再是列 0-127,从左到右,列是先读取高四位,后读取低四位
  write_cmd_mini12864(0x00+(8*l%16));   //低四位
}


void show_string(unsigned char p, unsigned char l,char  *string)   //在第p页的l列
{                                                                                                                                        //显示一个字符串(数组中的元素)
    unsigned int X,i=0;
   write_add(p,l);                     //页列转换函数
   while(string[i++])               //判断是否为空
   {
    X=(string[i-1]-32)*16;           //将string中的元素(ASC码)匹配到预先写好的ASC数组之中
    for(int j=0;j<16;j++) write_dat_mini12864(ASCII8_16[X++]);         //发显示数据
   }
}

void show_number(unsigned char p, unsigned char l,unsigned int d)   //在第p页的l列
{                                                                                                                                        //显示一个字数字
  char s[8];   
  unsigned char m;
  m=0;
  do      //将d分离到数组s中
  {
    s[m]=d%10;
    m++;
    d=d/10;   
  }while(d);//此时m就是d的位数  
   
   unsigned int X,i=0;
   write_add(p,l);                     //页列转换函数
   for(int z=m;z>0;z--)               //循环m次,没就是数字的位数
   {
    X=(s[z-1]+48-32)*16;           //由于此时数组中的并非ASC码,而是真真的数字,所以转换时候系数不同
    for(int j=0;j<16;j++) write_dat_mini12864(ASCII8_16[X++]);         //发显示数据
   }
}


void setup()
{
        mini12864_Init();   //初始化液晶
}

void loop()
{  
   
   show_string(0,0,"HELLO!");
   show_string(1,0,"Arduino");
   show_number(2,0,12345);
   
   show_string(6,0,"I'm Kiwi");
        
}
[/mw_shl_code]

该用户从未签到

发表于 2013-2-5 00:08 | 显示全部楼层
虽不明,但觉厉

该用户从未签到

 楼主| 发表于 2013-2-5 10:06 | 显示全部楼层
奈何col 发表于 2013-2-5 00:08
虽不明,但觉厉

厉你妹.......

该用户从未签到

发表于 2013-2-5 10:23 | 显示全部楼层
标记学习一个

该用户从未签到

发表于 2013-2-17 09:56 | 显示全部楼层
虽不明,但觉厉。。。

该用户从未签到

发表于 2014-4-18 18:00 | 显示全部楼层
虽不明,但觉厉。。。

该用户从未签到

发表于 2014-11-5 01:50 | 显示全部楼层
非常感谢,还使用图示,不错学习了。

该用户从未签到

发表于 2015-5-27 00:46 | 显示全部楼层
请教个用MINI12864显示动画的方法

该用户从未签到

发表于 2015-5-28 16:12 | 显示全部楼层
能不能给我发个关于mini12864文本资料,1732729719@qq.com    谢谢!

该用户从未签到

发表于 2015-5-28 16:21 | 显示全部楼层
大神,发个文本的!谢谢1732729719@qq.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热门推荐

为开发板 NodeMCU 1.0 (ESP-12E Module) 编译时出错??
为开发板 NodeMCU 1.0 (ES
'analgoWrite' 未在此范围内声明 ??? 什么情况?求大神解答!...
'analgoWrite' 未
analogWrite不是不用定义,直接写入就行了吗?如图:
nodemcuesp8266上传点灯程序失败
nodemcuesp8266上传点灯程
程序能编译成功,但是一上传到12%就停止了,然后就出现错误 esptool.FatalError: Time
【Arduino】168种传感器系列实验(217)---2.9寸汉朔三色墨水屏
【Arduino】168种传感器系
37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是
【Arduino】168种传感器系列实验(171)---HLK-V20离线语音模块
【Arduino】168种传感器系
37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是
Copyright   ©2015-2016  Arduino中文社区  Powered by©Discuz!   
快速回复 返回顶部 返回列表