Adsense HTML/JavaScript

Tuesday, April 26, 2022

ESP32-S2 (arduino-esp32) display on ILI9341 SPI TFT with Touch, using TFT_eSPI Library.

TFT_eSPI is a Arduino and PlatformIO IDE compatible TFT library optimized for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips.

Connection:


ILI9488
-------
1  - VCC	VCC
2  - GND	GND
3  - CS		34
4  - RESET	38
5  - DC		39
6  - SDI(MOSI)	35
7  - SCK	36
8  - LED	VCC
9  - SDO (MISO)	37
10 - T_CLK	(SCK)
11 - T_CS	40
12 - T_DIN	(MOSI)
13 - T_DO	(MISO)
14 - T_IRQ	no connection
In arduino-esp32, the default pins of ESP32S2 Dev Module for SPI are:
Default SS:         34
Default MOSI:    35
Default MISO:    37
Default SCK:      36

In TFT_eSPI, the SPI bus for the touch controller is shared with the TFT and only an additional chip select line is needed.

Setup TFT_eSPI Library:

This video show how to setup TFT_eSPI library in Arduino IDE, tested on ESP32-S2-Saola-1, with 2.4inch SPI Module ILI9341 SKU:MSP2402 with Touch.


Refer to "Tips" section in the TFT_eSPI page:

If you load a new copy of TFT_eSPI then it will overwrite your setups if they are kept within the TFT_eSPI folder. One way around this is to create a new folder in your Arduino library folder called "TFT_eSPI_Setups". You then place your custom setup.h files in there. After an upgrade simply edit the User_Setup_Select.h file to point to your custom setup file.

You can take this one step further and have your own setup select file and then you only need to replace the Setup.h line reference in User_Setup_Select.h to.

mySetup70_ESP32_S2_ILI9341.h, my custom setup.h for ESP32-S2 using ILI9341.
// Setup for the ESP32 S2 with ILI9341 display
// Note SPI DMA with ESP32 S2 is not currently supported
#define USER_SETUP_ID 70
// See SetupX_Template.h for all options available
#define ILI9341_DRIVER
/*
                    // Typical board default pins
#define TFT_CS   10 //     10 or 34

#define TFT_MOSI 11 //     11 or 35
#define TFT_SCLK 12 //     12 or 36
#define TFT_MISO 13 //     13 or 37

#define TFT_DC   14
#define TFT_RST  15
*/
#define TFT_MISO 37
#define TFT_MOSI 35
#define TFT_SCLK 36
#define TFT_CS   34
#define TFT_DC   39
#define TFT_RST  38

//#define TOUCH_CS 16 // Optional for touch screen
#define TOUCH_CS 40


#define LOAD_GLCD
#define LOAD_FONT2
#define LOAD_FONT4
#define LOAD_FONT6
#define LOAD_FONT7
#define LOAD_FONT8
#define LOAD_GFXFF

#define SMOOTH_FONT

// FSPI port will be used unless the following is defined
#define USE_HSPI_PORT

//#define SPI_FREQUENCY  27000000
#define SPI_FREQUENCY  40000000   // Maximum for ILI9341

#define SPI_READ_FREQUENCY  6000000 // 6 MHz is the maximum SPI read speed for the ST7789V

#define SPI_TOUCH_FREQUENCY 2500000


Updated User_Setup_Select.h.
// This header file contains a list of user setup files and defines which one the
// compiler uses when the IDE performs a Verify/Compile or Upload.
//
// Users can create configurations for different Espressif boards and TFT displays.
// This makes selecting between hardware setups easy by "uncommenting" one line.

// The advantage of this hardware configuration method is that the examples provided
// with the library should work with different setups immediately without any other
// changes being needed. It also improves the portability of users sketches to other
// hardware configurations and compatible libraries.
//
// Create a shortcut to this file on your desktop to permit quick access for editing.
// Re-compile and upload after making and saving any changes to this file.

// Customised User_Setup files are stored in the "User_Setups" folder.

#ifndef USER_SETUP_LOADED //  Lets PlatformIO users define settings in
                          //  platformio.ini, see notes in "Tools" folder.

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

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

//...




No comments:

Post a Comment