在netduino.com的论坛里看到很多人提出lcd的显示问题,因为没测试过,所以不知道情况如何,一直想试试。这几天因为我们需要将我们做的即插即用的网络技术展现出来,如果显示不了不就失去了很多特点了吗?加上手头上有成都智能盒子做的lcd12864的lcd,选择他们的lcd的原因很简单,好看,好用这就够了。以下是在成都智能盒子的淘宝上看到的lcd12864的简介:
Openjumpr 12864 LCD模块
mini12864 LCD模块是一款基于12864液晶显示器开发的显示模块。这款模块SPI为接口的显示模块,配合12864LCD库文件,便可轻松显示汉字,字符和图形。并有背光LED控制,可使显示效果更美观。
二、模块参数:
外形尺寸 (长×宽×高):47mm×38mm×6mm(不含插针)
LCD视域(长×宽):33.7mm×33.5mm
LCD有效显示区域(长×宽):30.7mm×23mm
背光模式:白色LED支架背光
工作电压:3.3V ~ 5.5V(内置升压电路,无需高压)
控制IC :UC1701
点阵格式:128列×64行
显示效果:白底蓝字
三、模块特点:
1、结构轻、薄、带背光
2、IC采用UC1701,功能强大,稳定性好
3、功耗低:
LCD工作电流:0.2mA(背光LED关闭状态)
背光LED工作电流:≤4.5mA
总功耗:≤23.5mW(5V)、≤15.5mW(3.3V)
4、显示内容:
可显示128列×64行点阵单色图片
可显示16×16点阵和12×12点阵汉字及图片
可显示8字/行×4行(16×16点阵汉字)
可显示16字/行×8行(8×8点阵的英文、数字、符号)
5、接口简单方便:采用3线SPI串行接口以及一条命令/数据控制线,最多只需5个端口(3线SPI接口加命令/数据控制线,再加上复位信号线)
6、模块上分别设计有上下位置引脚引出,上部已焊接有2.54mm间距插针,下部预留有焊盘,方便进行模块化连接。
四、引脚定义:
标示符号 | 名 称 | 功 能 | |
R | RESET | 低电平复位,复位完成后,回到高电平,液晶模块开始工作。如果不需软件给芯片复位,可不连接 | |
A | A0 | 数据和命令选择。L:命令 H:数据 | |
CS | CS | SPI | 片选(内部已拉高),低有效 |
C | SCK | 串行时钟 | |
D | MOSI(SID) | 数据传输 | |
- | GND | 电源地 | |
+ | VCC | DC 3.3V~5.5V | |
L | LED | 背光LED使能,低有效 |
(注明:该模块有手册;需要进一步了解的可联系客服接收PDF文档)
更多资料请参见OpenJumper资料库:http://x.openjumper.com/
在openjumper的资料库里我并没有找到netduino版本的驱动,咋办??当然是自己写咯,先偷懒,让俺的学生去写,俺的学生经过一番查看,告诉我,不好写,不得不逼我这个老家伙动手,好吧,我写。经过半天的努力,俺写好了,并交付给学生调试,再做了一下修改,俺改好了,现在先附上驱动代码:
using System; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware.Netduino; public class Lcd12864 { Microsoft.SPOT.Hardware.OutputPort LAO; Microsoft.SPOT.Hardware.OutputPort LCS; Microsoft.SPOT.Hardware.OutputPort LSCK; Microsoft.SPOT.Hardware.OutputPort LSID; Microsoft.SPOT.Hardware.OutputPort LRST; Microsoft.SPOT.Hardware.SPI spi; public Lcd12864() { LAO = new Microsoft.SPOT.Hardware.OutputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D10, false); LCS = new Microsoft.SPOT.Hardware.OutputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D8, false); LSCK = new Microsoft.SPOT.Hardware.OutputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D13, false); LSID = new Microsoft.SPOT.Hardware.OutputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D11, false); LRST = new Microsoft.SPOT.Hardware.OutputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D9, false); LCS.Write(false); LRST.Write(false); System.Threading.Thread.Sleep(200); LRST.Write(true); System.Threading.Thread.Sleep(1000); write_cmd(Convert.ToChar(0xe2));//system reset System.Threading.Thread.Sleep(200); write_cmd(Convert.ToChar(0x24));//SET VLCD RESISTOR RATIO write_cmd(Convert.ToChar(0xa2));//BR=1/9 write_cmd(Convert.ToChar(0xa0));//set seg direction write_cmd(Convert.ToChar(0xc8));//set com direction write_cmd(Convert.ToChar(0x2f));//set power control write_cmd(Convert.ToChar(0x40));//set scroll line write_cmd(Convert.ToChar(0x81));//SET ELECTRONIC VOLUME write_cmd(Convert.ToChar(0x20));//set pm: 通过改变这里的数值来改变电压 //write_cmd(0xa6);//set inverse display a6 off, a7 on //write_cmd(0xa4);//set all pixel on write_cmd(Convert.ToChar(0xaf));//set display enable LcmClear(); } public void SendByte(byte Dbyte) { byte a,TEMP; TEMP = Dbyte; for(int i=0;i<8;i++) { LSCK.Write(false); //digitalWrite(LSCK,LOW); TEMP = (byte)((Int32)(Dbyte << i) & 0X80); LSID.Write((TEMP=='\0'?false:true)); LSCK.Write(true); //digitalWrite(LSID,TEMP); //digitalWrite(LSCK,HIGH); } } public void write_cmd(char Cbyte) { LCS.Write(false); LAO.Write(false); SendByte((byte)Cbyte); } /*************** * 写数据 ******************/ public void write_data(byte Dbyte) { LCS.Write(false); LAO.Write(true); SendByte(Dbyte); } void LcmClear() { short x, y; for (y = 0; y < 8; y++) write_cmd(Convert.ToChar((ushort)(0xb0 + y))); write_cmd(Convert.ToChar(0x10)); write_cmd(Convert.ToChar(0x00)); for (x = 0; x < 132; x++) write_data(0x0); } /************************* * 8*8字符,取模顺序是列行式, * 从上到下,高位在前,从左到右; * 先选择页地址0-7,再选择列0-130 * 页码是直接读取8位数据作为地址; * 列是先读取高四位,后读取低四位; **********************/ void PUTchar8x8(char row, char col, char count, byte[] put) { int X = 0; int i = 0, j = 0; write_cmd((char)(0xb0 + row)); write_cmd((char)(0x10 + (8 * col / 16))); write_cmd((char)(0x00 + (8 * col % 16))); for (j = 0; j < count; j++) for (i = 0; i < 8; i++) write_data(put[X++]); } /***************** * 8*16字符,取模顺序是列行式, * 从上到下,高位在前,从左到右; * 先选择页地址0-7,再选择列0-127 * 页码是直接读取8位数据作为地址; * 列是先读取高四位,后读取低四位; **********************/ void PUTchar8x16(char row, char col, char count, byte[] put) { int X = 0; int i = 0, j = 0; write_cmd((char)(0xb0 + row)); write_cmd((char)(0x10 + (8 * col / 16))); write_cmd((char)(0x00 + (8 * col % 16))); for (j = 0; j < count; j++) { for (i = 0; i < 8; i++) write_data(put[X++]); write_cmd((char)(0xb1 + row)); write_cmd((char)(0x10 + (8 * col / 16))); write_cmd((char)(0x00 + (8 * col % 16))); for (i = 0; i < 8; i++) write_data(put[X++]); write_cmd((char)(0xb0 + row)); col = (char)(col + 1); } } /***************** * 16*16字符,取模顺序是列行式, * 从上到下,高位在前,从左到右; * 先选择页地址0-7,再选择列0-127 * 页码是直接读取8位数据作为地址; * 列是先读取高四位,后读取低四位; **********************/ void PUTchar16x16(char row, char col, char count, byte[] put) { int X = 0; int i = 0, j = 0; write_cmd((char)(0xb0 + row)); write_cmd((char)(0x10 + (8 * col / 16))); write_cmd((char)(0x00 + (8 * col % 16))); for (j = 0; j < count; j++) { for (i = 0; i < 16; i++) write_data(put[X++]); write_cmd((char)(0xb1 + row)); write_cmd((char)(0x10 + (8 * col / 16))); write_cmd((char)(0x00 + (8 * col % 16))); for (i = 0; i < 16; i++) write_data(put[X++]); write_cmd((char)(0xb0 + row)); col = (char)(col + 2); } } /***************** * 24*24字符,取模顺序是列行式, * 从上到下,高位在前,从左到右; * 先选择页地址0-7,再选择列0-127 * 页码是直接读取8位数据作为地址; * 列是先读取高四位,后读取低四位; **********************/ public void PUTchar24x24(char row, char col, char count, byte[] put) { int X = 0; int i = 0, j = 0; write_cmd((char)(0xb0 + row)); write_cmd((char)(0x10 + (8 * col / 16))); write_cmd((char)(0x00 + (8 * col % 16))); for (j = 0; j < count; j++) { for (i = 0; i < 24; i++) write_data(put[X++]); write_cmd((char)(0xb1 + row)); write_cmd((char)(0x10 + (8 * col / 16))); write_cmd((char)(0x00 + (8 * col % 16))); for (i = 0; i < 24; i++) write_data(put[X++]); write_cmd((char)(0xb2 + row)); write_cmd((char)(0x10 + (8 * col / 16))); write_cmd((char)(0x00 + (8 * col % 16))); for (i = 0; i < 24; i++) write_data(put[X++]); write_cmd((char)(0xb0 + row)); col = (char)(col + 3); } } /***************** * 图片;取模顺序是列行式, * 从上到下,低在前,从左到右; * 先选择页地址0-7,再选择列0-127 * 页码是直接读取8位数据作为地址; * 列是先读取高四位,后读取低四位; **********************/ public void PUTBMP(byte[] put) { int X = 0; int i = 0, j = 0; for (j = 0; j < 8; j++) { write_cmd((char)(0xb0 + j)); write_cmd((char)(0x10)); write_cmd((char)(0x00)); for (i = 0; i < 128; i++) write_data(put[X++]); } } /***************** * 图片反显;取模顺序是列行式, * 从上到下,位在前,从左到右; * 先选择页地址0-7,再选择列0-127 * 页码是直接读取8位数据作为地址; * 列是先读取高四位,后读取低四位; **********************/ public void PUTREVERSEBMP(byte[] put) { int X = 0; int i = 0, j = 0; for (j = 0; j < 8; j++) { write_cmd((char)(0xb0 + j)); write_cmd((char)(0x10)); write_cmd((char)(0x00)); for (i = 0; i < 128; i++) write_data(put[X++]); } } }
以上是openjumper版本的lcd12864的驱动,有兴趣的话可以自行进行扩展,下面附上的是调用的例子
public class Program { static byte[] bmp001= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0xE0,0x00,0xE0,0x00,0xE0,0x20,0x00,0x20,0xE0, 0x00,0xE0,0x00,0xE0,0x20,0x00,0x20,0xE0,0x00,0xE0,0x00,0xE0,0x20,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x20,0xA0,0xA0,0xC0,0x00,0x00,0x20,0x20, 0xE0,0x40,0x20,0x20,0x60,0x00,0x00,0xC0,0x20,0x20,0x20,0x24,0xFC,0x00,0x20,0xE0, 0x00,0x00,0x00,0x20,0xE0,0x00,0x00,0x20,0x2C,0xEC,0x00,0x00,0x00,0x00,0x20,0xE0, 0x40,0x20,0x20,0x20,0xC0,0x00,0x00,0x80,0x40,0x20,0x20,0x40,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x20,0x20,0x40,0x00,0x20,0xE0, 0x40,0x20,0x20,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x0E,0x01,0x0E,0x01,0x00,0x00,0x00,0x01, 0x0E,0x01,0x0E,0x01,0x00,0x00,0x00,0x01,0x0E,0x01,0x0E,0x01,0x00,0x00,0x00,0x0C, 0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x09,0x08,0x08,0x0F,0x08,0x00,0x08,0x08, 0x0F,0x08,0x08,0x00,0x00,0x00,0x00,0x07,0x08,0x08,0x08,0x04,0x0F,0x08,0x00,0x07, 0x08,0x08,0x08,0x04,0x0F,0x08,0x00,0x08,0x08,0x0F,0x08,0x08,0x00,0x00,0x08,0x0F, 0x08,0x00,0x00,0x08,0x0F,0x08,0x00,0x03,0x04,0x08,0x08,0x04,0x03,0x00,0x00,0x0C, 0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x08,0x08,0x08,0x04,0x00,0x08,0x0F, 0x08,0x00,0x00,0x08,0x0F,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; public static void Main() { Lcd12864 x=new Lcd12864(); while (1==1) { x.PUTBMP(bmp001); //液晶点阵正向显示1 秒 System.Threading.Thread.Sleep(1000); x.PUTREVERSEBMP(bmp001); //反向显示1 秒 System.Threading.Thread.Sleep(1000); } } }
如果你调用没有问题的话,接线没有错误的话,你将看到在屏幕的上面显示出www.arduino.cn,有没有www我忘记了,大概是这个意思,因为现在是在家里写博客,没有相关测试环境。netduino版本nfc读写器驱动和彩色液晶屏的驱动还在准备和测试中,做好了一并奉上。
lcd的淘宝地址是:
http://item.taobao.com/item.htm?spm=a230r.1.0.0.Z7vxT5&id=19563684137
netduino的淘宝地址是:
http://item.taobao.com/item.htm?spm=686.1000925.1000774.23.RwMzRt&id=21448079990
同时netduino的qq群欢迎大家加入群号是:331212289