TFT ST7735 flickering on ESP32

Hey. I have used an OLED 1.3" display for my project and did not have any problems.

for my OLED, i had a function:

void OLED_display(int number1){

    int address=0;



    display.setTextSize(4);

    display.clearDisplay();

    display.setCursor(0,0);               

    display.println(EEPROM.readUShort(address));

    //Serial.print("OLED display quantity = ");

    //Serial.println(EEPROM.readUShort(address));

    address += sizeof(unsigned short);

    //display.display();

    display.setCursor(0,32);                

    display.println(number1);        // number2 means number to_pick

    display.setTextSize(1);

    display.setCursor(64,32);

    display.println(current_status);      

    display.setCursor(64,40);

    display.println(DEVICE_ID);      

    display.setCursor(64,48);

    display.println(EEPROM.get(address,eeprom_serial));      //print SERIAL id

    address += 10;

    display.setCursor(64,56);

    display.println(encoder.displaycounter);      //print SERIAL id

    display.display();

}

Being called every 1second to update all the values that I need on my display.

I have decided to switch to bigger display ST7735 and wrote an identical function for it:

void TFT_setup(){

  tft.initR(INITR_BLACKTAB);

  tft.setRotation(1);

  pinMode(TFT_BACKLIGHT, OUTPUT);

  //tft.invertDisplay(false);

  digitalWrite(TFT_BACKLIGHT, HIGH); // Backlight on

  tft.fillScreen(ST77XX_BLACK);

  tft.setTextColor(ST77XX_GREEN);



}





void TFT_display(int number1){

    int address=0;

    tft.setTextSize(3);

    tft.fillScreen(ST77XX_BLACK);

    tft.setCursor(0, 0);  

    tft.print(EEPROM.readUShort(address));           

    address += sizeof(unsigned short);

    tft.setCursor(0,32);                

    tft.print(number1);        // number2 means number to_pick

    tft.setTextSize(1);

    tft.setCursor(64,32);

    tft.print(current_status);      

    tft.setCursor(64,40);

    tft.print(DEVICE_ID);      

    tft.setCursor(64,48);

    tft.print(EEPROM.get(address,eeprom_serial));      //print SERIAL id

    address += 10;

    tft.setCursor(64,56);

    tft.print(encoder.displaycounter);      //print SERIAL id



}

However, this TFT display flickers everytime I call TFT_display function. I believe the reason for that is because when i use tft.fillscreen it takes a while to print all the values on the screen?. Im not sure why I am not able to see any flickering on my SSD1306 OLED display.

Could someone suggest me a way to fix this problem since its very annoying and not convenient to look at such delay that is flickering every time a value is being changed.

The Adafruit_SSD1306 library and many other OLED libraries build an image in a local SRAM buffer.

Nothing is sent to the OLED until you call display.display()

This means that you can draw graphics, text, ... to the buffer but only see the results when you call display(). This function is very quick.

A TFT can draw one pixel at a time. Hence you see it working.

The trick is to only redraw a TFT when you need to. e.g. only paint a new background for the new text you are writing. Or draw the text in "rubout mode" e.g. tft.setTextColor(GREEN, BLACK)

David.

david_prentice:
The Adafruit_SSD1306 library and many other OLED libraries build an image in a local SRAM buffer.

Nothing is sent to the OLED until you call display.display()

This means that you can draw graphics, text, ... to the buffer but only see the results when you call display(). This function is very quick.

A TFT can draw one pixel at a time. Hence you see it working.

The trick is to only redraw a TFT when you need to. e.g. only paint a new background for the new text you are writing. Or draw the text in "rubout mode" e.g. tft.setTextColor(GREEN, BLACK)

David.

Or use DMA

Už Lietuvą vyrai :smiley: