概述
【基于STM32】Stduino拓展学习(三)LCD12864
本文转载自:http://www.stduino.com/forum.php?mod=viewthread&tid=65&extra=page%3D1=
关键词:
51;stm32;arduino;stduino单片机;stduino UNO&Nano;LCD1602
说明:
带中文字库的LCD128X64是一种具有4位/8位并行、2线或3线串行多种接口方式,内部含有国标一级、二级简体中文字库的点阵图形液晶显示模块。其显示分辨率为128×64,内置8192个1616点汉字,和128个168点ASCII字符集。利用该模块灵活的接口方式和简单、方便的操作指令,可构成全中文人机交互图形界面。可以显示8×4行16×16点阵的汉字。
LCD12864有多种接线方式,依据数据传输的方式可以分为8位并口、4位并口以及串口接线三种方式。串口接线只需要接一根数据线,节约了端口,因此,我们采用串口接线的方式。
实验目的:
在本例中,我们将利用LCD12864模块输出特定字符,以及让LCD显示图片。
器材:
Stduino UNO/Nano;杜邦线;LCD12864
电路连接:
示例一:输出特定字符代码
#include <LCD12864.h>
Lcd12864 lcd12864;
void setup()
{
// put your setup code here, to run once:
lcd12864.initial(A2,A1,A0,9);// EN,RW,RS,PSB
lcd12864.clean();//清屏
delay(20);
}
void loop()
{
// put your main code here, to run repeatedly:
lcd12864.clean();//清屏
lcd12864.ShowString(0,2,"思特诺");//从第0行第2列开始 输出"思特诺"内容
lcd12864.ShowString(1,2,"Stduino");//从第1行第2列开始 输出"Stduino"内容
lcd12864.ShowString(3,1,"创建时间: 年");//从第3行第1列开始输出"创建时间: 年"内容
lcd12864.ShowInt(3,6,2020);//从第3行第6列开始 输出2020内容
lcd12864.ShowDouble(2,1,123.43);//从第2行第1列开始 输出123.43内容
delay(1000);//延时1000ms
}
示例二:显示128×64像素大小的图画
首先我们需要利用Krita或者其他绘图软件制作一幅128×64大小的黑白bmp格式的图片。接下来,将其导入到取字模软件,获得Stduino IDE可识别的每一像素点的信息。随后利用DrawFullScreen()方法,将像素点的信息传递给LCD上的每一位地址,即可绘制全屏的像素图。
第一步:在Krita中新建128×64大小的文档,并绘制像素图,保存为BMP文件:
因为今年有千年一遇的新智彗星访问地球,因此画了一幅彗星的图片,嘿嘿,算作补上没有看到的遗憾吧。
第二步,利用取字模软件,将BMP图转化为像素信息:
参数确认:选择C语言以及输出大小(128×64),点击参数确认;
第三步:编写代码。
把前面的数据复制到一个无符号字符数组中,再利用DrawFullScreen()方法处理即可。
代码如下:
#include <LCD12864.h>
Lcd12864 lcd12864;
unsigned char newWise[]={ //你的图片的数据
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x19,0x87,0xBC,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x18,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x60,0xC2,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x46,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x29,0x08,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x08,0xB0,0x00,0x10,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xDC,0x00,0xA4,0x25,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0x01,0x12,0x00,0x00,0x08,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3B,0x94,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
0x41,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,
0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6B,
0xC8,0x00,0x00,0x00,0x00,0x00,0x00,0x04,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x8F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0x00,0x05,0x98,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xF8,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x10,0x00,0x00,0xF7,0xF0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0xFC,0xC0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0xF3,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x00,0x00,0x00,0x00,0x00,0x03,0xFC,0x00,
0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x07,0xF8,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x07,0xC0,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x00,0x00,0x00,0x00,0x07,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,
0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x00,0x02,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x03,0x40,0x01,
0x40,0x40,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x10,
0x00,0x01,0x00,0x00,0x00,0x00,0x02,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,
0x00,0x40,0x00,0x01,0x00,0x80,0x00,0x00,
0x04,0x01,0x00,0x40,0xA3,0x80,0x06,0x18,
0x04,0x00,0x20,0x00,0x08,0x00,0x00,0x04,
0x00,0x96,0x00,0x20,0x80,0x10,0x80,0x04,
0x00,0x40,0x01,0x00,0x00,0x08,0x06,0x01,
0x40,0x00,0x08,0x00,0x00,0x00,0x84,0x00,
0x80,0x00,0x00,0x18,0x52,0x01,0x00,0x30,
0x01,0x00,0x60,0x29,0xB9,0xC0,0xC0,0x46,
0x90,0x00,0x00,0x40,0x00,0x02,0x80,0x02,
0x09,0x00,0x00,0x52,0x01,0x28,0x8C,0xFA,
0x40,0xA9,0x08,0x20,0x34,0x00,0x0E,0xE0,
0x43,0x94,0x73,0x62,0x0D,0xDC,0x0C,0x15,
0x42,0x00,0x20,0x04,0x00,0x00,0x19,0xB7,
0x3D,0xE8,0x7F,0x9A,0xEB,0x36,0xF9,0xFC,
0x00,0x08,0x44,0x00,0x14,0x0C,0xD5,0x7B,
0xC3,0x99,0x78,0xEB,0x20,0x43,0xBB,0x1A,
0x14,0xA1,0x80,0x11,0x00,0x02,0x00,0x3F,
0x81,0x81,0xC2,0x3F,0xAF,0xEF,0x3E,0x18,
0x31,0x0C,0x88,0xD0,0x98,0xB0,0x40,0x3E,
0x4D,0xFD,0xE4,0x1F,0xDF,0x3F,0xD8,0x58,
0xAC,0x00,0x0B,0x01,0x6E,0x88,0x02,0x5C,
0xFE,0xF9,0xEC,0x0F,0x9F,0x9D,0x70,0x0F,
0xF2,0x10,0xE4,0x00,0x65,0x00,0x03,0x09,
0xFE,0x7F,0xC9,0x07,0xBF,0xC7,0xC0,0x47,
0xCB,0x0C,0x49,0xB4,0x48,0x30,0x01,0xE3,
0xF1,0x3F,0x89,0x03,0xFF,0xB3,0x80,0x77,
0xF2,0xED,0xEF,0x6E,0xC3,0xF0,0x0D,0xF9,
0xC0,0x8E,0x02,0x10,0xFF,0xFF,0x01,0x3B,
0xE6,0x08,0x71,0xC3,0x00,0xC0,0x0C,0xF0,
0x00,0xE4,0x00,0x8F,0x1F,0xF8,0x01,0x39,
0x7E,0x0F,0x70,0x00,0x75,0x00,0x6E,0x62,
0x00,0x70,0x01,0xCF,0x0F,0xF0,0x03,0x3D,
0xFF,0xFF,0x4E,0x44,0x86,0x00,0xEF,0x00,
0x18,0x60,0x03,0xC7,0xE3,0xE0,0x03,0x3E,
0xE7,0xE8,0xC9,0xE6,0xFC,0x00,0xE7,0x00,
0x1C,0xA0,0x03,0xE3,0xF1,0x80,0x03,0xBE,
0x80,0xFB,0x7A,0xF2,0xF0,0x01,0xF8,0x00,
0x18,0x00,0x01,0xFB,0xF0,0x00,0x01,0x9F,
0x80,0x3F,0xBC,0xFF,0x80,0x03,0xF0,0x00,
0x38,0x60,0x01,0xC9,0x98,0x00,0x01,0xCF,
0x80,0x01,0x3F,0xE0,0x00,0x01,0xE0,0x00,
0x62,0x70,0x00,0xE7,0xF0,0x00,0x30,0xE7,
0x00,0x40,0x00,0x00,0x00,0x83,0x60,0x00,
0xF6,0x26,0x1C,0xD7,0x80,0x00,0x30,0xE7,
0x00,0x3F,0x10,0x00,0x00,0x00,0x00,0x09,
0xC7,0x72,0xCE,0x6B,0xE0,0x00,0x18,0x7F,
0x00,0x47,0xE0,0x00,0x00,0x00,0x00,0x13,
0x0F,0x04,0x81,0x65,0xF0,0x00,0x0C,0x7F,
0x00,0x53,0xF4,0x00,0x00,0x00,0x00,0x1E,
0x07,0x33,0x00,0xF4,0x60,0x00,0x0E,0x7F,
0x00,0x00,0x7D,0x80,0x00,0x00,0x00,0x3C,
0x07,0x3D,0x84,0x33,0x00,0x08,0x0E,0x3F,
0x01,0x00,0x3F,0xF0,0x00,0x08,0x02,0x1C,
0x47,0x1F,0x07,0x19,0x40,0x18,0x2E,0x3F,
0x00,0x00,0x07,0xE7,0x80,0x08,0x02,0x10,
0x44,0x1F,0x03,0xC0,0x00,0x10,0x26,0x3F
};
void setup()
{
// put your setup code here, to run once:
lcd12864.initial(A2,A1,A0,9);
lcd12864.clean();
delay(20);
}
void loop()
{
// put your main code here, to run repeatedly:
lcd12864.clean();
lcd12864.DrawFullScreen(newWise);
delay(50000);
}
实验效果:
Stduino IDE是一款面向32位处理器快速入门学习的集成开发平台,目前已经支持Arduino_Core_STM32框架,集聚快捷、高效、免费、开源、易得于一身,软件还集成了GDB调试功能。
IDE当前支持的功能有:
- GDB调试
- 封装库下载安装
- 代码自动补全提示
- 中英文模式
- UTF-8GBK编码格式
- 代码快速格式化
- SWD串口程序下载&调试(已验证)
- DFU程序下载方式(待验证)
- USB HID程序下载方式(待验证)
- maple DFU程序下载方式(待验证)
- maple DFU2程序下载方式(待验证)
- MassStorage程序下载方式(待验证)
更多功能细节请前往www.stduino.com进行了解
已经支持的芯片&板型列表:
- Stduino UNO&Nano
- Nucleo 144 boards
- Nucleo 64 boards
- Nucleo 32 boards
- Discovery boards
- Eval boards
- STM32MP1 series coprocessor boards
- Generic STM32F0 boards
- Generic STM32F1 boards
- Generic STM32F3 boards
- Generic STM32F4 boards
- Generic STM32H7 boards
- Generic STM32L0 boards
- 3D printer boards
- LoRa boards
- Electronic Speed Controller boards
- Generic flight controllers
- Garatronics boards
- Midatronics boards
更多功能集成正在进行中~
最后
以上就是时尚音响为你收集整理的【更好用的单片机】Stduino拓展学习(三)LCD12864【基于STM32】Stduino拓展学习(三)LCD12864的全部内容,希望文章能够帮你解决【更好用的单片机】Stduino拓展学习(三)LCD12864【基于STM32】Stduino拓展学习(三)LCD12864所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复