Go Down

Topic: Graphics library for NodeMCU (ESP8266), ESP32 and serial+parallel TFT displays (Read 94330 times) previous topic - next topic


Thank you David, I'll try!
Although the example comes 'raw'; I'll have to use some RTC to get the time.


You can test the "look and feel" of a clock by using the Arduino internal system timer e.g. millis()

Replace this with an external RTC after you have the display looking like you want.

Explain in English what you want to do.  e.g. clockface in different location, size, colours, or style.

Readers can only help you with coding when they know what you actually want.



Hi all,

Quite new to Arduino. I think I have a NodeMCU ESP8266 board and a mcufrield.com 3.5" display.

If someone can help out with the connections between the two, it will be greatly appreciated. I am assuming the TFT-eSPI is the correct library but without proper connection, I am sure my display won't work.

Any help will be greatly appreciated.


https://github.com/lualiliu/esp32-gameboy  . Would be nice if we can port this project to make use of TFT_eSPI and thus bigger screens..


I have a touch LCD shield with parallel interface, a clone of this one (or at least extremely similar). How to properly wire it to ESP32 for use with this library? Just the screen, no touch or SD card for now.

This is what confuses me in the docs - this is an example config for ILI9341:
Code: [Select]
//#define TFT_MISO 19
//#define TFT_MOSI 23
//#define TFT_SCLK 18
//#define TFT_CS   15  // Chip select control pin
//#define TFT_DC    2  // Data Command control pin
//#define TFT_RST   4  // Reset pin (could connect to RST pin)
//#define TFT_RST  -1  // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST

My board also has 9341, but I have the following pins:
RST (this one is clear, just a Reset pin)
RS (??)
And 8 data pins.


If it looks like this

It should work with any Mcufriend-style libraries (if you configure the data bus pins)
It appears to have a separate hardware-reset chip.

Regular Mcufriend-style shields have a LCD_RST pin on A4.
This is unnecessary if you have a reset-chip.

Bodmer's TFT_eSPI library runs some parallel chips e.g. ILI9341
You need a small hardware mod on a TTGO D1 R32 board and software tweak.

MCUFRIEND_kbv library supports ILI9325, ILI9328, HX8347D and many others.
You need a small hardware mod on a TTGO D1 R32 board and software tweak.

It is fairly pointless using a Parallel shield with ESP32.
You can use SPI modules with ESP32, ESP8266 and still have pins spare.



Thanks for inserting the board photo, David. I was just thinking if it's a good idea or better leave it as a link.

And indeed, I've used your MCU_friend_kbv library with great success with my LCD and Arduino Due! But I thought it's only for Arduino boards, do you also support EPS32?
I understand it's pointless, but I already have this LCD and could start working on the project isntead of just sitting on my hands for a month until a more fitting LCD arrives from China.


I read the rotation examples for the Sprites but cannot seems to find the answer.
Say I want to create a dial with two individually rotated needles (Based on bmp images on spiffs)
Think clockhands as an example. 

How can I push both images (and correctly rotated) into the single Sprite?
pushRotated seems to rotate the whole Sprite if I am not mistaken. 


Guys, is it possible to load BPM (i.e. in 16bits format 565) into SPIFFS  and then read only a part of that bitmap and put that small part on the display/spring?
For example i have 100x100 pixels BMP stored in flash. Now i need to take a small part using function like:

partBMP(flie_name, startX, startY, width, height) - i'm telling where to start (startX, startY) within the BMP 'file_name' and how big part i need (width, height).

Please tell me how to implement it.
By this i can easily replace just part of the display content and shift that part easily i the direction i need.


@Mac_che: Study the Rotated_Sprite_2 example. You just need to print the "needle" twice at different angles.

@bogus105: Answered here.


I have updated the TFT_eSPI library to support this fast 320x420 4" ST7796 based RPi display. Typically this is available for $15 or less with or without XPT2046 based touch screen.

This display is fitted with a bespoke SPI serial to parallel converter that is much better than many RPi displays on the market. The SPI transmit data can be clocked into the display reliably at up to 125MHz which is the data sheet limit for parallel data with the ST7796. The chip converts the SPI data to 16 bit parallel and writes it into the display at up to 30Mbytes/sec. This neatly gets around the speed limits of typical SPI interfaces on these screens and permits 50fps whole screen update rate.

The TFT_eSPI library can be used with the ESP32 SPI with an 80MHz clock (maximum for ESP32). For a 320 x 480 display this gives good performance for a SPI interface:

Code: [Select]

ESP32 RPi ST7796 80MHZ SPI
Benchmark,                Time (microseconds)
Screen fill,              180556 (clear screen = 36 ms = ~28 fps)
Text,                     13699
Lines,                    166066
Horiz/Vert Lines,         16290
Rectangles (outline),     9376
Rectangles (filled),      440312
Circles (filled),         102275
Circles (outline),        101998
Triangles (outline),      34580
Triangles (filled),       164103
Rounded rects (outline),  43216
Rounded rects (filled),   490934

Total = 1.7634s

Although the ESP8266 can clock the SPI at 80MHz, it does not have the signal drive strength to maintain the correct clock phase relationship with the data. This limits the ESP8266 to 40MHz SPI clock with this display:

Code: [Select]

ESP8266 RPi ST7796 40MHZ SPI
Benchmark,                Time (microseconds)
Screen fill,              317434 (clear screen = 63 ms = ~18 fps)
Text,                     20888
Lines,                    270627
Horiz/Vert Lines,         27145
Rectangles (outline),     16004
Rectangles (filled),      768065
Circles (filled),         173822
Circles (outline),        163897
Triangles (outline),      55797
Triangles (filled),       293139
Rounded rects (outline),  70044
Rounded rects (filled),   863555

Total = 3.0404s

Wiring is as per image here.


Hi guys.
I'm a newbie to ESP32 and also Bodmer's tft_espi library, but have been trawling through the examples trying to get the font type and size I want.
Firstly I must say the use of sprites is fantastic for flicker free dynamic text.
Now looking at smooth fonts.
I converted Arial font using the various links Bodmer provides in the examples and can get it onto the display using sprite. Not sure if doing it 100% correctly, but it's working.
Anyway, wondering if I can scale the smooth font.
Img.setTextSize() isn't doing anything. Tried it at several positions in the code. Ended up just converting the font again in a bigger size.
So is this the way to go? Or am I missing something?
Using a 2.2" TFT ILI9341.
Any tips?

Thanks in advance



Scaling does not work on smooth fonts. You have to create and load a larger size font.


Many thanks Bodmer. That's what I figured.
Top job on the library by the way.
A tad confusing for a novice like me but great examples and with those I've been able to piece stuff together as I'd like.



While I'm here, may as well ask.... No chance of a user manual I suppose.
The examples are great but I find that I usually delete a lot of the clever stuff just to get to the bare bones.
Maybe just me being lazy.....

Go Up