【小项目关键技术四】液晶显示屏
分享一个刷新率比较高的,利用的是 UTFT.h
的库。
完整版资料地址为:https://pmdway.com/blogs/product-guides-for-arduino/using-the-0-96-80-x-160-full-color-ips-lcd-module-with-arduino
程序如下:
// https://pmdway.com/blogs/news/using-the-0-96-80-x-160-full-color-ips-lcd-module-with-arduino
// https://pmdway.com/products/0-96-80-x-160-full-color-lcd-module
#include <UTFT.h>// Declare which fonts we will be using
extern uint8_t SmallFont[];// Initialize display
// Library only supports software SPI at this time
//NOTE: support DUE , MEGA , UNO
//SDI=11 SCL=13 /CS =10 /RST=8 D/C=9
UTFT myGLCD(ST7735S_4L_80160,11,13,10,8,9); //LCD: 4Line serial interface SDI SCL /CS /RST D/C NOTE:Only support DUE MEGA UNO// Declare which fonts we will be using
extern uint8_t BigFont[];int color = 0;
word colorlist[] = {VGA_WHITE, VGA_BLACK, VGA_RED, VGA_BLUE, VGA_GREEN, VGA_FUCHSIA, VGA_YELLOW, VGA_AQUA};
int bsize = 4;void drawColorMarkerAndBrushSize(int col)
{myGLCD.setColor(VGA_BLACK);myGLCD.fillRect(25, 0, 31, 239);myGLCD.fillRect(myGLCD.getDisplayXSize()-31, 161, myGLCD.getDisplayXSize()-1, 191);myGLCD.setColor(VGA_WHITE);myGLCD.drawPixel(25, (col*30)+15);for (int i=1; i<7; i++)myGLCD.drawLine(25+i, ((col*30)+15)-i, 25+i, ((col*30)+15)+i);if (color==1)myGLCD.setColor(VGA_WHITE);elsemyGLCD.setColor(colorlist[col]);if (bsize==1)myGLCD.drawPixel(myGLCD.getDisplayXSize()-15, 177);elsemyGLCD.fillCircle(myGLCD.getDisplayXSize()-15, 177, bsize);myGLCD.setColor(colorlist[col]);
}
void setup()
{randomSeed(analogRead(0));// Setup the LCDmyGLCD.InitLCD();myGLCD.setFont(SmallFont);
}void loop()
{int buf[158];int x, x2;int y, y2;int r;// Clear the screen and draw the framemyGLCD.clrScr();myGLCD.setColor(255, 0, 0);myGLCD.fillRect(0, 0, 159, 13);myGLCD.setColor(64, 64, 64);myGLCD.fillRect(0, 114, 159, 127);myGLCD.setColor(255, 255, 255);myGLCD.setBackColor(255, 0, 0);myGLCD.print("pmdway.com.", CENTER, 1);myGLCD.setBackColor(64, 64, 64);myGLCD.setColor(255,255,0);myGLCD.print("pmdway.com", LEFT, 114);myGLCD.setColor(0, 0, 255);myGLCD.drawRect(0, 13, 159, 113);// Draw crosshairsmyGLCD.setColor(0, 0, 255);myGLCD.setBackColor(0, 0, 0);myGLCD.drawLine(79, 14, 79, 113);myGLCD.drawLine(1, 63, 158, 63);myGLCD.setColor(0, 0, 255);myGLCD.drawLine(0, 79, 159, 79);for (int i=9; i<150; i+=10)myGLCD.drawLine(i, 61, i, 65);for (int i=19; i<110; i+=10)myGLCD.drawLine(77, i, 81, i);// Draw sin-, cos- and tan-lines myGLCD.setColor(0,255,255);myGLCD.print("Sin", 5, 15);for (int i=1; i<158; i++){myGLCD.drawPixel(i,63+(sin(((i*2.27)*3.14)/180)*40));}myGLCD.setColor(255,0,0);myGLCD.print("Cos", 5, 27);for (int i=1; i<158; i++){myGLCD.drawPixel(i,63+(cos(((i*2.27)*3.14)/180)*40));}myGLCD.setColor(255,255,0);myGLCD.print("Tan", 5, 39);for (int i=1; i<158; i++){myGLCD.drawPixel(i,63+(tan(((i*2.27)*3.14)/180)));}delay(2000);myGLCD.setColor(0,0,0);myGLCD.fillRect(1,14,158,113);myGLCD.setColor(0, 0, 255);myGLCD.setBackColor(0, 0, 0);myGLCD.drawLine(79, 14, 79, 113);myGLCD.drawLine(1, 63, 158, 63);myGLCD.setColor(0, 0, 255);myGLCD.drawLine(0, 79, 159, 79); // Draw a moving sinewavex=1;for (int i=1; i<(158*20); i++) {x++;if (x==159)x=1;if (i>159){if ((x==79)||(buf[x-1]==63))myGLCD.setColor(0,0,255);elsemyGLCD.setColor(0,0,0);myGLCD.drawPixel(x,buf[x-1]);}myGLCD.setColor(0,255,255);y=63+(sin(((i*2.5)*3.14)/180)*(40-(i / 100)));myGLCD.drawPixel(x,y);buf[x-1]=y;}delay(2000);myGLCD.setColor(0,0,0);myGLCD.fillRect(1,14,158,113);myGLCD.setColor(0, 0, 255);myGLCD.drawLine(0, 79, 159, 79); // Draw some filled rectanglesfor (int i=1; i<6; i++){switch (i){case 1:myGLCD.setColor(255,0,255);break;case 2:myGLCD.setColor(255,0,0);break;case 3:myGLCD.setColor(0,255,0);break;case 4:myGLCD.setColor(0,0,255);break;case 5:myGLCD.setColor(255,255,0);break;}myGLCD.fillRect(39+(i*10), 23+(i*10), 59+(i*10), 43+(i*10));}delay(2000);myGLCD.setColor(0,0,0);myGLCD.fillRect(1,14,158,113);myGLCD.setColor(0, 0, 255);myGLCD.drawLine(0, 79, 159, 79); // Draw some filled, rounded rectanglesfor (int i=1; i<6; i++){switch (i){case 1:myGLCD.setColor(255,0,255);break;case 2:myGLCD.setColor(255,0,0);break;case 3:myGLCD.setColor(0,255,0);break;case 4:myGLCD.setColor(0,0,255);break;case 5:myGLCD.setColor(255,255,0);break;}myGLCD.fillRoundRect(99-(i*10), 23+(i*10), 119-(i*10), 43+(i*10));}delay(2000);myGLCD.setColor(0,0,0);myGLCD.fillRect(1,14,158,113);myGLCD.setColor(0, 0, 255);myGLCD.drawLine(0, 79, 159, 79);
// Draw some filled circlesfor (int i=1; i<6; i++){switch (i){case 1:myGLCD.setColor(255,0,255);break;case 2:myGLCD.setColor(255,0,0);break;case 3:myGLCD.setColor(0,255,0);break;case 4:myGLCD.setColor(0,0,255);break;case 5:myGLCD.setColor(255,255,0);break;}myGLCD.fillCircle(49+(i*10),33+(i*10), 15);}delay(2000);myGLCD.setColor(0,0,0);myGLCD.fillRect(1,14,158,113);myGLCD.setColor(0, 0, 255);myGLCD.drawLine(0, 79, 159, 79); // Draw some lines in a patternmyGLCD.setColor (255,0,0);for (int i=14; i<113; i+=5){myGLCD.drawLine(1, i, (i*1.44)-10, 112);}myGLCD.setColor (255,0,0);for (int i=112; i>15; i-=5){myGLCD.drawLine(158, i, (i*1.44)-12, 14);}myGLCD.setColor (0,255,255);for (int i=112; i>15; i-=5){myGLCD.drawLine(1, i, 172-(i*1.44), 14);}myGLCD.setColor (0,255,255);for (int i=15; i<112; i+=5){myGLCD.drawLine(158, i, 171-(i*1.44), 112);}delay(2000);myGLCD.setColor(0,0,0);myGLCD.fillRect(1,14,158,113);myGLCD.setColor(0, 0, 255);myGLCD.drawLine(0, 79, 159, 79); // Draw some random circlesfor (int i=0; i<100; i++){myGLCD.setColor(random(255), random(255), random(255));x=22+random(116);y=35+random(57);r=random(20);myGLCD.drawCircle(x, y, r);}delay(2000);myGLCD.setColor(0,0,0);myGLCD.fillRect(1,14,158,113);myGLCD.setColor(0, 0, 255);myGLCD.drawLine(0, 79, 159, 79); // Draw some random rectanglesfor (int i=0; i<100; i++){myGLCD.setColor(random(255), random(255), random(255));x=2+random(156);y=16+random(95);x2=2+random(156);y2=16+random(95);myGLCD.drawRect(x, y, x2, y2);}delay(2000);myGLCD.setColor(0,0,0);myGLCD.fillRect(1,14,158,113);myGLCD.setColor(0, 0, 255);myGLCD.drawLine(0, 79, 159, 79); // Draw some random rounded rectanglesfor (int i=0; i<100; i++){myGLCD.setColor(random(255), random(255), random(255));x=2+random(156);y=16+random(95);x2=2+random(156);y2=16+random(95);myGLCD.drawRoundRect(x, y, x2, y2);}delay(2000);myGLCD.setColor(0,0,0);myGLCD.fillRect(1,14,158,113);myGLCD.setColor(0, 0, 255);myGLCD.drawLine(0, 79, 159, 79); for (int i=0; i<100; i++){myGLCD.setColor(random(255), random(255), random(255));x=2+random(156);y=16+random(95);x2=2+random(156);y2=16+random(95);myGLCD.drawLine(x, y, x2, y2);}delay(2000);myGLCD.setColor(0,0,0);myGLCD.fillRect(1,14,158,113);myGLCD.setColor(0, 0, 255);myGLCD.drawLine(0, 79, 159, 79); for (int i=0; i<5000; i++){myGLCD.setColor(random(255), random(255), random(255));myGLCD.drawPixel(2+random(156), 16+random(95));}delay(2000);myGLCD.fillScr(0, 0, 255);myGLCD.setColor(255, 0, 0);myGLCD.fillRoundRect(10, 17, 149, 72);myGLCD.setColor(255, 255, 255);myGLCD.setBackColor(255, 0, 0);myGLCD.print("That's it!", CENTER, 20);myGLCD.print("Restarting in a", CENTER, 45);myGLCD.print("few seconds...", CENTER, 57);myGLCD.setColor(0, 255, 0);myGLCD.setBackColor(0, 0, 255);myGLCD.print("Runtime: (msecs)", CENTER, 103);myGLCD.printNumI(millis(), CENTER, 115);delay (5000);
}
Mega2560
1.77 Inch TFT LCD Display With ST7735S On Arduino Mega 2560
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>#define TFT_CS 10
#define TFT_RST 8
#define TFT_DC 9 #define TFT_SCLK 13
#define TFT_MOSI 11 //Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);void setup(void) {tft.initR(INITR_BLACKTAB); tft.fillScreen(ST7735_BLACK); tft.setTextColor(ST7735_WHITE);tft.setTextSize(0);tft.setCursor(30,80);tft.println("Hello World!"); delay(1000);}void loop() {tft.fillScreen(ST7735_WHITE); delay(1000);tft.setTextColor(ST7735_BLACK);tft.setTextSize(0);tft.setCursor(30,80);tft.println("Hey you! You got it!"); delay(500);
}
tronixstuff.com
Small IPS Color Display with Arduino Nano
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>//Arduino Uno/Nano Pins:
//GND = GND
//VCC = 5v
//DC = 8
//RES = 9
//CS = 10
//SDA = 11
//SCL = 13#define TFT_CS A1
#define TFT_DC A2
#define TFT_RST A3
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);void setup(void) {tft.initR(INITR_MINI160x80); //Initializes ST7735.//Please note that use of 'MINI160x80' displays cyan instead of yellow and vice versa.tft.setRotation(3);tft.fillScreen(ST7735_BLACK);tft.setCursor(5, 5);tft.setTextColor(ST7735_RED); tft.setTextSize(1);tft.println("Welcome to");tft.setCursor(5, 20);tft.setTextColor(ST7735_GREEN);tft.setTextSize(2);tft.println("2021-08-09");tft.setCursor(5, 38);tft.setTextColor(ST7735_BLUE);tft.setTextSize(3);tft.print("PKU");tft.drawLine(153, 0, 153, 79, ST7735_WHITE);tft.drawCircle(153, 20, 5, ST7735_CYAN);tft.fillTriangle(153, 35, 148, 45, 158, 45, ST7735_MAGENTA);tft.drawTriangle(153, 35, 148, 45, 158, 45, ST7735_WHITE);tft.fillCircle(153, 60, 5, ST7735_YELLOW);
}void loop()
{}
https://item.taobao.com/item.htm?spm=a230r.1.14.41.72664a8cmaOyRc&id=552454154728&ns=1&abbucket=7#detail
4.0inch SPI Module ST7796
【小项目关键技术四】液晶显示屏相关推荐
- 【小项目关键技术】硬件通信三种方式、串口、IIC、SPI
文章目录 串口UART: IIC SPI SWD 仿真下载接口 串口UART: 引脚 功能 VCC GND TXD 发送数据输出引脚. RXD 接收数据输入引脚. IIC 引脚定义为:SCL.SDA ...
- 【小项目关键技术六】控制北斗 GPS 定位 / UWB 室内定位
文章目录 UWB 定位 GPS 定位 UWB 定位 产品链接:维特智能UWB室内定位传感器模块平面坐标二维厘米级通讯距离测量 产品资料地址:(打开网站搜索型号获取资料) 模块实物如下: 指令 功能 0 ...
- 【小项目关键技术五】控制全彩 WS2812 灯环/灯带
Ref: Arduino控制WS2812灯带(灯环) #include <FastLED.h>#define LED_PIN 13// Information about the LED ...
- 【小项目关键技术七】MPU6050
Ref: MPU 6050 Tutorial | How to Program MPU 6050 With Arduino connections for our Arduino UNO and NA ...
- 【小项目关键技术二】UGV电机编码测速
测试程序 #define PinA 2 //外部中断0 #define PinZ 3 //外部中断1 #define PinB 9 //编码器的OUT_B信号连接到数字端口8 #define T 20 ...
- 坦克大战小游戏关键技术总结
这两天参照韩顺平的坦克大战游戏并在其基础上初步完善成一个小的页面游戏,最终js代码大约570行,html代码200多行,具体可参见https://github.com/Mrkaiyang/Art/tr ...
- 鸿蒙OS架构及关键技术整理
鸿蒙OS架构及关键技术整理 一. 鸿蒙OS整体介绍 二. 子系统架构 三. 关键技术 四. 参考资料 一. 鸿蒙OS整体介绍 HarmonyOS简介 原作者:xiangzhihong8 前两天,华为发 ...
- 一文读懂GaussDB(openGauss) 的六大关键技术特性
摘要:更为深入地介绍了GaussDB(openGauss)的关键特性.成功案例. GaussDB(openGauss)是深度融合华为在数据库领域多年的经验,结合企业级场景需求,推出的新一代企业级分布式 ...
- 实训项目四 powerpoint 综合应用_【深化改革结硕果】新疆番茄综合精深加工关键技术及产业化应用项目取得重大突破...
近日,记者从新疆冠农果茸股份有限公司(以下简称冠农股份)获悉,由国家功能食品工程技术研究中心与冠农股份合作的番茄综合精深加工关键技术研究及产业化基地即将在冠农股份挂牌成立.这标志着新疆乃至全国的番茄综 ...
最新文章
- ID--HANDLE--HWND三者之间的互相转换
- RSA, ACS5.X 集成配置
- dropout层_深度学习两大基础Tricks:Dropout和BN详解
- flask和vue的冲突问题
- XML DOM---解析xml dom
- 引用类型--Object类型、Array类型
- labelImg使用教程
- python写入文件取消自动换行
- Tensorflow中 tf.train.exponential_decay() 等实现学习率衰减
- 微信公众平台注册与认证图文教程分享
- SQlite3基本用法,使用sublime编辑器
- C++面向对象程序设计大作业:魔兽世界(三):开战
- 漫画:什么是MD5算法?
- 苹果系统各平台软件安装包地址
- 22,Horizontal Pod Autoscaler(HPA),自动扩缩容
- 吴俊计算机音乐研究者,音乐创作中计算机音乐技术的应用研究
- 杰里之 定时器捕获(timer_cap.c) 使用注意事项【篇】
- 40-岁的中年失业者怎么活下去?,零基础入门学习android
- 利用caffe在Windows下实现图像识别
- WPF 控件样式及样式事件设置
热门文章
- (二)linux内核准备及编译
- java之对象的复制
- 游戏设计模式——C++单例类
- Day3:数据类型(布尔值、集合)
- Eclipse 创建web项目后没有 Java EE 5 Library,没有web开发相关基础java包,myeclipse中有。...
- hdu1166敌兵布阵hdu1754I Hate It(线段树入门)
- CFBundleVersion与CFBundleShortVersionString
- Hibernate映射配置方法
- java正则替换标点
- UA MATH563 概率论的数学基础2 随机变量1 随机变量与分布函数