esp8266测试1.44英寸TFT屏(驱动7735)的demo

news/2024/11/25 2:15:02/

参考这教程:

使用esp8266点亮福利屏型号st7735的1.44的TFT屏
管脚连接:
我的用的TFT1.44寸ST7735,与NodeMCU针脚接线成功连接
VCC——3V
GND——G
LED——3V
CLK——D5
SDI——D7
RS——D6
RST——D4
CS——D8
这里给出常用的屏幕管脚定义
在这里插入图片描述
以及esp8266nodemcu的管脚定义,协助理解接线:
在这里插入图片描述RS——D6
CS——D8
RST——D4
是因为在Arduino\libraries\TFT_eSPI\下的User_Setup.h中有定义:
在这里插入图片描述

遇到的错误:

  1. 报错找不到 <TJpg_Decoder.h> 这个库,网上找了一番没有相关的帖子,自己找到这个网站,下载了1.0.7的版本在这里插入图片描述
    ,解压放到了对应arduino的libraries文件夹下,直接编译通过。

给出测试的demo

//屏幕驱动库
#include <TFT_eSPI.h> 
//spi驱动库
#include <SPI.h>
//图片解码库
#include <TJpg_Decoder.h>// bilibili的图标
#include "img/bililogo.h"//背景颜色
uint16_t bgColor =0x0000 ;
//线框颜色
uint16_t  xkColor= 0xFFFF;
// 上一次刷新时间
int AprevTime = 0;
// 第Anim张图
int Anim = 0;TFT_eSPI tft = TFT_eSPI();  // 引脚请自行配置tft_espi库中的 User_Setup.h文件
TFT_eSprite clk = TFT_eSprite(&tft);bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t* bitmap)
{if ( y >= tft.height() ) return 0;tft.pushImage(x, y, w, h, bitmap);// Return 1 to decode next blockreturn 1;}void setup() {// put your setup code here, to run once:Serial.begin(9600);tft.begin(); /* TFT init */tft.invertDisplay(0);//反转所有显示颜色:1反转,0正常tft.fillScreen(0x0000);tft.setTextColor(TFT_WHITE, 0x0000);// 设置屏幕显示的旋转角度,参数为:0, 1, 2, 3// 分别代表 0°、90°、180°、270°//根据实际需要旋转tft.setRotation(3); TJpgDec.setJpgScale(1);TJpgDec.setSwapBytes(true);TJpgDec.setCallback(tft_output);tft.fillScreen(0x0000);
//  tft.fillRoundRect(0,0,128,128,0,bgColor);//实心矩形//绘制线框tft.drawFastHLine(0,0,128,xkColor);tft.drawFastHLine(0,18,128,xkColor);tft.drawFastHLine(0,106,128,xkColor);tft.drawFastVLine(80,0,18,xkColor);tft.drawFastHLine(0,88,128,xkColor);tft.drawFastVLine(32,88,18,xkColor);tft.drawFastVLine(85,88,18,xkColor);
}void fanspush()
{TJpgDec.drawJpg(1,108,bililogo,sizeof(bililogo));
}void loop() {// put your main code here, to run repeatedly:fanspush();
//  myImage();
//  imgAnim();
}

对应的.h文件大家可以自己生成参考这个网站
我这也给出

#include <pgmspace.h>
const uint8_t bililogo[] PROGMEM =  {
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x08, 0x06, 0x06, 0x07, 0x06, 
0x05, 0x08, 0x07, 0x07, 0x07, 0x09, 0x09, 0x08, 0x0a, 0x0c, 0x14, 0x0d, 0x0c, 0x0b, 0x0b, 0x0c, 0x19, 0x12, 0x13, 0x0f, 0x14, 0x1d, 0x1a, 0x1f, 0x1e, 0x1d, 0x1a, 0x1c, 0x1c, 0x20, 
0x24, 0x2e, 0x27, 0x20, 0x22, 0x2c, 0x23, 0x1c, 0x1c, 0x28, 0x37, 0x29, 0x2c, 0x30, 0x31, 0x34, 0x34, 0x34, 0x1f, 0x27, 0x39, 0x3d, 0x38, 0x32, 0x3c, 0x2e, 0x33, 0x34, 0x32, 0xff, 
0xdb, 0x00, 0x43, 0x01, 0x09, 0x09, 0x09, 0x0c, 0x0b, 0x0c, 0x18, 0x0d, 0x0d, 0x18, 0x32, 0x21, 0x1c, 0x21, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0x12, 0x00, 0x12, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x00, 
0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 
0xff, 0xc4, 0x00, 0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 
0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 
0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 
0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 
0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 
0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
0xf8, 0xf9, 0xfa, 0xff, 0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 
0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, 0x02, 
0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 
0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 
0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 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x5d, 0x47, 0xe2, 0x7b, 0xad, 0x33, 0xc3, 0xf7, 0xbe, 0x1c, 0xb6, 0xd4, 0x2e, 0xb4, 0xc9, 0xb4, 0x3b, 0x5b, 0x3b, 
0xd3, 0xa6, 0x9d, 0xae, 0x5e, 0x13, 0x22, 0xbc, 0x7b, 0xd4, 0x16, 0x42, 0x37, 0x7d, 0x0e, 0x46, 0x41, 0xc5, 0x33, 0x42, 0xd1, 0x7c, 0x5d, 0x16, 0xa9, 0xa5, 0xd8, 0x5b, 0x68, 0x7a, 
0xe6, 0x9d, 0xa0, 0xad, 0xed, 0xbc, 0xf7, 0x51, 0x5f, 0x3f, 0x99, 0x1c, 0x61, 0x26, 0x57, 0x32, 0x02, 0xc8, 0xa1, 0x30, 0x06, 0x7e, 0x50, 0x09, 0xe7, 0x24, 0xe7, 0x14, 0x01, 0xe6, 
0x77, 0xa0, 0xe9, 0xf7, 0xf7, 0x16, 0x57, 0x19, 0x13, 0xdb, 0xca, 0xd1, 0x48, 0x14, 0xe4, 0x06, 0x52, 0x41, 0xc7, 0xe2, 0x28, 0xa7, 0xf8, 0x9d, 0xc6, 0xa1, 0xe2, 0xcd, 0x66, 0xf6, 
0xdc, 0x6f, 0x82, 0xe2, 0xfa, 0x79, 0x63, 0x65, 0x3c, 0x32, 0xb3, 0x92, 0x08, 0xfc, 0x0d, 0x14, 0x08, 0x84, 0xcb, 0x24, 0x2d, 0xba, 0x27, 0x68, 0xd8, 0xe3, 0x25, 0x0e, 0x0d, 0x2b, 
0x5c, 0xcf, 0x39, 0xdb, 0x34, 0xd2, 0x48, 0xbe, 0x8e, 0xc4, 0x8f, 0xd6, 0x8a, 0x28, 0x01, 0x68, 0xa2, 0x8a, 0x00, 0xff, 0xd9, 
};

这里解释一下图片数据定义时的 PROGMEM 关键字,给出官方解释:
在这里插入图片描述

#include <pgmspace.h>
const uint8_t bililogo[] PROGMEM =  {
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x08, 0x06, 0x06, 0x07, 0x06, 
0x05, 0x08, 0x07, 0x07, 0x07, 0x09, 0x09, 0x08, 0x0a, 0x0c, 0x14, 0x0d, 0x0c, 0x0b, 0x0b, 0x0c, 0x19, 0x12, 0x13, 0x0f, 0x14, 0x1d, 0x1a, 0x1f, 0x1e, 0x1d, 0x1a, 0x1c, 0x1c, 0x20, 
0x24, 0x2e, 0x27, 0x20, 0x22, 0x2c, 0x23, 0x1c, 0x1c, 0x28, 0x37, 0x29, 0x2c, 0x30, 0x31, 0x34, 0x34, 0x34, 0x1f, 0x27, 0x39, 0x3d, 0x38, 0x32, 0x3c, 0x2e, 0x33, 0x34, 0x32, 0xff, 
0xdb, 0x00, 0x43, 0x01, 0x09, 0x09, 0x09, 0x0c, 0x0b, 0x0c, 0x18, 0x0d, 0x0d, 0x18, 0x32, 0x21, 0x1c, 0x21, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 

也就是说告诉mcu(板子)存在FLASH中,而不是SRAM中,这里给出FLASH与SRAM的区别:
在这里插入图片描述
参考这个

最后的最后,这个博主的教程我觉得很有用
Arduino+esp8266+1.3寸TFT屏(st7789驱动)显示图片教程


http://www.ppmy.cn/news/6126.html

相关文章

矽昌--Wireless配置简述

Wireless配置简述 1 编译 1.1 首次编译 ​ 如果是第一次编译时就需要添加wifi模块&#xff0c;请检查所需编译版型的配置&#xff0c;配置位于openwrt-18.06/target/linux/siflower/ 文件夹下&#xff0c;例如sf19a28_ac28_fullmask_def.config为ac28版型的配置。 查看配置并…

Qt中实例化一个函数变量时加不加括号的区别,以及括号中的this的使用

一、设计一个测试小程序 废话不多说&#xff0c;直接上代码。 main.h函数就不多说了&#xff0c;没改动。直接上mainwindow.h&#xff0c;也没改动。看mainwindow.cpp的内容。 #include "mainwindow.h" #include "ui_mainwindow.h" #include "test.…

虚函数与纯虚函数

1. 虚函数与纯虚函数 虚函数&#xff1a;在类成员方法的声明&#xff08;不是定义&#xff09;语句前加virtual关键字&#xff0c;此函数就变成了虚函数。具体如下&#xff1a; virtual void function set_value();... endfunction用途&#xff1a;主要用于实现多态。在父类中…

三.keepalived介绍及工作原理

keepalived介绍及工作原理keepalived介绍及工作原理一、keepalived的介绍二、Keepalived服务的重要功能1、管理LVS负载均衡软件2、实现对LVS集群节点健康检查功能&#xff08;healthcheck&#xff09;3、作为系统网络服务的高可用功能&#xff08;failover&#xff09;三、Keep…

QT 学习笔记(十一)

文章目录一、绘图设备1. QPixmap1.1 QPixmap 简介1.2 QPixmap 演示2. QBitmap2.1 QBitmap 简介2.2 QBitmap 演示见 QPixmap 和 QBitmap 的区别。3. QImage3.1 QImage 简介3.2 QImage 演示4. QPicture4.1 QPicture 简介4.2 QPicture 演示二、QPixmap 和 QBitmap 的区别1. widget…

Android基础学习(二十四)—— View绘制

1、Activity.setContentView Activity.setContentView(layoutResID:int)PhoneWindow.setContentView(layoutResID:int)PhoneWindow.installDecor//mContentParent为DecorViewLayoutInflater.inflate(layoutResID:int, mContentParent:ViewGroup)//attachToRoot为 root ! nullL…

【数据结构】详解队列和循环队列

目录一.队列1.队列的概念及结构2.队列的实现Queue.hQueue.c二.循环队列1.循环队列的实现2.设计循环队列解题思路代码一.队列 1.队列的概念及结构 队列&#xff1a;只允许在一端进行插入数据操作&#xff0c;在另一端进行删除数据操作的特殊线性表&#xff0c;队列具有先进先出…

单商户商城系统功能拆解52—财务概况

单商户商城系统&#xff0c;也称为B2C自营电商模式单店商城系统。可以快速帮助个人、机构和企业搭建自己的私域交易线上商城。 单商户商城系统完美契合私域流量变现闭环交易使用。通常拥有丰富的营销玩法&#xff0c;例如拼团&#xff0c;秒杀&#xff0c;砍价&#xff0c;包邮…