Tips on using the LilyGo T-Display / Touch boards with SquareLine Studio

I have spent several hours today fathoming out what was happening with code generated using SLS on my LilyGo T-Display and T-Display Touch ESP32S3 boards, which were causing no end of issues. Thought it might be beneficial if I wrote up my tips for any other users of these pretty decent ESP32S3 development boards in an attempt to avoid anyone else experiencing the same pain and frustration as I have over the last few days!!. For clarity, for the purposes of these suggestions / tips, I use the ArduinoIDE2 app on a Mac. Also please let it be known I am not a professional developer by any stretch of the imagination, just - as like many of us here I imagine - an enthusiastic self taught wannabe :slight_smile:

The boards I am referring are available here: T-Display-S3 – LILYGO®

They have a pretty decent GitHub page where you can find the factory code and some other examples to try out in your IDE. Squareline Studio makes extensive use of the TFT_eSPI library and it MUST be noted that to use the LilyGo T-Display boards with TFT_eSPI one must use the modified TFT_eSPI library in the /lib folder from the LilyGo T-Display-S3 GitHub page linked above.

  1. Once you have completed your project in SquareLine Studio, and have done the Export > Create Template Project and Export > Export UI Files you will need to replace the TFT_eSPI folder and importantly one additional file.

  2. Replace the folder…

your-project/libraries/TFT_eSPI

… with the one downloaded from LilyGo GitHub repository

  1. Repalce the file…

/your-project/libraries/lv_conf.h

… with the one downloaded from LilyGo GitHub repository

  1. You may have to edit the lv_conf.h file to ensure that line 30 shows:

#define LV_COLOR_16_SWAP 0

  1. Launch your-project.ino file using ArduinoIDE

  2. I have found and reported an issue/bug in the Squareline Studio generated code for your-project.ino file, typically on line 18 or thereabouts look for a line with the following:

TFT_eSPI tft = TFT_eSPI(screenWidth, screenHeight); /* TFT instance */

Then change that to:

TFT_eSPI tft = TFT_eSPI(); /* TFT instance */

…and save your file

  1. Ensure you have changed your Sketches Folder in Arduino>preferences to the location of your newly created SLS project folder

Your code should then compile and upload successfully. Now I appreciate this in not the best solution but it does allow you to use these boards with SLS. Be aware that if you re-export your template files from SLS you may have to once again repeat steps 2-4 above.

NB: it should also be noted that if you use either of these boards outside of SquareLine Studio, you also need to ensure you are using the correct TFT_eSPI library and lv_conf.h file from LilyGo in your Arduino/libraries folder.

I created a quick demo project in SquareLine Studio to check this, here’s a screenshot from SLS;

and the resulting (poor quality) photo from the board itself…

3 Likes

Thank you very much for sharing your experience. I’m sure it will be useful for many people.

We are visiting Embedded World this week and I’ll check if I can meet with the guys from LilyGo.

You are very welcome, and have a great conference, hope you make loads of useful contacts.

1 Like

Any luck on getting the touch feature to work?

Thanks a ton @themusicman . After hours of failure in getting the expected output, I stumbled upon your other post that dealt with lv_conf.h and then this thread. You saved me few more hours of troubleshooting.
While I did copy the TFT_eSPI from the lilygo repo, I didn’t know about the lv_conf.h and thanks for that pointer.

Hi! Great advice. As a follow-up to this, any luck getting the touch feature to work? I may play with TouchLib form the Lilygo T-Display GitHub and see if I can trigger events with it.

Aha! Sorted the touch feature issue. @yokofuego, I am not sure if I am late here, but I just posted that I had success getting the touch feature to work on my T-Display-S3 Touch. Just need to add the CST816S library and make a few tweaks. I hope it helps!

1 Like

Thank you!!! :grinning:

1 Like

"Hello and good day, I’m also an enthusiastic self-learner and a beginner in Arduino / SLS. Would it be possible for you to share your demo project here for interested people like me? I’m using the Lilygo T3 AMOLED Touch Display with 536x240 resolution and I’m not quite achieving a satisfactory result.

Thank you in advance."