Écran TFT ST7789 + ESP32

Bonjour

J'ai acheté un ecran TFT 3.2p driver ST7789


Je veux l'utiliser avec une carte esp32 (ESP32 DEV Module)
image
J'ai essayé des exemples sans même réussir a allumer la carte
Je suis actuellement sur le code le plus simple que j'ai trouvé sur le forum, mais rien de rien ne s'affiche....., pourriez vous m'orienter pour au moins réussir a allumer l'écran et afficher Hello!! ça me donnerai un peu de jus pour continuer car je voudrais créer un menu de choix sur l'écran tactile et ça commence mal

[code]
#include <SPI.h>
#include <TFT_eSPI.h>       // Include the graphics library
#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 RST


#define TFT_WIDTH 320
#define TFT_HEIGHT 240
TFT_eSPI tft = TFT_eSPI(TFT_WIDTH, TFT_HEIGHT);

void setup(void) {
  tft.init();
  tft.fillScreen(TFT_BLUE);
}

void loop()
{
}
[/code]

Trouvez une bibliothèque adaptée au chipset de l’écran

Peut être GitHub - adafruit/Adafruit-ST7735-Library: This is a library for the Adafruit 1.8" SPI display http://www.adafruit.com/products/358 and http://www.adafruit.com/products/618

Ou bien, les les instructions sur ce site

un tft 3.2" de 240x320 n'est PAS a chipset st7789

la lib tft eSPI est celle de bodmer ? pour les 7789 ???

Oui, elle est compatible de ce driver. Dans le fichier setup, tu trouves les connexions suggérées :

// Generic ESP32 setup
//#define TFT_MISO 19
//#define TFT_MOSI 23
//#define TFT_SCLK 18
//#define TFT_CS    -1 // Not connected
//#define TFT_DC    2
//#define TFT_RST   4  // Connect reset to ensure display initialises

Mais si ce n'est pas le bon driver, il faut savoir lequel est le bon...
Ca peut être un ILI9341 : TFT_eSPI est aussi compatible

Merci pour les pistes
ENFIN , j'ai trouvé une config qui fonctionne pour l'affichage


Avec le code joint cela donne ça (c'est pas le top du design mais c'est un début)
image
Pour le tactile, je ne comprends pas comment me connecter avec TouchScreen, je suis preneur d'un exemple basique

[code]
/**************************************************************************
  This is a library for several Adafruit displays based on ST77* drivers.

  This example works with the 1.14" TFT breakout
    ----> https://www.adafruit.com/product/4383
  The 1.3" TFT breakout
    ----> https://www.adafruit.com/product/4313
  The 1.47" TFT breakout
    ----> https://www.adafruit.com/product/5393
  The 1.54" TFT breakout
    ----> https://www.adafruit.com/product/3787
  The 1.69" TFT breakout
    ----> https://www.adafruit.com/product/5206
  The 1.9" TFT breakout
    ----> https://www.adafruit.com/product/5394
  The 2.0" TFT breakout
    ----> https://www.adafruit.com/product/4311


  Check out the links above for our tutorials and wiring diagrams.
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional).

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 **************************************************************************/

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
//#include <TouchScreen.h>
//Pour ESP32
  #define TFT_CS         5
  #define TFT_RST        15
  #define TFT_DC         32



// OPTION 1 (recommended) is to use the HARDWARE SPI pins, which are unique
// to each board and not reassignable. For Arduino Uno: MOSI = pin 11 and
// SCLK = pin 13. This is the fastest mode of operation and is required if
// using the breakout board's microSD card.

Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);



void setup(void) {
  Serial.begin(9600);
  Serial.print(F("Hello! ST77xx TFT Test"));

  

  // OR use this initializer (uncomment) if using a 2.0" 320x240 TFT:
  tft.init(240, 320);           // Init ST7789 320x240

 

  // SPI speed defaults to SPI_DEFAULT_FREQ defined in the library, you can override it here
  // Note that speed allowable depends on chip and quality of wiring, if you go too fast, you
  // may end up with a black screen some times, or all the time.
  //tft.setSPISpeed(40000000);
  Serial.println(F("Initialized"));

  uint16_t time = millis();
  tft.fillScreen(ST77XX_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);

  
  tft.invertDisplay(false);
  delay(500);
  tft.fillScreen(ST77XX_BLACK);
  //Titre
     tft.setCursor(25, 0);
     tft.setTextColor(ST77XX_WHITE);
     tft.setTextSize(2);
     tft.setTextWrap(true);
     tft.print("CHOISIR CASIER");

  //Bouton1
     tft.fillRoundRect(6, 30, 70, 60, 10,ST77XX_BLUE );
     tft.setCursor(32,47);
     tft.setTextSize(3);
     tft.print("1");
     
   //Bouton2
     tft.fillRoundRect(86, 30, 70, 60, 10,ST77XX_YELLOW );
     tft.setCursor(112,47);
     tft.setTextSize(3);
     tft.print("2");
     
   //Bouton3
     tft.fillRoundRect(166, 30, 70, 60, 10,ST77XX_RED );
     tft.setCursor(192,47);
     tft.setTextSize(3);
     tft.print("3");
     
   //Bouton4
     tft.fillRoundRect(6, 100, 70, 60, 10,ST77XX_RED );
     tft.setCursor(32,117);
     tft.setTextSize(3);
     tft.print("4");
     
   //Bouton5
     tft.fillRoundRect(86, 100, 70, 60, 10,ST77XX_GREEN );
     tft.setCursor(112,117);
     tft.setTextSize(3);
     tft.print("5");
     
   //Bouton6
     tft.fillRoundRect(166, 100, 70, 60, 10,ST77XX_MAGENTA );
     tft.setCursor(192,117);
     tft.setTextSize(3);
     tft.print("6");
  
    delay(5000);
}

void loop() {



 
   }  
 

 

[/code]

au temps pour moi : 7789 max 240 (x3 rgb)x320 pixels , st7735 max 132(x3 rgb)x162 pixels , 300 pages datasheet

je teste la biblio tft-espi, avec un ili9341 sur wemos d1, je trouve que le user setup et le
StepupX_Template.h ne sont pas bien clairs ?

setup ili9341.h

// See SetupX_Template.h for all options available
#define USER_SETUP_ID 1  // fait référence a quoi le 1 derriere ID  ?

// ok c'est le numero du setup "driver"

#define ILI9341_DRIVER

//node mcu wemos d1 8266
// MOSI  D7	
// SCK   D5  
// MISO  D6 PAS UTILE POUR TFT



#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

pour le st7789 240x320 sur esp32
en fait on ne fait rien

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

va chercher lui meme le setup driver suivant l'écran connecté ET le board selectionné dans l 'IDE
mais il faut que le tft soit connecté sur les bonnes pins sinon il ne reconnaitra pas le CHIP ID de l'ecran

// Setup for the ESP32 S2 with ST7789 display (copié collé)

// Note SPI DMA with ESP32 S2 is not currently supported
#define USER_SETUP_ID 71
// See SetupX_Template.h for all options available

#define ST7789_DRIVER     // Configure all registers


#define TFT_CS   34 //     10 or 34
#define TFT_MOSI 35 //     11 or 35
#define TFT_SCLK 37 //     12 or 36    !!!!!!  define 37  ? 
#define TFT_MISO 36 //     13 or 37  define 36 

#define TFT_DC   33
#define TFT_RST  -1

dans le SetupX_Template.h et surtout dans le User_Setup.h

//#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

// 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

un blog sur tft+esp32 avec tft_espi

The TFT_eSPI library written by Bodmer is a versatile library that supports a host of microcontrollers and graphical display chips.

bon courage

Apres beaucoup d'essais sans résultats , j'ai acheté un écran driver ILI9341 car je trouvais plus de tutos sur ce modèle
Apres avoir reconfiguré la librairie TFT_eSPI avec le driver ILI9341 Déception, mêmes problèmes qu'avec l'ecran ST7789, impossible de faire fonctionner l'exemple On_Off_Button de la bibliothèque TFT_eSPI
erreur hal/gpio_ll.h: No such file or directory
J'ai trouvé la solution sur ce lien car je n'étais pas le seul a rencontrer ce problème https://github.com/Bodmer/TFT_eSPI/discussions/3048
En fait, la dernière version (2.5.34) ne fonctionne pas pour mon besoin 'ESP32/TFT et en chargeant la version précédente (2.5.33) l'exemple On-Off_Button fonctionne très bien!!
Je joint le User Setup et le User Setup Select tel que je l'ai configuré pour esp32+TFT ILI9341 240x320 ainsi que ceux que j'ai configuré pour ESP32+TFT ST7789 240x320, cela pourra peut être faire gagner beaucoup de temps a des novices comme moi car j'ai galéré et failli abandonner sur ce coup

User Setup ILI9341
User_Setup.h (18,2 Ko)

User Setup Select ILI9341
User_Setup_Select.h (17,0 Ko)

User Setup ST7789
User_Setup.h (18,2 Ko)

User Setup Select ST7789
User_Setup_Select.h (17,0 Ko)

1 Like

Je rajoute le brochage de la carte (même branchement pour les deux drivers)
image

J'ai encore une question: si je veux utiliser la bibliothèque TouchScreen de Adafruit
Quelles sont les correspondances entre les broches de l'écran :T-clc, T-cs, T-DIN, T-DA et YP, XM, YM, XP de la bibliothèque?
Avez vous déjà utilisé cette bibliothèque avec une carte ESP32 ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.