LVGL with ILI9341 + Touch panel
- spookyrufus
- Posts: 12
- Joined: Wed Jul 15, 2020 8:09 am
- Location: Estonia
- Contact:
LVGL with ILI9341 + Touch panel
I am trying to experiment with LVGL and an ILI9341 + touch display.
So far I managed to compile and deploy Micropython+LVGL and get the display connected via VSPI to the ESP32, and get some demos running. I am amazed at the beauty of the results, using only few lines of python code.
I am having trouble though, getting the touch panel working.
First, I am not sure of the correct wiring for the touch panel. On the back of the display module, the first 5 pins are dedicated to the touch functions:
How should these connect to the ESP32?
I have tried several ways of connecting it, but also due to the second point below, I am not sure whether I got the right wiring, and the wrong test routine, or the other way around, or both.
And second, I could not find -despite extensive searches- any example code to test whether the connected touch panel is working, in LVGL.
I took few educated guess after reading the docs, but no good results.
I would appreciate any pointer in the right direction.
Shameless shoutout to @pythoncoder or @dhylands because they are legends and absolute divinities of these forums
So far I managed to compile and deploy Micropython+LVGL and get the display connected via VSPI to the ESP32, and get some demos running. I am amazed at the beauty of the results, using only few lines of python code.
I am having trouble though, getting the touch panel working.
First, I am not sure of the correct wiring for the touch panel. On the back of the display module, the first 5 pins are dedicated to the touch functions:
How should these connect to the ESP32?
I have tried several ways of connecting it, but also due to the second point below, I am not sure whether I got the right wiring, and the wrong test routine, or the other way around, or both.
And second, I could not find -despite extensive searches- any example code to test whether the connected touch panel is working, in LVGL.
I took few educated guess after reading the docs, but no good results.
I would appreciate any pointer in the right direction.
Shameless shoutout to @pythoncoder or @dhylands because they are legends and absolute divinities of these forums
Re: LVGL with ILI9341 + Touch panel
Ar you sure that a touch sensor is present. The chip U2 seems missing. And if yes, which touch controller should be there?
Edit: On some other pictures I see a XPT2048 populated at that place.
Edit: On some other pictures I see a XPT2048 populated at that place.
-
- Posts: 67
- Joined: Fri Sep 04, 2020 9:27 am
- Location: Hanko, Finland
- Contact:
Re: LVGL with ILI9341 + Touch panel
Most likely it is missing.
Code you might be interested https://github.com/divergentti/airquali ... ouchscreen most likely better display drivers exists, but I used that. I hit into memory issues and decided to leave keyboard etc interaction with user away.
Connections in the parameters.py file https://github.com/divergentti/airquali ... ameters.py
My similar TFT panel with Touchscreen version:
Currently I wonder can I use SD-slot as a slave to SPI-bus, because another SPI is in touchcreen and another in TFT...
Code you might be interested https://github.com/divergentti/airquali ... ouchscreen most likely better display drivers exists, but I used that. I hit into memory issues and decided to leave keyboard etc interaction with user away.
Connections in the parameters.py file https://github.com/divergentti/airquali ... ameters.py
My similar TFT panel with Touchscreen version:
Currently I wonder can I use SD-slot as a slave to SPI-bus, because another SPI is in touchcreen and another in TFT...
Re: LVGL with ILI9341 + Touch panel
You can connect several SPI slaves to the same SPI BUS. Just activate them alternatively with CS. You may have to switch speed.
-
- Posts: 67
- Joined: Fri Sep 04, 2020 9:27 am
- Location: Hanko, Finland
- Contact:
Re: LVGL with ILI9341 + Touch panel
Thank you @Roberthh for this information.
Currently I am using 1.2 MHz for the touchscreen digitizer (VSPI) and I guess 1.31250 MHz is something what I shall use for the SD-reader? The touchscreen absolutely maximum speed is below 2 MHz with my test setup (with dupont patch cables).
Re: LVGL with ILI9341 + Touch panel
It might be easier to share the bus for display and touch screen. For the SD card, it may not be clear about when the SD card will be accessed. Then you have to switch the bus speed between accesses. Besides that, you may also consider using SoftSPI for the touch interface. That is not in conflict with the other interfaces. If you use different buses, you can pull CS permanently low, reducing pin count.
Long ago, I have also made a driver for the XPT2048 using Pin bit-banging. See: https://github.com/robert-hh/XPT2046-to ... yBoard.git
The function to adapt is touch_talk(). It uses direct port I/O of the Pyboard. Your can change that to ESP32, or use Pin access. No too complicated.
Long ago, I have also made a driver for the XPT2048 using Pin bit-banging. See: https://github.com/robert-hh/XPT2046-to ... yBoard.git
The function to adapt is touch_talk(). It uses direct port I/O of the Pyboard. Your can change that to ESP32, or use Pin access. No too complicated.
- spookyrufus
- Posts: 12
- Joined: Wed Jul 15, 2020 8:09 am
- Location: Estonia
- Contact:
Re: LVGL with ILI9341 + Touch panel
Wow. Missing chip indeed.
Thanks for pointing that out as I would have never figured it out.
Thanks for pointing that out as I would have never figured it out.
- spookyrufus
- Posts: 12
- Joined: Wed Jul 15, 2020 8:09 am
- Location: Estonia
- Contact:
Re: LVGL with ILI9341 + Touch panel
Thanks for this pointer also.Divergentti wrote: ↑Tue Jan 26, 2021 7:57 amMost likely it is missing.
Code you might be interested https://github.com/divergentti/airquali ... ouchscreen
I have ordered a new display from AliExpress (unfortunately there aren't many for sale where I live and shipping from Amazon is outrageous) so I have now around 3 weeks to review your code before I can test it
-
- Posts: 67
- Joined: Fri Sep 04, 2020 9:27 am
- Location: Hanko, Finland
- Contact:
Re: LVGL with ILI9341 + Touch panel
Hopefully 3 weeks is enough. I ordered quite a lot sensors and stuff from Aliexpress October 2020 and I am still waiting some of them. Reason is most likely Post of Finland, because European Union begins collecting VAT and customs from purchases less than 22€ and they hold those packages somewhere. Last year they did not collect VAT nor customs from purhcases valued less than 22€. At least tracking code shows package arrivals to Finland already November or beginning of December.spookyrufus wrote: ↑Tue Jan 26, 2021 4:08 pmThanks for this pointer also.Divergentti wrote: ↑Tue Jan 26, 2021 7:57 amMost likely it is missing.
Code you might be interested https://github.com/divergentti/airquali ... ouchscreen
I have ordered a new display from AliExpress (unfortunately there aren't many for sale where I live and shipping from Amazon is outrageous) so I have now around 3 weeks to review your code before I can test it
About my code: I hit into serious memory issues and I re-structured and refactored it quite a bit. I removed comments, shortened variable names etc.
For some reason speeding up CPU to 240MHz seems to keep free memory around 40 000, but if I use standard 160MHz, free memory might dip almost 0 and sometimes I got out of memory.
Once memory issue is solved, most likely I add some trending, average calculation, finish MQTT part, perhaps add SD-card access to the code and then I draw some nice case with Fusion360 to be printed with 3D-printer https://www.thingiverse.com/divergentti/designs.
- spookyrufus
- Posts: 12
- Joined: Wed Jul 15, 2020 8:09 am
- Location: Estonia
- Contact:
Re: LVGL with ILI9341 + Touch panel
What are the chances.. I'm across the gulf, in Tallinn. Terve fellow micropythonist!