Display BYZESTY ESP32 che rimane nero

Buonasera a tutti, io ho comprato il display BYZESTY ESP32, il Modello è ‎WDY-ESP32Display-ZLBY (ESP32-2432S028). Appena tolto dalla confezione l'ho acceso e funzionava, mostrava i grafici, pulsanti e calendari. Poi ho provato a inserire io un codice ma in seguito è rimasto sempre nero. Ecco il codice che ho caricato sul display:

#include <SPI.h>


#include <TFT_eSPI.h>


#include <XPT2046_Touchscreen.h>

TFT_eSPI tft = TFT_eSPI();

// Touchscreen pins
#define XPT2046_IRQ 36   // T_IRQ
#define XPT2046_MOSI 32  // T_DIN
#define XPT2046_MISO 39  // T_OUT
#define XPT2046_CLK 25   // T_CLK
#define XPT2046_CS 33    // T_CS

SPIClass touchscreenSPI = SPIClass(VSPI);
XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);

#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define FONT_SIZE 2

// Touchscreen coordinates: (x, y) and pressure (z)
int x, y, z;

// Print Touchscreen info about X, Y and Pressure (Z) on the Serial Monitor
void printTouchToSerial(int touchX, int touchY, int touchZ) {
  Serial.print("X = ");
  Serial.print(touchX);
  Serial.print(" | Y = ");
  Serial.print(touchY);
  Serial.print(" | Pressure = ");
  Serial.print(touchZ);
  Serial.println();
}

// Print Touchscreen info about X, Y and Pressure (Z) on the TFT Display
void printTouchToDisplay(int touchX, int touchY, int touchZ) {
  // Clear TFT screen
  tft.fillScreen(TFT_WHITE);
  tft.setTextColor(TFT_BLACK, TFT_WHITE);

  int centerX = SCREEN_WIDTH / 2;
  int textY = 80;
 
  String tempText = "X = " + String(touchX);
  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);

  textY += 20;
  tempText = "Y = " + String(touchY);
  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);

  textY += 20;
  tempText = "Pressure = " + String(touchZ);
  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);
}

void setup() {
  Serial.begin(115200);

  // Start the SPI for the touchscreen and init the touchscreen
  touchscreenSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
  touchscreen.begin(touchscreenSPI);
  // Set the Touchscreen rotation in landscape mode
  // Note: in some displays, the touchscreen might be upside down, so you might need to set the rotation to 3: touchscreen.setRotation(3);
  touchscreen.setRotation(1);

  // Start the tft display
  tft.init();
  // Set the TFT display rotation in landscape mode
  tft.setRotation(1);

  // Clear the screen before writing to it
  tft.fillScreen(TFT_WHITE);
  tft.setTextColor(TFT_BLACK, TFT_WHITE);
  
  // Set X and Y coordinates for center of display
  int centerX = SCREEN_WIDTH / 2;
  int centerY = SCREEN_HEIGHT / 2;

  tft.drawCentreString("Hello, world!", centerX, 30, FONT_SIZE);
  tft.drawCentreString("Touch screen to test", centerX, centerY, FONT_SIZE);
}

void loop() {
  // Checks if Touchscreen was touched, and prints X, Y and Pressure (Z) info on the TFT display and Serial Monitor
  if (touchscreen.tirqTouched() && touchscreen.touched()) {
    // Get Touchscreen points
    TS_Point p = touchscreen.getPoint();
    // Calibrate Touchscreen points with map function to the correct width and height
    x = map(p.x, 200, 3700, 1, SCREEN_WIDTH);
    y = map(p.y, 240, 3800, 1, SCREEN_HEIGHT);
    z = p.z;

    printTouchToSerial(x, y, z);
    printTouchToDisplay(x, y, z);

    delay(100);
  }
}

Le foto del Display BYZESTY ESP32:


Ti segnalo che, nella sezione in lingua Inglese, si può scrivere solo in Inglese ... quindi, per favore, la prossima volta presta più attenzione in quale sezione metti i tuoi post; questa volta esso è stato spostato, da un moderatore della sezione di lingua Inglese, nella sezione di lingua Italiana ... la prossima volta potrebbe venire direttamente eliminato.

Grazie.

A quanto detto da pert aggiungo ...

... evitate di utilizzare la traduzione automatica fatta dal browser ... vi impedisce di capire la lingua della sezione dove andate a scrivere!

Guglielmo

... prova seguire QUESTO tutorial :wink:

Guglielmo

ho già provato, ma il display rimane sempre nero, ho provato a caricare questo codice sul display, sul monitor seriale compaiono le posizioni delle x e delle y ma sul display non esce nulla, rimane sempre nero. ecco il codice che ho usato:

#include <TFT_eSPI.h>
#include <XPT2046_Touchscreen.h>

TFT_eSPI tft = TFT_eSPI();

#define XPT2046_IRQ 36
#define XPT2046_MOSI 32
#define XPT2046_MISO 39
#define XPT2046_CLK 25
#define XPT2046_CS 33

SPIClass touchscreenSPI = SPIClass(VSPI);
XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);

#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define FONT_SIZE 2

void setup() {
  Serial.begin(115200);

  tft.init();
  tft.setRotation(1);
  tft.fillScreen(TFT_WHITE);
  tft.setTextColor(TFT_BLACK, TFT_WHITE);

  touchscreenSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
  touchscreen.begin(touchscreenSPI);
  touchscreen.setRotation(1);

  tft.setTextSize(FONT_SIZE);
  int centerX = SCREEN_WIDTH / 2;
  int centerY = SCREEN_HEIGHT / 2;
  tft.setCursor(centerX - 50, 30);
  tft.print("Hello, world!");
  tft.setCursor(centerX - 80, centerY);
  tft.print("Touch screen to test");
}

void loop() {
  if (touchscreen.tirqTouched() && touchscreen.touched()) {
    TS_Point p = touchscreen.getPoint();

    // Print raw values
    Serial.print("Raw X = ");
    Serial.print(p.x);
    Serial.print(" | Raw Y = ");
    Serial.print(p.y);
    Serial.print(" | Pressure = ");
    Serial.println(p.z);

    // Apply simple mapping if necessary
    int x = map(p.x, 200, 3700, 0, SCREEN_WIDTH);
    int y = map(p.y, 240, 3800, 0, SCREEN_HEIGHT);
    int z = p.z;

    // Update TFT display
    tft.fillScreen(TFT_WHITE);
    tft.setTextColor(TFT_BLACK, TFT_WHITE);
    int centerX = SCREEN_WIDTH / 2;
    int textY = 80;

    String tempText = "X = " + String(x);
    tft.setCursor(centerX - 30, textY);
    tft.print(tempText);

    textY += 20;
    tempText = "Y = " + String(y);
    tft.setCursor(centerX - 30, textY);
    tft.print(tempText);

    textY += 20;
    tempText = "Pressure = " + String(z);
    tft.setCursor(centerX - 60, textY);
    tft.print(tempText);

    delay(100);
  }
}

Può essere un problema di configurazione del display? Oppure un problema di retroilluminazione? Perché rimane sempre nero.

Ho provato a inserire questo codice:

#include <TFT_eSPI.h>  // Include la libreria TFT_eSPI
#include <XPT2046_Touchscreen.h>  // Include la libreria del touchscreen

// Creazione dell'oggetto TFT
TFT_eSPI tft = TFT_eSPI();

// Definizione dei pin per il touchscreen
#define XPT2046_IRQ 36
#define XPT2046_MOSI 32
#define XPT2046_MISO 39
#define XPT2046_CLK 25
#define XPT2046_CS 33

// Pin per la retroilluminazione del display
#define BACKLIGHT_PIN 21

// Creazione dell'oggetto touchscreen
SPIClass touchscreenSPI = SPIClass(VSPI);
XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);

void setup() {
  Serial.begin(115200);  // Inizia la comunicazione seriale

  // Configura il pin di retroilluminazione
  pinMode(BACKLIGHT_PIN, OUTPUT);
  digitalWrite(BACKLIGHT_PIN, HIGH);  // Accende la retroilluminazione

  // Inizializza il display
  tft.init();
  tft.setRotation(1);  // Imposta la rotazione del display

  // Riempi lo schermo di rosso per testare il display
  tft.fillScreen(TFT_RED);

  // Inizializza il touchscreen
  touchscreenSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
  touchscreen.begin(touchscreenSPI);
  touchscreen.setRotation(1);  // Imposta la rotazione del touchscreen
}

void loop() {
  // Controlla se il touchscreen è stato toccato
  if (touchscreen.tirqTouched() && touchscreen.touched()) {
    // Ottieni i punti di tocco dal touchscreen
    TS_Point p = touchscreen.getPoint();
    Serial.print("X = ");
    Serial.print(p.x);
    Serial.print(" | Y = ");
    Serial.print(p.y);
    Serial.print(" | Pressure = ");
    Serial.println(p.z);
  }

  delay(100);  // Piccola pausa per stabilità
}

Le x e le y mi compaiono sul monitor seriale, ma sul display non compare nulla. Ora rimane bianco perché ho inserito il pin della retroilluminazione:

// Pin per la retroilluminazione del display
#define BACKLIGHT_PIN 21

Ai seguito ALLA LETTERA il tutorial? Hai messo il file di configurazione indicato?

Guglielmo

SI', ho installato le librerie, ho caricato il codice, il display con il codice del tutorial, rimane nero, non diventa nemmeno bianco.
Cordiali Saluti

Ho 14 anni, elettronica la devo ancora studiare, quindi non so tutto, mi potresti dire Qual è il file di configurazione indicato?

Nel tutorial, se lo leggi CON ATTENZIONE, è indicato un file da scaricare e sostituire nella libreria TFT_eSPI ... altrimenti non funziona.

Guglielmo

Scusate, ma come faccio a visualizzare un'immagine sul display BYZESTY ESP32, il Modello è ‎WDY-ESP32Display-ZLBY (ESP32-2432S028)

Se tu leggessi con ATTENZIONE quello che ti viene indicato, scopriresti che sul sito di cui ti ho messo il link, oltre alle istruzioni esatte per far funzionare quel display, ci sono anche altri tutorial ad esso relativi che ti insegnano come usarlo.

Certo ... occorre dedicarci tempo, studiare con attenzione ed applicarsi.

Guglielmo

1 Like

Ti confermo quanto detto da Guglielmo, se non configuri correttamente la libreria TFT_esPI per il display che utilizzi non funzionerà mai.
Guglielmo ti ha indicato un tutorial dove spiegano come configurare la libreria, devi scaricare il file User_Setup.h per la tua scheda e sostituirlo a quello di default della libreria.

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