What a frame costs
The whole screen is 128 × 160 pixels at two bytes each: 40,960 bytes. At the controller's rated 15 MHz that is at least 21.8 ms on the wire before the library does anything else, longer than a 60 Hz frame. One number in large text is about 5 kB, an eighth of that. That arithmetic is why a sketch that clears the screen every loop flickers.
Forty thousand bytes
The panel is 128 by 160 pixels. The libraries send each pixel as two bytes, 16-bit colour, so the whole screen is 128 × 160 × 2 = 40,960 bytes. Every one goes down MOSI one bit per clock tick: 327,680 ticks.
The ST7735S data sheet puts the shortest write clock cycle at 66 ns, about 15 MHz. At that speed the whole screen spends at least 21.8 ms on the wire. That is a floor, not a measurement: the window commands, the gaps between transfers and whatever the sketch does to decide the pixels all come on top.
Libraries often run these panels at 20 to 40 MHz, past the data sheet, and on short wires it usually works. An Uno's SPI tops out at 8 MHz, and through a level converter it may need less. At 8 MHz the whole screen is at least 41 ms.
What that means for a loop
A 60 Hz monitor shows a new frame every 16.7 ms. A whole-screen redraw on this display takes longer than that on the wire alone, at any clock the data sheet promises. So a loop that clears the screen and draws everything again cannot keep up, and for the time the screen is cleared it shows nothing at all: that is the flicker.
The fix is in the other two bars. One number in the sketch's large text is about 108 × 24 pixels, 5,184 bytes, about 13% of the screen. A bar that grew by two pixels is 56 bytes. Send only those and the same clock does several times the work. The page this book replaced made the same point, and it was right: it is the habit that carries to every display after this one.
When it does not work
Look for fillScreen() in loop(). Every call sends 40,960 bytes, at least 22 ms at 15 MHz and much longer at an Uno's slower clock or through a level converter. Draw the parts that never change once in setup(), and redraw only what changes.
Up to a point. The data sheet rates the write clock to about 15 MHz; libraries often run faster and it usually works on short wires. Past what your wires and the panel take, the picture fills with noise. Redrawing less helps far more than clocking faster.
The controller can take 12, 16 or 18 bits a pixel. The libraries send 16, called RGB565, because it fits two bytes exactly: 65,536 colours for two thirds of the bytes 18-bit would take.
A dashboard that never clears the screen, and prints how long each update took.
Redraw only what changed →Edit this page — content/books/tft-1-8-inch/what-a-frame-costs.mdx
Questions about this product
See what other owners have asked, and read their solutions.
1.8-inch TFT Display
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.