arduino中TFT_ILI9341触摸屏使用TFT_eSPI库的学习LVGL笔记

1 篇文章 0 订阅
1 篇文章 0 订阅

1.TFT_eSPI\User_Setup.h 配置

#define ILI9341_DRIVER       // Generic driver for common displays
// For ESP32 Dev board (only tested with ILI9341 display)
// The hardware SPI can be mapped to any pins

// #define M5STACK  //这个不要使用 会显示镜像

#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS   15  // Chip select control pin
#define TFT_DC    2  // Data Command control pin
#define TFT_RST   4  // Reset pin (could connect to RST pin)
#define TFT_BL   22  // LED back-light 这个引脚要接高电平,或在代码中置高电平 否则黑屏不显示
#define TOUCH_CS 21  // Chip select pin (T_CS) of touch screen 有触摸屏时这个要设置


#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts

// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
// this will save ~20kbytes of FLASH
#define SMOOTH_FONT


#define SPI_FREQUENCY  27000000


// Optional reduced SPI frequency for reading TFT
#define SPI_READ_FREQUENCY  20000000

// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
#define SPI_TOUCH_FREQUENCY  2500000



2.触摸屏和显示座标不一致的可能问题解决

a.如果使用触摸屏 在使用或更换tft.setRotation(X);设置时,必先校正触摸屏

校正触摸屏方法:

1打开.pio\libdeps\esp32dev\TFT_eSPI\examples\Generic\Touch_calibrate\Touch_calibrate.ino

2.在setup()中运行其中的  touch_calibrate();按提示箭头点击就可校正屏幕,然后就会得到类似

 uint16_t calData[5] = { 286, 3534, 283, 3600, 6 };

  tft.setTouch(calData);

把上面代码放在setup()中.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值