Can't change DC & RST GPIO pin assignments using TFT_eSPI

SETUP:

  1. IDE Arduino v2.0.0
  2. TFT_eSPI library version 2.4.76
  3. Board package version (don't know how to find this info - get from espressif)
  4. ESP32-WROOM-32D DevKitC
  5. TFT driver ST7789
  6. Interface SPI

ISSUE:
-Unable to change DC and RST GPIO assignments

DESC:

  1. Changes to the User_Setup.H don't work for DC & RST ONLY. (Changes to other GPIOs are applied correctly)
  2. Assignments in the sketch don't work either.

TFT_eSPI "User_Setup.h" configuration trying to be used:

#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

TESTING OUTPUT:
(from Read_User_Setup.ino)

TFT_eSPI ver = 2.4.72
Processor    = ESP32
Frequency    = 240MHz
Transactions = Yes
Interface    = SPI
Display driver = 7789
Display width  = 240
Display height = 320

MOSI    = GPIO 23
MISO    = GPIO 19
SCK     = GPIO 18
TFT_CS   = GPIO 15
TFT_DC   = GPIO 0
TFT_RST  = GPIO 2

Font GLCD   loaded
Font 2      loaded
Font 4      loaded
Font 6      loaded
Font 7      loaded
Font 8      loaded
Smooth font enabled

Display SPI frequency = 27.00

Additional:
The display does work correctly using 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 with the same pin assignments

What do you mean by "can't change DC and RST GPIO pin assignments"?

GPIO_NUM_2 is typically the built in LED pin and can cause issues with some devices needing a clean signal.

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789

//Adafruit_ST7789 tft = Adafruit_ST7789( TFT_CS     , TFT_DC    , TFT_MOSI   , TFT_SCLK   , TFT_RST     );
Adafruit_ST7789 tft   = Adafruit_ST7789( GPIO_NUM_15, GPIO_NUM_0, GPIO_NUM_13, GPIO_NUM_14, GPIO_NUM_22 );


void fDoTheDisplayThing( void * parameter )
{
  tft.init( 240, 320 ); // Init ST7789 320x240
  tft.setRotation( 3 );
  tft.setTextSize( 3 );
  tft.fillScreen( ST77XX_BLACK );
  tft.setTextWrap( false );
  struct stu_eData px_eData;
  int OneTwoThree = 0;
  int countUpDown = 255;
  ledcWrite( 4, countUpDown ); //backlight set
  int dimDelaytime = 7;
  for (;;)
  {
    if ( xQueueReceive(xQ_eData, &px_eData, portMAX_DELAY) == pdTRUE )
    {
      xSemaphoreTake( sema_ScreenUpdate, portMAX_DELAY );
      if (!BlankScreen)
      {
        for ( countUpDown; countUpDown-- > 0; )
        {
          ledcWrite( 4, countUpDown ); // write to channel number 4, dim backlight
          vTaskDelay( dimDelaytime );
        }
      }
      tft.fillScreen(ST77XX_BLACK);
      tft.setCursor( 0, 0 );
      OneTwoThree++;
      if ( OneTwoThree == 1 )
      {
        tft.setTextColor( ST77XX_RED );
      }
      if ( OneTwoThree == 2 )
      {
        tft.setTextColor( ST77XX_WHITE );
      }
      if ( OneTwoThree == 3 )
      {
        tft.setTextColor( ST77XX_BLUE );
        OneTwoThree = 0;
      }
      tft.println( "Temp " + String(px_eData.Temperature) + "F" );
      tft.setCursor( 0, 30 );
      tft.println( "Hum  " + String(px_eData.Humidity) + "%" );
      tft.setCursor( 0, 60 );
      tft.println( "Pres " + String(px_eData.Pressure) + "mmHg" );
      tft.setCursor( 0, 90 );
      tft.println( "AQI  " + String(px_eData.IAQ) + "%" );
      tft.setCursor( 0, 120 );
      tft.println( "RM0  " + String(px_eData.RM0) + "%" );
      tft.setCursor( 0, 150 );
      tft.println( "PM2  " + String(px_eData.PM2) + "ug/m3" );
      tft.setCursor( 0, 180 );
      tft.println( String(px_eData.WSV) + "V " + String(int(px_eData.WSC * 1000.0f)) + "mA " + String((int(px_eData.WSP * 1000.0f))) + "mW" );
      //brighten blacklight level
      vTaskDelay( 400 ); // wait for screen update to be done
      if ( !BlankScreen )
      {
        for ( countUpDown; countUpDown <= 255; countUpDown++ )
        {
          ledcWrite( 4, countUpDown ); // write to channel number 4
          vTaskDelay( dimDelaytime  );
          //log_i( "DoTheBME280Thing high watermark % d",  uxTaskGetStackHighWaterMark( NULL ) );
        } //if ( xQueueReceive(xQ_eData, &px_eData, portMAX_DELAY) == pdTRUE )
      }
      xSemaphoreGive( sema_ScreenUpdate );
    } //if ( xQueueReceive(xQ_eData, &px_eData, portMAX_DELAY) == pdTRUE )
  } //for (;;)
  vTaskDelete( NULL );
} //void fDoTheDisplayTHing( void * parameter )


void fScreenBlanking( void *pvParameters )
{
  int      TimeOfPause = 10000 * 1000; 
  uint64_t PauseStartTime = esp_timer_get_time();
  bool     Pause = false;
  int      countUpDown = 255;
  for ( ;; )
  {
    if (!Pause )
    {
      xSemaphoreTake( sema_ScreenUpdate, portMAX_DELAY );
      //if motion detect then show display otherwise blank display
      if ( !(gpio_get_level( GPIO_NUM_27)) )
      {
        BlankScreen = true;

        for ( countUpDown; countUpDown-- > 0; )
        {
          ledcWrite( 4, countUpDown ); // write to channel number 4, dim backlight
          vTaskDelay( 7 );
        }
      } else {
        Pause = true;
        PauseStartTime = esp_timer_get_time();
        ledcWrite( 4, 255 );
        BlankScreen = false;
        countUpDown = 255;
      }
      xSemaphoreGive( sema_ScreenUpdate );
    } else {
      // still detecting movement reset blanking pause time
      if ( gpio_get_level( GPIO_NUM_27) )
      {
        PauseStartTime = esp_timer_get_time(); // extend pause blanking time
      }
      if ( (esp_timer_get_time() - PauseStartTime) >= TimeOfPause )
      {
        Pause = false;
      }
    }
    vTaskDelay( 250 );
  }
  vTaskDelete( NULL );
} //void fScreenBlanking( void *pvParameters )

Is how I do the thing with an ESP32.

Hi,
First, thank you for responding.

I don't have any problems using the Adafruit_ST7789.h setup. Both the DC & RST can be assigned to GPIO2 & GPIO4, respectively.

The problem is with the TFT_eSPI setup and GPIO configuration.

Trying to assign the following:
DC to GPIO2
RST to GPIO4

No matter what I set either in the User_Setup.h file or directly in the sketch, the outcome is always:
DC = GPIO 0
RST = GPIO 2

I hope that helps.

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