TFT_eSPI 库使用中遇到的坑

介绍

本文主要是记录学习使用 ESP32 驱动3.5寸屏I(驱动芯片LI9488)时 遇到的问题和解决方法。

问题1

使用arduino 编译带触摸函数的例子总报错,找不到相应的函数。经过研究TFT_eSPI 的文件包含结构才发现设置自己设置错了。

程序结构入下:

1,arduino.ino 程序中 会 #include <TFT_eSPI.h> ,这样编译的时候,编译软件会去对用的库中找到TFT_eSPI.h 并将整个文件copy  并合并到 arduino.ino 原程序中。

2,打开 TFT_eSPI.h 文件,发现 #include <User_Setup_Select.h> , 表示  TFT_eSPI.h 中把

 User_Setup_Select.h 这个文件包含进来。为此,我们进入User_Setup_Select.h 查看

3,打开 User_Setup_Select.h 文件,这个文件是让你选择使用哪个文件进行tft 显示屏的驱动配置

文件进行设置。如果 要 使用 User_Setup.h 进行通用设置,那就需要将 // #include <User_Setup.h>  前面的两个取消掉,并到 User_Setup.h 进行设置对应的管脚等。

如果你 取消了#include <User_Setups/Setup21_ILI9488.h>  的注释, 则需要到文件夹 User_Setups 下面的 Setup21_ILI9488.h 中进行设置相关的配置。

我这里选择了

#include <User_Setups/Setup21_ILI9488.h> ,由于 User_Setups/Setup21_ILI9488.h 中 没有以下语句  “”#define TOUCH_CS 21“”     // Chip select pin (T_CS) of touch screen

我犯的低级错误就是#include <User_Setups/Setup21_ILI9488.h> ,但包含的库中没有#define TOUCH_CS 21, 我想当然的去 User_Setup.h 中设置触摸的 片选管脚 

#define TOUCH_CS 21     // Chip select pin (T_CS) of touch screen

导致带有触摸的例子报错无法编译通过(因为User_Setup_Select.h 根本没有#include <User_Setup.h>)。为此,只要在 Setup21_ILI9488.h 加入以下宏定义并设置相应管脚即可

TOUCH_CS 21, 我想当然的去 User_Setup.h 中设置触摸的 片选管脚 

///
//   User configuration selection lines are below    //
///

// Only ONE line below should be uncommented to define your setup.  Add extra lines and files as needed.

//#include <User_Setup.h>           // Default setup is root library folder

//#include <User_Setups/Setup1_ILI9341.h>  // Setup file for ESP8266 configured for my ILI9341
//#include <User_Setups/Setup2_ST7735.h>   // Setup file for ESP8266 configured for my ST7735
//#include <User_Setups/Setup3_ILI9163.h>  // Setup file for ESP8266 configured for my ILI9163
//#include <User_Setups/Setup4_S6D02A1.h>  // Setup file for ESP8266 configured for my S6D02A1
//#include <User_Setups/Setup5_RPi_ILI9486.h>        // Setup file for ESP8266 configured for my stock RPi TFT
//#include <User_Setups/Setup6_RPi_Wr_ILI9486.h>     // Setup file for ESP8266 configured for my modified RPi TFT
//#include <User_Setups/Setup7_ST7735_128x128.h>     // Setup file for ESP8266 configured for my ST7735 128x128 display
//#include <User_Setups/Setup8_ILI9163_128x128.h>    // Setup file for ESP8266 configured for my ILI9163 128x128 display
//#include <User_Setups/Setup9_ST7735_Overlap.h>     // Setup file for ESP8266 configured for my ST7735
//#include <User_Setups/Setup10_RPi_touch_ILI9486.h> // Setup file for ESP8266 configured for ESP8266 and RPi TFT with touch

//#include <User_Setups/Setup11_RPi_touch_ILI9486.h> // Setup file configured for ESP32 and RPi TFT with touch
//#include <User_Setups/Setup12_M5Stack_Basic_Core.h>// Setup file for the ESP32 based M5Stack (Basic Core only)
//#include <User_Setups/Setup13_ILI9481_Parallel.h>  // Setup file for the ESP32 with parallel bus TFT
//#include <User_Setups/Setup14_ILI9341_Parallel.h>  // Setup file for the ESP32 with parallel bus TFT
//#include <User_Setups/Setup15_HX8357D.h>           // Setup file for ESP8266 configured for HX8357D
//#include <User_Setups/Setup16_ILI9488_Parallel.h>  // Setup file for the ESP32 with parallel bus TFT
//#include <User_Setups/Setup17_ePaper.h>            // Setup file for ESP8266 and any Waveshare ePaper display
//#include <User_Setups/Setup18_ST7789.h>            // Setup file for ESP8266 configured for ST7789

//#include <User_Setups/Setup19_RM68140_Parallel.h>	 // Setup file configured for RM68140 with parallel bus

//#include <User_Setups/Setup20_ILI9488.h>           // Setup file for ESP8266 and ILI9488 SPI bus TFT
#include <User_Setups/Setup21_ILI9488.h>           // Setup file for ESP32 and ILI9488 SPI bus TFT

//#include <User_Setups/Setup22_TTGO_T4.h>           // Setup file for ESP32 and TTGO T4 version 1.2
//#include <User_Setups/Setup22_TTGO_T4_v1.3.h>      // Setup file for ESP32 and TTGO T4 version 1.3
//#include <User_Setups/Setup23_TTGO_TM.h>           // Setup file for ESP32 and TTGO TM ST7789 SPI bus TFT
//#include <User_Setups/Setup24_ST7789.h>            // Setup file for DSTIKE/ESP32/ESP8266 configured for ST7789 240 x 240
//#include <User_Setups/Setup25_TTGO_T_Display.h>    // Setup file for ESP32 and TTGO T-Display ST7789V SPI bus TFT
//#include <User_Setups/Setup26_TTGO_T_Wristband.h>  // Setup file for ESP32 and TTGO T-Wristband ST7735 SPI bus TFT

问题2

触屏功能无法使用。

User_Setups/Setup21_ILI9488.h 中 明显标注,如果多个设备使用MISO,(显示和触摸都使用了),

需要将显示的MISO 断开

#define TFT_MISO 19 // (leave TFT SDO disconnected if other SPI devices share MISO)

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
tft_espi是一种用于控制液晶显示屏的,它的全称是“Thin Film Transistor Enhanced Super Fine Picture”,也就是“薄膜晶体管增强超细图像”。tft_espi可以在各种嵌入式系统使用,实现对液晶显示屏的控制和输出。 使用tft_espi可以实现对液晶显示屏的图像和文本等内容进行输出。通过该,我们可以设置显示屏的分辨率、亮度、背光等参数,并在显示屏上绘制各种图形和文字。这使得我们可以在嵌入式系统轻松地实现复杂的用户界面和图形显示。 tft_espi支持文显示。我们可以通过设置相应的字体和字符编码来显示文。可以使用Unicode编码或其他文字符集来呈现文字符。当在液晶显示屏上显示文时,我们可以选择适当的字体大小和风格,以确保文字清晰可辨,满足用户需求。 tft_espi在实现文显示时需要一些额外的设置。首先,我们需要为文字符选择正确的字体文件,并将其加载到嵌入式系统。其次,我们需要根据液晶显示屏的分辨率和像素密度来调整字符的显示大小和位置,保证文字符能够完整且清晰地显示。另外,我们还可以通过调整背光亮度等参数来改善文显示效果。 总之,tft_espi是一种方便易用的,可用于控制液晶显示屏并实现文显示。通过使用,我们可以在各种嵌入式系统轻松地实现文显示,并为用户提供良好的用户界面和图形显示体验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值