peterhinch / micropython-touch

A GUI for touch panel displays.
MIT License
17 stars 2 forks source link

Docs for spi assignment for touch screen. #1

Closed beetlegigg closed 3 months ago

beetlegigg commented 3 months ago

Hello Peter, Big thanks for providing the code to get a touch screen working. It looks very interesting.

I've perused the doc's in preparation to having a go at the touch with my Chinese ili9341 which appears to have the xpt2046 chip. I will see if this low cost screen can be made to work, but I note your info on the fact it may not be as good as the Adafruit screens so I may have to get an Adafrut one.

I see the xpt2046.py that appears to want an spi variable and a chip select pin. (which of course is good my my screen :) . What I'm not clear on is if the spi used for the touch should be the same as the spi pins that drives the screen output (but with a different chip select pin), a completely different set of spi pins just for the 5 touch screen pin connections, or perhaps also a different spi bus should be assigned. Also is the touch irq pin to be connected?

Do you have an example hardware_setup.py for the xpt2046 as the example one is just for the tsc2007 which uses i2c for the touch interface. That would help me in working my way through the code as I'm a bit befuddled at the moment. Apologies if I've missed something in the docs where this is all explained.

Thanks.

peterhinch commented 3 months ago

I'm still working on the docs :) I had neglected to include the setup_examples directory in the Git repo. I pushed it yesterday. You'll find an XPT2046 example.

I advise against using a single SPI bus. The display should have a hard SPI bus for its sole use. This is for two reasons:

  1. It needs to run at high speed for fast refreshes. The ILI9341 allows up to 30MHz.
  2. Display refreshes occur as a background task. Sharing the bus would require arbitration which would be tricky and would slow down the refresh.

The touch controller runs at 2.5MHz max (although in my testing I am running it at the default 1MHz). Hard or soft SPI may be used and speed is not critical.

Re Chinese units I bought two. One works well, but the other has a large dead zone in one touch axis. This is very evident: it was impossible to calibrate properly. The dead zone was obvious runningtouch.check on the uncalibrated display.

I'll review the docs to make sure this is clear.

Thanks for the comments - I'm keen to improve the docs.

beetlegigg commented 3 months ago

Thanks for the example setup file and the information on the SPI requirements, thats just what I needed to get started.