ESP32 S3 et TFT 2,8 pouces ILI9341 Tactile

Bonjour,

Après avoir testé mon écran tft avec succès sur un arduino uno:
https://forum.arduino.cc/t/probleme-tft-2-8-ili9341-spi-uno/13669081

Je voudrais maintenant le brancher sur un ESP32 S3 Wroom1, dans le but d'en faire une "télécommande" tactile pour piloter un autre ESP32 par wifi.

Je désire utiliset la bibliothèque TFT_eSPI de bodmer. Je me pose quelques questions... Concernant le choix des pins sur l'ESP32, je peux les définir comme je veux dans la configuration de la librairie?

J'ai fait un test vite fait en suivant ce tuto:

Le sketch tourne normalement mais je n'ai qu'un écran blanc pour l'instant.

Avez-vous des conseils ou des recommandations pour mener à bien mon projet?

La carte ESP32:


L'écran tft 2,8 pouces ili9341:

Regardes l'exemple Setup70h_ESP32_S3_GC9A01.h c'est un bon point de départ je pense.

Merci je vais tester. :slight_smile:

Par contre, je lis sur le net que le driver gc901 est utilisé pour les écrans carrés ou rond de maximum 240x240... Mon écran fait 240x320, cela ne pose pas de problèmes?

Je dois seulement modifier la résolution dans le code ?

#define USER_SETUP_ID 70

#define GC9A01_DRIVER

#define TFT_WIDTH  240
#define TFT_HEIGHT 240 // je remplace 240 par 320?
                    // Typical board default pins - change to match your board
#define TFT_CS   10 //34 //     10 or 34 (FSPI CS0) 
#define TFT_MOSI 11 //35 //     11 or 35 (FSPI D)
#define TFT_SCLK 12 //36 //     12 or 36 (FSPI CLK)
#define TFT_MISO 13 //37 //     13 or 37 (FSPI Q)

// Use pins in range 0-31
#define TFT_DC    7
#define TFT_RST   6

#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 (SPI2) used unless following defined
#define USE_HSPI_PORT

#define SPI_FREQUENCY  80000000   // Maximum for ILI9341
saisissez ou collez du code ici

Ma suggestion concernait uniquement les paramètres pour le SPI.
On voit qu'il ne propose que 2 jeux de pins pour le SPI.
Pour le reste, il faut bien sur utiliser les paramètres de ton écran.

à l'aide de ESP32-S3-DevKitC-1 pour piloter un HiLetgo 240X320 Résolution 2.8" SPI TFT LCD Écran Tactile ILI9341 j'ai utilisé le code suivant

TFT_Print_Test.ino

// ESP32 TFT_eSPI library  example TFT_Print_Test


// 5Volt power to display VCC if J1 is open
// LED to 3.3V

/*  
 Test the tft.print() viz. the libraries embedded write() function

 This sketch used font 2, 4, 7
 
 Make sure all the required fonts are loaded by editing the
 User_Setup.h file in the TFT_eSPI library folder.

  #########################################################################
  ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
  #########################################################################
 */

#include <SPI.h>

#include <TFT_eSPI.h> // Hardware-specific library


TFT_eSPI tft = TFT_eSPI();       // Invoke custom library

#define TFT_GREY 0x5AEB // New colour


void setup(void) {
  //uint16_t ID = tft.readID();
  Serial.begin(115200);
  delay(2000);
  Serial.println("\n\nESP32 TFT_eSPI library  example TFT_Print_Test");
  //Serial.println(ID);
  tft.init();
  tft.setRotation(2);
}

void loop() {
  
  // Fill screen with random colour so we can see the effect of printing with and without 
  // a background colour defined
  tft.fillScreen(random(0xFFFF));
  
  // Set "cursor" at top left corner of display (0,0) and select font 2
  // (cursor will move to next line automatically during printing with 'tft.println'
  //  or stay on the line is there is room for the text with tft.print)
  tft.setCursor(0, 0, 2);
  // Set the font colour to be white with a black background, set text size multiplier to 1
  tft.setTextColor(TFT_WHITE,TFT_BLACK);  tft.setTextSize(1);
  // We can now plot text on screen using the "print" class
  tft.println("Hello World!");
  
  // Set the font colour to be yellow with no background, set to font 7
  tft.setTextColor(TFT_YELLOW); tft.setTextFont(7);
  tft.println(1234.56);
  
  // Set the font colour to be red with black background, set to font 4
  tft.setTextColor(TFT_RED,TFT_BLACK);    tft.setTextFont(4);
  tft.println((long)3735928559, HEX); // Should print DEADBEEF

  // Set the font colour to be green with black background, set to font 4
  tft.setTextColor(TFT_GREEN,TFT_BLACK);
  tft.setTextFont(4);
  tft.println("Groop");
  tft.println("I implore thee,");

  // Change to font 2
  tft.setTextFont(2);
  tft.println(F("my foonting turlingdromes.")); // Can store strings in FLASH to save RAM
  tft.println("And hooptiously drangle me");
  tft.println("with crinkly bindlewurdles,");
  // This next line is deliberately made too long for the display width to test
  // automatic text wrapping onto the next line
  tft.println("Or I will rend thee in the gobberwarts with my blurglecruncheon, see if I don't!");
  
  // Test some print formatting functions
  float fnumber = 123.45;
   // Set the font colour to be blue with no background, set to font 4
  tft.setTextColor(TFT_BLUE);    tft.setTextFont(4);
  tft.print("Float = "); tft.println(fnumber);           // Print floating point number
  tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary
  tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal
  delay(10000);
}




User_Setup.h fichier dans le même répertoire que le fichier.ino ci-dessus

// TFT_eSPI setup.h file for ESP32-S3-DevKitC-1
// HiLetgo 240X320 Resolution 2.8" SPI TFT LCD Display Touch Panel ILI9341 

#define USER_SETUP_INFO "User_Setup"

#define ILI9341_DRIVER

// For ST7735, ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
// Try ONE option at a time to find the correct colour order for your display
//  #define TFT_RGB_ORDER TFT_RGB  // Colour order Red-Green-Blue
//  #define TFT_RGB_ORDER TFT_BGR  // Colour order Blue-Green-Red

// For ST7789, ST7735, ILI9163 and GC9A01 ONLY, define the pixel width and height in portrait orientation
#define TFT_WIDTH  240 // ST7789 240 x 240 and 240 x 320
#define TFT_HEIGHT 320 // ST7789 240 x 320

// If colours are inverted (white shows as black) then uncomment one of the next
// 2 lines try both options, one of the options should correct the inversion.

// #define TFT_INVERSION_ON
// #define TFT_INVERSION_OFF

#define TFT_CS   10//SS     // 10 
#define TFT_MOSI MOSI   // 11
#define TFT_SCLK SCK    // 12
#define TFT_MISO MISO   // 13

#define TFT_DC   9
#define TFT_RST  3

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

#define SMOOTH_FONT

#define SPI_FREQUENCY   10000000

#define SPI_TOUCH_FREQUENCY  2500000



photo

@fdufnews nAh oui... J'avais mal compris. :slight_smile:
Dans la doc du esp32 S3, j'ai vu qu'il y avait 4 SPI matériel. Deux reservés pour la mémoire flash et deux de libre.

@horace Merci :slight_smile: Je teste dès que je suis sur PC et je fais un retour.