Reader [Jasper] writes in with glowing praise for the TFT_eSPI library for the ESP8266 and the various cheap 480×320 TFT displays (ILI9341, ILI9163, ST7735, S6D02A1, etc.) that support SPI mode. It’s a drop-in replacement for the Adafruit GFX and driver libraries, so you don’t need to rework your code to take advantage of it. If you’re looking to drive an LCD screen with an ESP8266 and Arduino, check this out for sure.
As a testbed, [Jasper] ported his Tick Tock Timer project over to the new library. He got a sevenfold increase in draw speed, going from 500 ms to 76 ms. That’s the difference between a refresh that’s visibly slow, and one that looks like it happens instantly. Sweet.
Improving software infrastructure isn’t one of the sexiest or most visible hacks, but it can touch the lives of many hackers. How many projects have we featured with an ESP8266 and a screen? Thanks, [Bodmer] for the good work, and [Jasper] for bringing it to our attention.
Software infrastructure isn’t sexy? Please say it isn’t so! ;-)
Very useful article, Elliot. Thank you. I’ve tweeted out a link on it as well.
nice
I came across Bodmers library yesterday and within minutes tested out the weather station example which works a treat and is so so fast compared with the other TFT libraries out there. Thanks ever so much for your hard work Bodmer, it’s turned a pass able project into one that looks awesome!!
Thanks for this post. Useful software libraries are très sexy.
nice.
I like seeing more driver work for the ESP and also the ‘blue pill’ that is now becoming a really hot arduino-compat item.
Good man. The best drivers are the ones you can’t tell are there.
I feel like the Tick Tock Timer could be repurposed and marketed for lawn sprinkler systems to reach a larger audience.
Another good application would be a lighting controller.
That housing is really nice. I’d like to use that for my home automation.
Too bad he didn’t release the files.
If anyone is interested in the tick tock timers board (esp8266, ili9341, DS3231 RTC, relay) and the 3D pintable case PM me.
Btw, any way to simply & quickly display a picture on the screen ? Using adafruit libraries, you hav to do it pixel by pixel using “plot”, which is very slow…
It depends what you mean by “quick”. The ESP8266 can decode a 320×240 JPEG stored in the SPIFFS memory and render it on the SPI screen in 400ms. A lot of this time is doing the maths to decode the JPEG. A raw bitmap from SPIFFS probably won’t be any faster as the much larger file size takes longer to pull out of the serial access FLASH chip.
The library ESP8266_uncannyEyes example renders a moving eyeball with the animated eyelids onto the screen at 33 fps, so small animations are possible.
on the C SDK for the ESP the hardware SPI “send” function takes 10 bytes to the send buffer. whats interesting is that i have not come across any display library that uses all bytes and only sends data 1 byte at the time. It is an easy hack to increase SPI data speed by a lot. Here is a micropython “C Module” implementation i wrote http://ideone.com/SZ62N8.
Mine takes advantage of the ESP32’s 64bytes SPI registers:
https://github.com/agashka/esp8266_ili9341/blob/master/driver/ili9341.c
The TFT_eSPI library uses the 64 byte buffer too and that is one way it achieves the high data rates. By recycling a full buffer to say clear a screen it is possible to send pixels fast (at 75Mbps with 80MHz SPI clock). The ILI9341 “nearly” manages to cope with this rate (a few duff pixels) but it is heavily overclocking the TFT driver.
Going from 500ms to 76ms should make it possible to have UI animations in devices built around these if the storage allows it.
The uncannyEyes example runs at ~30fps but that is quite a small graphic. The main constraint is the serial SPIFFS FLASH access.
Are any of those chips really for 480×320 resolution or is is a typo? seems 240×320 or lower to me. I have actually tried to find cheap 480×320 on ebay with good driver support like ILI9341 for 320×240 but didn’t find anything similar for 480×320
ILI9488 for example, I bought mine (3,95″) for €8,- at aliexpress.
A number of display resolutions are supported. Assembled 480 x 320 TFT’s that have an SPI interface are rare. The 480 x 320 display supported by the library is an ILI9486 display designed for the Raspberry Pi by Waveshare. Clones are available 3.5″ and 4.0″ for circa $15. This RPi board design uses a 16 bit shift register (2x 74HC4094), a counter (1 x 74HC4040) and a hex inverter (74HC04). Many other RPi interface designs are sold that are not of this design so be careful if you are looking to buy a display!
Performance is reasonable but the display circuit design limits the SPI clock rate to 20MHz. An image in the library “Tools” folder of the library shows a hack to add a write strobe that boosts the speed for block writes (e.g. clear 480×320 screen in 24ms) and faster rendering Run Length Encoded fonts (1.2ms for 72 pixel height digit). The hack also delays the Write strobe from the 74HC4040 just enough to let the circuit run at a higher 27MHz SPI clock rate too.
The ILI9341 is typically a 320 240 TFT, these display drivers are good and almost work at 80MHz SPI clock rate (data sheet spec. is 25MHz). Expect some duff pixels at 80MHz but they seem to work reliably at 40MHz.
For best performance run the ESP8266 at 160MHz.
Have fun,
Bodmer
Hi Bodmer, can we connect somehow? I need to contract your skills for a display driver for one of my projects (eInk & esp). Thanks in advance!
Hi Andrei, Unfortunately I don’t have enough time to do my own projects :-(
Thanks for thinking of me though.
I thought that might be the case but said to try anyway :)
Thanks for responding. Could you follow me on Twitter (I’ll follow back) to have a connection channel and maybe in the future we have the opportunity to work together?
Thanks in advance!
@Bodmer
actually the datasheet spec is 10Mhz SPI spec (100nS write cycle)
can not find any datasheet say otherwise
sidenote.
old datasheets of ST7735 have 16nS write cycle which gives 62.5Mhz spi write
this is corrected in newer versions to 100nS as well
eiher they did a typo, or the absolute ratings spec. is 16nS