介绍
本文主要是记录学习使用 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)