Multiple TFT_eSPI libraries - how to use and best to manage?

Hi all... I'll try to be as detailed as I can so as to explain what I am trying to accomplish.

I have recently purchased several LilyGo ESP32S3 boards, namely the T-Display S3, the T-Display S3 Touch, and the T-Embed S3. I have been writing scripts to do various tasks and they all make use of the excellent TFT_eSPI library. However, for whatever reason the T-Embed board uses different settings in the /User_Setup.h and /User_Setup_Select.h files for it to be used correctly with the TFT_eSPI library. After several hours yesterday I figured this out and managed to get the T-Embed board working fine with my code.

But today... when I came to use the other two boards, I found that they no longer display anything when yesterday (before I updated the TFT_eSPI libraries etc) they were all working fine. I have since discovered that of course the boards use different settings in the files mentioned above i.e. to define the specifics of the board, and reading some of the //comments in the files I see this is of course by design, thus allowing multiple boards to be used with essentially the same library. When I once again updated the relevant lib folders etc. the two other boards worked fine once again. But... you know what's coming now... the T-Embed board stopped working and I found myself back in the same position I was in yesterday!

Hence doing some research today finding out about all this stuff, and needing to figure out how to use multiple TFT_eSPI libraries. Therein lies my question.

How do you use multiple versions of a library with different sketches, specifically the TFT_eSPI library? I appreciate one can hard-code the location of the library in the #include statement to directly reference the file, but then if I move the file or folder etc it all goes awry again.

Right now I have the version of TFT_eSPI required to correctly run the first two boards installed in my Arduino/libraries folder, and in each of the files that uses it, I have #include "TFT_eSPI.h", but of course when I try to use the T-Embed board this library won't cut the mustard because the User_Setup.c and User_Setup_Select.h files are referencing the wrong boards!

How do I set up the environment such that I can use different installations of the library, with different settings for each board I use? Where do I install the TFT_eSPI folder and it's files...? is it in the /lib folder that the MySketch.ino is stored in, or elsewhere...? And how do I reference that file instead of the one in the /Arduino/libraries folder? Or, do I simply copy the User_Setup.h and User_Setup_Select.h files to the same folder as the MySketch.ino file?

Hope all that makes sense and that someone can point me in the right direction please. Thanks.

You have to change the user file evey time, I think. The Bodmers solution is good because it use just some bytes of memory but it is hard to configure and you loose your settings on an update because you have to edit the library itself.

I don't think you can set the configuration inside your sketch.

I had more luck with this library, on my last project:

The Bodmer TFT_eSPI library is very good to use with same controller, same display. Everey other controller or display are other setup files. Many of them are in the User_Setups map. If you make you're own combination, like the others in the map, you need only changing 2 lines in User_Setup_Select.h. One comment and one comment out.

Bodmer has tried to work around with a tft_setup.h file in the same folder as the .ino file. But this isn't work always. See here.

Thanks for the replies and pointers.

I’ve managed to find a crude workaround which is to store and configure an additional version of TFT_eSPI in the Arduino/libraries folder for each board type I own, rename each of those folders individually from the default TFT_eSPI to TFT_eSPI-board-name, then once I know the board I’m currently coding for, rename that boards folder to the default TFT_eSPI.

Crude, but at least it works :joy:

And remember to not update the library anymore!

Indeed!!!

I do have a copy of each of the TFT_eSPI libraries I use stored on an external SSD as a just-in-case :slight_smile:

Ok it works as the µC are always the same. You must make combinations TFT_eSPI-board_name-µC. And then making that they always use the same GPIO as SC or Reset.

Yep, this is exactly what I am doing :+1:

Now though, having trouble with the TFT_Widgets examples... sheesh, this 'resolving issues' never abates eh! :slight_smile:

Look into the widgets code. Isn't the code searching the real TFT_eSPI library?

Compilation error: 'class TFT_eSPI' has no member named 'getTouch'; did you mean 'getColor'?

Is the error I am seeing in Arduino IDE on compile, amongst others. I see the getTouch function defined in the touch.cpp class file, but for whatever reason the code is not finding it!

I have manually added:

#define TOUCH_CS 1
#include "Extensions/Touch.h"        // Loaded if TOUCH_CS is defined by user

... to the .ino file too so that the code sees there is a touch chip enabled.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.