ESP32 – Display 320x240px
Testaufbau
Beschreibung
Dieses Projekt stellt einen Text auf einem Display von 320x240px, auf der Basis des Controllers ILI9341, mit einer SPI-Schnittstelle. Als Controller kommt ein AZ Delivery ESP32S Dev Kit C zum Einsatz. Die verwendete Library ist TFT_eSPI von Bodmer, in der Version 2.5.43.
Hardware
Die Hardware ist ein ESP32 mit einem 2,8 Zoll LCD TFT Touch Display, basierend auf dem Controller ILI9341.
- AZ Delivery ESP32S Dev Kit C
- Display ILI9341-320x240px SPI
Schaltplan
Pin Bez. ESP32 Pin
-------------------------------
1 = VCC = 3,3V
2 = GND = GND
3 = CS = GPIO15
4 = RESET = GPIO4
5 = DC = GPIO2
6 = SDA = GPIO19
7 = SDI = GPIO23
8 = LED = 3,3V
9 = SDO
10 = T_CLK = GPIO18
11 = T_CS = GPIO21
12 = T_DIN = GPIO23
13 = T_DO = GPIO19
14 = T_IRQ
Software
Library: TFT_eSPI
Pfad unter Windows: C:\Users\….\Documents\Arduino\libraries\TFT_eSPI\User_Setup.h
Die markierten Zeilen sind auszukommentieren, 45, 88, 92, 212-217
// Display type - only define if RPi display
//#define RPI_DISPLAY_TYPE // 20MHz maximum SPI
// 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 TFT_WIDTH 170 // ST7789 170 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
// For ESP32 Dev board (only tested with ILI9341 display)
// The hardware SPI can be mapped to any pins
#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_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RS
Programm Code
#include <TFT_eSPI.h> // Library für ILI9341 Controller
TFT_eSPI tft = TFT_eSPI(); // Library init
void setup(void) {
tft.init();
tft.setRotation(2);
tft.setTextSize(3); // Grosse Schrift
tft.fillScreen(TFT_BLACK); // Schwarzer Hintergrund
tft.setTextColor(TFT_WHITE, TFT_BLACK); // Weisse Schrift, Schwarzer Hintergrund
tft.drawString("Hello World!", 0, 0, 2); // Text ausgeben
}
void loop() {
delay(1000);
}
Andere ESP32 Beiträge: ESP32 – Entfernungsmesser,