1.8 tft 128*160 lcd error

Hi, i am using 1.8 TFT 128*160 LCD with spi communication. I am using esp32 microcontroller and trying to upload the image to the LCD but i am facing issues with the TFT library.
I have used the code as shown below:

<#include <SPI.h>
#include <SD.h>
#include <TFT.h>  // Arduino LCD library

// pin definition for the Uno
#define sd_cs  4
#define lcd_cs 10
#define dc     9
#define rst    8

// pin definition for the Leonardo
//#define sd_cs  8
//#define lcd_cs 7
//#define dc     0
//#define rst    1

TFT TFTscreen = TFT(lcd_cs, dc, rst);

// this variable represents the image to be drawn on screen
PImage logo;


void setup() {
  // initialize the GLCD and show a message
  // asking the user to open the serial line
  TFTscreen.begin();
  TFTscreen.background(255, 255, 255);

  TFTscreen.stroke(0, 0, 255);
  TFTscreen.println();
  TFTscreen.println(F("Arduino TFT Bitmap Example"));
  TFTscreen.stroke(0, 0, 0);
  TFTscreen.println(F("Open serial monitor"));
  TFTscreen.println(F("to run the sketch"));

  // initialize the serial port: it will be used to
  // print some diagnostic info
  Serial.begin(9600);
  while (!Serial) {
    // wait for serial port to connect. Needed for native USB port only
  }

  // clear the GLCD screen before starting
  TFTscreen.background(255, 255, 255);

  // try to access the SD card. If that fails (e.g.
  // no card present), the setup process will stop.
  Serial.print(F("Initializing SD card..."));
  if (!SD.begin(sd_cs)) {
    Serial.println(F("failed!"));
    return;
  }
  Serial.println(F("OK!"));

  // initialize and clear the GLCD screen
  TFTscreen.begin();
  TFTscreen.background(255, 255, 255);

  // now that the SD card can be access, try to load the
  // image file.
  logo = TFTscreen.loadImage("arduino.bmp");
  if (!logo.isValid()) {
    Serial.println(F("error while loading arduino.bmp"));
  }
}

void loop() {
  // don't do anything if the image wasn't loaded correctly.
  if (logo.isValid() == false) {
    return;
  }

  Serial.println(F("drawing image"));

  // get a random location where to draw the image.
  // To avoid the image to be draw outside the screen,
  // take into account the image size.
  int x = random(TFTscreen.width() - logo.width());
  int y = random(TFTscreen.height() - logo.height());

  // draw the image to the screen
  TFTscreen.image(logo, x, y);

  // wait a little bit before drawing again
  delay(1500);
}/>

Trying to upload the image, But i am seeing these below errors:

<.pio/libdeps/esp32dev/TFT/src/utility/Adafruit_GFX.cpp:662:26: error: variable or field 'image' declared void
 void Adafruit_GFX::image(PImage & img, uint16_t x, uint16_t y) {
                          ^
.pio/libdeps/esp32dev/TFT/src/utility/Adafruit_GFX.cpp:662:26: error: 'PImage' was not declared in this scope
.pio/libdeps/esp32dev/TFT/src/utility/Adafruit_GFX.cpp:662:35: error: 'img' was not declared in this scope
 void Adafruit_GFX::image(PImage & img, uint16_t x, uint16_t y) {
                                   ^
.pio/libdeps/esp32dev/TFT/src/utility/Adafruit_GFX.cpp:662:49: error: expected primary-expression before 'x'
 void Adafruit_GFX::image(PImage & img, uint16_t x, uint16_t y) {
                                                 ^
.pio/libdeps/esp32dev/TFT/src/utility/Adafruit_GFX.cpp:662:61: error: expected primary-expression before 'y'
 void Adafruit_GFX::image(PImage & img, uint16_t x, uint16_t y) />

Please anyone guide to solve this.
Thank you

Please follow the advice given in the link below when posting code. Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Hi,
I think this thread could be moved to the Display section of the forum.
There are some very experienced members there that may have a simple answer.

Tom... :smiley: :+1: :coffee: :australia:

Forget about the TFT.h library. It is crap.

  1. Post a link to the actual display that you have bought.

  2. Install Adafruit_ST7735 and Adafruit_GFX via the IDE Library Manager.

  3. Run the examples. Select the Software SPI constructor to suit your ESP32 wiring.

  4. Then connect the Hardware SPI wiring e.g.

#define TFT_MOSI 23
#define TFT_MISO 19
#define TFT_SCK  18
#define TFT_SS   5
#define TFT_DC   13     //
#define TFT_RESET 12   //
  1. Run the examples with the HW SPI constructor.

This might sound a bit complicated. When we have links to your actual hardware i.e. display board and ESP32 board, we can walk you through every step.

David.

hi, sorry for the delay response, we have tried the above mentioned, it didnt give us any error, but the image didnt get uploaded, its showing white space.
we have connected the wroomesp32 hspi to the module display screen and vspi to sd card pins

Secondly. Always run the library examples.

Adafruit_ST7735 library was designed for AVR / ARM. But it should work with ESP32.

TFT_eSPI library was specifically designed for ESP8266, ESP32. And has some ready-made User_Setup files. Just connect wires according to the User_Setup.

There is no quick fix. You just have to follow the suggested wiring and check carefully. I advise adding the "wire color" as a comment to each define.
Make notes on paper as you go. Then you can write something more convincing than "we have tried the above mentioned"

Once you have the library examples working we can show how to display pictures.

David.

Now we have taken the library TFT_eSPI from the below link
GitHub - Bodmer/TFT_eSPI: Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips and used all the examples to check with the display,and in "User_Setup.h" we have selected the configurations as:

<#define ST7735_DRIVER
#define TFT_WIDTH 160
#define TFT_HEIGHT 128

#define TFT_CS 15 // Chip select control pin (library pulls permanently low
#define TFT_DC 2 // Data Command control pin - must use a pin in the range 0-31
#define TFT_RST 4 />


In the above image, we have got some raster
For ST7735 ONLY, define the type of display, originally this was based on the
// colour of the tab on the screen protector film but this is not always true, so try
// out the different options below if the screen does not display graphics correctly,
// e.g. colours wrong, mirror images, or stray pixels at the edges.
// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
// this User_Setup file, then rebuild and upload the sketch to the board again:

<
// #define ST7735_INITB
// #define ST7735_GREENTAB
// #define ST7735_GREENTAB2
//#define ST7735_GREENTAB3
//#define ST7735_GREENTAB128 // For 128 x 128 display
// #define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 offset)
// #define ST7735_REDTAB
// #define ST7735_BLACKTAB
// #define ST7735_REDTAB160x80 // For 160 x 80 display with 24 pixel offset
/>

Checked with all these, the raster is cleared but on the display its still not displaying full screen
Please tell us how to display the full screen and display the pictures using SD card

Please post a link to the actual display that you have bought. Then I can see what the pcb looks like.

I would expect one of the ST7735_xxxTAB defines to work 100%.
But it is no good saying they all failed.
Just quote the define that gave the "best" picture and say what was wrong with that picture.

I am not the author of TFT_eSPI. I am happy to help if you make a serious effort to give accurate replies.

Your wiring is obviously 100%.
But Ebay sellers often lie about the controller part number.
If you run the
C:\Users\ ... \Documents\Arduino\libraries\TFT_eSPI\examples\320 x 240\Read_ID_bitbash
sketch it might show a different make of controller.

David.

is the link which we have bought.

#define ST7735_GREENTAB
This almost fills the display but doesnt clear the previous display.

C:\Users\ ... \Documents\Arduino\libraries\TFT_eSPI\examples\320 x 240\Read_ID_bitbash
doing this example gives nothing on the display
but did C:\Users\ ... \Documents\Arduino\libraries\TFT_eSPI\examples\320 x 240\TFT_Rainbow
this example displayed fully on the screen but it doesnt clear the previous content on the screeen

Thanks for the link to your display . I have a pcb that looks exactly the same components, copper traces, printing. (my pcb has black plastic pin header instead of your yellow plastic)
My display contains Sitronics ST7735S controller.

The Read_ID_bitbash sketch prints to the the Serial Terminal. It makes no attempt to write to the TFT screen.

You must check that the pin defines match your wiring.
You must set the Terminal to 115200 baud.

Run the program. Copy-Paste from the Serial Terminal to your message.
If your wires are correct it should show some different information for different registers.

Regarding ST7735_GREENTAB.
Please quote example by name. Report problems.
e.g. wrong colors, mirrored text, ...
e.g. shifted display like your photo in #7

I suspect that English is not your first language. Write carefully in your own language and ask Google to translate.

I can diagnose a lot of things from a photo. But only when I have accurate information like
setup file: TFT_eSPI\User_Setups\Setup47_ST7735.h
setup edits: #define ST7735_GREENTAB
#define TFT_HEIGHT 160

sketch: TFT_eSPI\examples\160 x 128\TFT_Clock_Digital\TFT_Clock_Digital.ino

attach photo or describe problems in English

David.

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