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…

4 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."

The image you sent appears to be related to resolving issues with using LilyGo T-Display/Touch boards with SquareLine Studio. The text describes steps to take to address these issues.

Here are the key points from the text:

  • You need to use the modified TFT_eSPI library from LilyGo’s GitHub repository with LilyGo T-Display boards in SquareLine Studio.
  • Replace the TFT_eSPI folder in your project with the one from LilyGo’s GitHub.
  • Replace the lv_conf.h file in your project with the one from LilyGo’s GitHub.
  • Edit the lv_conf.h file to ensure line 30 reads: #define LV_COLOR_16_SWAP 0
  • There may be a bug in SquareLine Studio generated code. Line 18 of your_project.ino might say: TFT_eSPI tft = TFT_eSPI(screenWidth, screenHeight); /* TFT instance / . Change this line to: TFT_eSPI tft = TFT_eSPI(); / TFT instance */
  • Make sure your Arduino IDE sketches folder points to the location of your SLS project folder.

By following these steps, you should be able to resolve the issues with using LilyGo T-Display/Touch boards with SquareLine Studio.

1 Like

Thanks for the informaton. Question: does this apply to the 2.41" T4 S3 display? I followed this example moving all the files, now after uploading, the screen is blank and the serial monitor shows the board rebooting. I’m on a Mac version 14.4.1 using Arduino IDE 2.3.2.

Thanks

1 Like

Thank for this exemple, it’s great. But my TFT (touch0 don’t run !!!
Please help me.
The TFT run with the example Capacitivetouch but nothing with my squareline
(scuse my english because i’m french from Quebec)

Hello you can explain more on this : few tweaks
merci

Oh, mainly changing out TFT code with the library-supported code. Go to my post here, and in the code snippets, I share the changes I made (using //comments to indicate what I added or changed)

2 Likes

Merci beaucoup, votre aide est appréciée. :wink:

2 Likes