TFT_eSPI querie?

Something that’s cropped up during the development of my ESP32 USB-Midi keyboard player, regarding writing to my TFT screen, using the TFT_eSPI library.

I’ve introduced a new “Sequence” function, which automatically plays a series of chords / notes.
As the player moves through a song, it updates the screen, with information about the chord(s) being played.
Manually stepping through a chord chain is fine.
But NOW, the new sequence function highlights that the time spent writing data to the TFT screen affects the timing of the music. I never thought about it before, but it seems obvious to me now.

So, when regularly updating the TFT screen (at many different places on screen), which is quicker ? …

  1. Draw a rectangle to cover OLD text, then draw NEW text.
  2. Draw NEW text with BLACK background, to cover OLD text (needs trailing spaces,
    to ensure OLD text gets covered).

I’m using method 1 and I have proven that making the rectangles as small as possible, is actually quicker.
There are various issues that make method 2 awkward, in certain places on the screen.

I don’t know how to find the answer to my question scientifically, so I’m just doing some experiments, but it’s a labourious, long-winded process.
Any scientific knowledge would be helpful please.

Thank you
Trevor

I don’t think either of those will help you.
The key to speeding things up is “double buffering.”
You draw the entire screen into a (tft_eSPI) sprite in RAM, then copy the sprite to the display in one (fast) pass. This also avoids flickering.

Volos has good tutorials on YouTube:

Depending on your screen resolution, you may need to use a board with PSRAM.

Keep in mind that the ESP32 can perform multiple tasks, and chips such as the ESP32 and ESP32-S3 have a dual-core processor. This allows you to run the screen functions on one core while processing the audio functions on another core.

Thanks again Boris, I’ll check all that out.
Trevor