本文基于aduino IDE以最简化的代码实现合宙ESP32-C3将图片传至1.3寸LCD屏幕,文末有简化前的代码及资料参考

1.需要软件有(如有需要留言,正常我每天都会看CSDN)

1.1开发环境,配置ESP32-C3见,该环境下载因不可描述的原因,你大概率会下载失败,所以最好使用离线方式下载添加0.1.3 合宙CORE-ESP32-C3用arduino点亮ST7735TFT屏_̌萌新历险记的博客-CSDN博客合宙ESP32-C3 CORE开发板 arduino ST7735TFT屏 点亮https://blog.csdn.net/qq_63523190/article/details/125138743?spm=1001.2014.3001.5501

需要用到 TFT_eSPI库

新手添加改库参考(把下文的u8g2替换为TFT_eSPI)

0.1.1 arduino手动添加库(以u8g2例)_̌萌新历险记的博客-CSDN博客_arduino如何添加库文件原料:软件arduino 电脑 网络目的:安装库文件备注:点 项目 菜单 库保存在项目文件夹目录,点 工具 则库文件保存在软件安装目录----------------------------------------------------------------------------------------在线方式arduino可以通过【项目】-【加载库】-【库管理】-搜索安装库或arduino可以通过【工具】-【库管理】--搜索安装库---------------------https://blog.csdn.net/qq_63523190/article/details/124785234?spm=1001.2014.3001.55011.2图片转换数组工具Image2Lcd,自行搜索下载,如有需要我后续补上

*1.3非必须但建议 文本编辑器notepad++

2.硬件需要:

合宙CORE-ESP32-C3开发板一块,现在又出了新版,这里是旧版

1.3寸LCD ST7789 240*240 屏幕一块(芯澜科技、金逸晨我都买了一块一模一样,屏幕贴膜角颜色是蓝色(这对于配置TFT_eSPI库的配置文件有用),但是可能区别于其他1.3寸,各位注意看清)

其他连接线

2.1连接,物理连接按我另一篇博文0.1.3

,但那块是ST7735不是ST7789

ST7789配置类似ST7735,这里还是补上7789要改的地方的图吧

按上面配置,杜邦线不用错位直接直连

3.实现过程

3.1制作图片数组

用image2lcd工具导出*.C/*.H文件

按以下配置设置

点保存后在 arduino开发文件夹下添加导出的图片数组文件,改名

文本编辑器 打开*.h文件,编辑第一行把不带符号的字符串改成不带符号的8位整型

注意改image1的1后续是2、3、4

下面是代码便于复制粘贴

const uint8_t gImage_demo_image1[115200] PROGMEM = 

按上面的命名改完,直接复制下面的到主程序同目录下,重新打开arduino编译上传

#include <SPI.h>//声明头文件
#include <TFT_eSPI.h>
#include "demo_image1.h"
#include "demo_image2.h"
#include "demo_image3.h"
#include "demo_image4.h"TFT_eSPI tft = TFT_eSPI(); //初始化TFT_eSPI对象
#include <JPEGDecoder.h>// Return the minimum of two values a and b
#define minimum(a,b)     (((a) < (b)) ? (a) : (b))//####################################################################################################
// Draw a JPEG on the TFT pulled from a program memory array
//####################################################################################################
//void drawArrayJpeg(const uint8_t arrayname[], uint32_t array_size, int xpos, int ypos)
/*{int x = xpos;int y = ypos;JpegDec.decodeArray(arrayname, array_size);renderJPEG(x, y);Serial.println("#########################");
}
*/
//####################################################################################################
// Draw a JPEG on the TFT, images will be cropped on the right/bottom sides if they do not fit
//####################################################################################################
// This function assumes xpos,ypos is a valid screen coordinate. For convenience images that do not
// fit totally on the screen are cropped to the nearest MCU size and may leave right/bottom borders.
void renderJPEG(int xpos, int ypos)
{// retrieve infomration about the imageuint16_t *pImg;uint16_t mcu_w = JpegDec.MCUWidth;uint16_t mcu_h = JpegDec.MCUHeight;uint32_t max_x = JpegDec.width;uint32_t max_y = JpegDec.height;// Jpeg images are draw as a set of image block (tiles) called Minimum Coding Units (MCUs)// Typically these MCUs are 16x16 pixel blocks// Determine the width and height of the right and bottom edge image blocksuint32_t min_w = minimum(mcu_w, max_x % mcu_w);uint32_t min_h = minimum(mcu_h, max_y % mcu_h);// save the current image block sizeuint32_t win_w = mcu_w;uint32_t win_h = mcu_h;// record the current time so we can measure how long it takes to draw an image// uint32_t drawTime = millis();// save the coordinate of the right and bottom edges to assist image cropping// to the screen sizemax_x += xpos;max_y += ypos;// read each MCU block until there are no morewhile (JpegDec.readSwappedBytes()) {// save a pointer to the image blockpImg = JpegDec.pImage ;// calculate where the image block should be drawn on the screenint mcu_x = JpegDec.MCUx * mcu_w + xpos;  // Calculate coordinates of top left corner of current MCUint mcu_y = JpegDec.MCUy * mcu_h + ypos;// check if the image block size needs to be changed for the right edgeif (mcu_x + mcu_w <= max_x) win_w = mcu_w;else win_w = min_w;// check if the image block size needs to be changed for the bottom edgeif (mcu_y + mcu_h <= max_y) win_h = mcu_h;else win_h = min_h;// copy pixels into a contiguous blockif (win_w != mcu_w){uint16_t *cImg;int p = 0;cImg = pImg + win_w;for (int h = 1; h < win_h; h++){p += mcu_w;for (int w = 0; w < win_w; w++){*cImg = *(pImg + w + p);cImg++;}}}// draw image MCU block only if it will fit on the screenif (( mcu_x + win_w ) <= tft.width() && ( mcu_y + win_h ) <= tft.height()){tft.pushRect(mcu_x, mcu_y, win_w, win_h, pImg);}else if ( (mcu_y + win_h) >= tft.height()) JpegDec.abort(); // Image has run off bottom of screen so abort decoding}
}void setup() //屏幕初始化
{Serial.begin(115200);tft.begin();tft.setRotation(0);tft.fillScreen(TFT_GREEN);//初始化屏幕颜色大写
}void loop()//展示图片和时间间隔
{tft.pushImage(0, 0, 240, 240, (uint16_t*)gImage_demo_image1);delay(1000);tft.pushImage(0, 0, 240, 240, (uint16_t*)gImage_demo_image2);delay(1000);tft.pushImage(0, 0, 240, 240, (uint16_t*)gImage_demo_image3);delay(1000);tft.pushImage(0, 0, 240, 240, (uint16_t*)gImage_demo_image4);delay(1000);}

效果图

图片来源 永劫无间 官网,此处仅做效果图,没有版权所有,所以我给他打码了

以上代码是简化过的,所有//后的都可以删掉,代码共四部分 第一部分声明库和文件头,第二部分处理图像数组进行绘制图像,第三部分初始化屏幕,第四部分输出循环,简化的原因,原参考的博文源代码有一丢丢小问题,编译不通过,还有就是那个是通配几种开发板,新手不友好

老规矩 上源原文,详细但不太新手友好,想深入研究的可以好好钻研下完整的Arduino应用开发——LCD显示图片_柒壹漆的博客-CSDN博客_arduino显示屏显示图片LCD是项目中比较常用的外设,基于Arduino开发有个好处就是它很多相关的库可用,这对于项目的开发或者前期的方案验证来说是非常方便的,缺点是灵活性较差。Arduino支持很多硬件,我们这一讲主要基于ESP8266和ESP32来讲解图片的显示。https://blog.csdn.net/ShenZhen_zixian/article/details/122682500

最后感谢这位老哥的例程,虽然有小错误但是帮我知道怎么让LCD显示图了

自学需要持之以恒,加油 各位爱好者

0.1.3-01 合宙CORE-ESP32-C3制作1.3寸ST7789驱动的简单相册相关推荐

  1. X、合宙Air模块Luat开发:全网首发,通过iic直接驱动OLED,720Sl开始有显时代

    目录 点击这里查看所有博文   本系列博客,理论上适用于合宙的Air202.Air268.Air720x.Air720S以及最近发布的Air720U(我还没拿到样机,应该也能支持).   先不管支不支 ...

  2. 含税9.9元包邮——合宙ESP32-C3核心板来了

    当ESP32遇上LuatOS,会产生怎样奇妙的火花?--工程师朋友们呼声极高的CORE ESP32-C3核心板来了. 工程师需要,合宙造!适配越来越多的CPU支持LuatOS,敬请期待! 合宙ESP3 ...

  3. Esp32 C3 Arduino 串口开发(1)

    网上合宙的esp32 C3 的测试版 9.9元,简洁小巧,用于学习测试非常方便.原来是装的Luatos,可以直接用Arduino开发.Arduino安装的为最新版 V2.00RC8,有点类似 vSco ...

  4. 005.Python制作客户端截屏通过合宙ESP32-C3投屏到0.96OLED

    Python制作客户端截屏通过ESP32-C3投屏到0.96'OLED 一.实现原理 Python对屏幕进行截屏,并进行数据处理 Python与ESP32-C3通过WIFI建立tcp连接 Python ...

  5. 0.1.3 合宙CORE-ESP32-C3开发板用arduino点亮ST7735 1.8寸TFT屏【已更新失效链接2022.07.10】

    9.9的ESP32开发板想用arduino开发,无奈都是用luatos玩,于是折腾了下 目的 用arduino驱动合宙ESP32-C3开发板点亮S7735TFT屏 材料 CORE-ESP32-C3开发 ...

  6. Arduino框架下ESP32+合宙1.54“ 电子墨水屏(e-paper)驱动显示示例

    Arduino框架下ESP32+合宙1.54" 电子墨水屏(e-paper)驱动显示示例 显示效果展示; 合宙1.54" 电子墨水屏 有关合宙1.54"电子墨水屏的介绍资 ...

  7. 合宙esp32 环境搭建和使用方法

    文章目录 1.环境搭建 2.问题 2-1:exec: "cmd": executable file not found in %PATH% 3.合宙esp32 使用 3-1引脚定义 ...

  8. 合宙esp32+显示屏测试

    1.开发板 合宙esp32 c3,主频160mhz. 2.显示屏 合宙0.96寸lcd,驱动为st7735. 3.代码 这是开发板的定义,如果要修改开发板则需要去示例程序PDQ graphicstes ...

  9. 003.0.96‘OLED+合宙ESP32C3+和风天气预报

    合宙ESP32-C3+OLED天气预报 一.搭建开发框架 使用VScode platformio开发 1.oled显示 #include <Arduino.h> #include < ...

最新文章

  1. 华南师范大学计算机学院拟录取,华南师范大学各学院2015年硕士拟录取名单公示...
  2. Symantec Backup Exec 2012 Agent For Linux安装
  3. js 正则学习小记之匹配字符串
  4. 将一个项目中已有的文档添加到另一个项目中的方法
  5. 互联网时代的应用设计,互联网营销
  6. php hmac sha256签名,HMAC-SHA256签名错误?
  7. 缓存,你真的用对了么?
  8. android viewflipper图片轮播,android开发:ViewFlipper实现图片轮播
  9. 如何将tomcat默认页面换成项目首页?
  10. 傻瓜神经网络入门指南
  11. PHP Opcache(ZendOptimizerPlus)的安装配置详解
  12. 几种类型的db,以及最新的db排名,看一下
  13. 在cmd中对Python的一些操作(查版本,下载包等)
  14. 内存优化——使用pandas读取千万级数据
  15. xcode清理缓存瘦身方法整理
  16. 干货!交换机常用的光模块及光接口
  17. H3C光模块专题笔记
  18. 计算机网络:非持久HTTP连接 VS 持久性HTTP 连接
  19. python的ide编辑器_python轻量IDE编辑器 pyscripter 免费开源 更新3.6.3版本
  20. POSIX是什么?解决了什么问题?

热门文章

  1. 1309460-27-2,Ald-Ph-PEG4-acid苯甲醛基与酰肼和氨基氧基
  2. 物联网到底为什么这么火?
  3. Android Studio 4.0 Image Asset 图标不能透明(记录)
  4. android 三星 蓝牙sco,android – 来电后蓝牙SCO失败
  5. asp毕业设计——基于asp+access的学生排课管理系统设计与实现(毕业论文+程序源码)——学生排课管理系统
  6. web端与移动端高德地图接入及实例化
  7. qq邮箱993服务器地址,ios邮箱绑定qq邮箱提示993服务器连接超时
  8. 计算机word快捷方式,右键-新建-WORD等快捷方式丢失了怎么找回?
  9. Nginx快速入门(三)正向代理、HTTP服务器与动静分离
  10. android 瀑布流 github,GitHub - youxilua/waterfall4android: android瀑布流