一、運行環(huán)境:
? 操作系統(tǒng):windows 10 x64
? IDE:Arduino1.8.15
? 運行庫1:TFT_eSPI
? 運行庫2:ESP8266
? 開發(fā)板硬件:ESP8266-CH340
?,?ST7789-240*240-TFT顯示屏
二、引腳接線#
ESP8266 | ST7789 | 備注 |
---|---|---|
G | GND | |
3V | VCC | |
D5 | SCL | |
D7 | SDA | |
D4 | RES | |
D3 | DC |
三、安裝TFT_eSPI運行庫#
3-1 安裝庫#
打開Arduino,進入:工具
-- >?管理庫...
,搜索:TFT_eSPI
,選擇版本,點擊安裝
下圖為已完成安裝

3-2 修改頭文件代碼#
由于本次使用的ST7789TFT顯示屏,需要對頭文件?User_Setup.h
進行修改,該文件在Arduino\libraries\TFT_eSPI
目錄下
那么Arduino目錄
在哪里呢?其實打開首選項就能看到,如下圖

User_Setup.h 修改位置有三處:
? 第一處
保留:#define ST7789_DRIVER
?即可
// Only define one driver, the other ones must be commented out
//#define ILI9341_DRIVER // Generic driver for common displays
//#define ILI9341_2_DRIVER // Alternative ILI9341 driver, see https://github.com/Bodmer/TFT_eSPI/issues/1172
//#define ST7735_DRIVER // Define additional parameters below for this display
//#define ILI9163_DRIVER // Define additional parameters below for this display
//#define S6D02A1_DRIVER
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
//#define HX8357D_DRIVER
//#define ILI9481_DRIVER
//#define ILI9486_DRIVER
//#define ILI9488_DRIVER // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
#define ST7789_DRIVER // Full configuration option, define additional parameters below for this display
//#define ST7789_2_DRIVER // Minimal configuration option, define additional parameters below for this display
//#define R61581_DRIVER
//#define RM68140_DRIVER
//#define ST7796_DRIVER
//#define SSD1351_DRIVER
//#define SSD1963_480_DRIVER
//#define SSD1963_800_DRIVER
//#define SSD1963_800ALT_DRIVER
//#define ILI9225_DRIVER
//#define GC9A01_DRIVER
? 第二處
ST7789使用屏幕尺寸為:240*240,故保留:#define TFT_WIDTH 240
?和?#define TFT_HEIGHT 240 // ST7789 240 x 240
// For ST7789, ST7735, ILI9163 and GC9A01 ONLY, define the pixel width and height in portrait orientation
// #define TFT_WIDTH 80
// #define TFT_WIDTH 128
// #define TFT_WIDTH 172 // ST7789 172 x 320
#define TFT_WIDTH 240 // ST7789 240 x 240 and 240 x 320
// #define TFT_HEIGHT 160
// #define TFT_HEIGHT 128
#define TFT_HEIGHT 240 // ST7789 240 x 240
// #define TFT_HEIGHT 320 // ST7789 240 x 320
// #define TFT_HEIGHT 240 // GC9A01 240 x 240
? 第三處
保留:#define TFT_DC PIN_D3
?和?#define TFT_RST PIN_D4
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP8266 SETUP ######
// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
//#define TFT_CS PIN_D8 // Chip select control pin D8
#define TFT_DC PIN_D3 // Data Command control pin
#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
//#define TFT_BL PIN_D1 // LED back-light (only for ST7789 with backlight control pin)
//#define TOUCH_CS PIN_D2 // Chip select pin (T_CS) of touch screen
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
四、編譯、燒寫范例到ESP8266#
4-1 編譯、燒錄#
在 工具-->開發(fā)板中選擇:NodeMCU 1.0 (ESP 12E Module) 和 開發(fā)板與電腦連接的端口號(樓主這里是COM3,換臺電腦COM口可能不一致)
打開示例:Color_Test

編譯、燒錄到ESP8266

4-2 驗證結(jié)果#
?文章來源:http://www.zghlxwxcb.cn/news/detail-737342.html
?文章來源地址http://www.zghlxwxcb.cn/news/detail-737342.html
到了這里,關(guān)于ESP8266+TFT顯示屏(ST7789 240*240)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!