Library for XPT2406 TouchScreen on UNO - Solved #7

I am using a 3.2" TFT LCD with touch screen as a shield on UNO.

The LCD uses the popular ILI9341 and the Touch uses the XPT2406.

For the LCD I am using the Adafruit_GFX and Adafruit_ILI9341 libraries. All well.

I want a matching XPT2406 library for the touch screen.

Any suggestions ?

Thanks

Tools->Library Manager : XPT2046_Touchscreen

Note that this library expects the XPT2046 to be on the hardware SPI bus.

If you use software pins, you need the URTouch library from Henning Karlsen (but for some reason he will not participate in the IDE Library Manager)

I strongly advise you to always use libraries from the IDE Library Manager.

David.

@david_prentice

Yes I did notice this from PJRC while searching but then thought it would be specific to Teensy family.

Anyway when I tried to use the XPT2046_Touchscreen it also asked for the ILI9341_t3

I hope these work with UNO. Will check out and let you know. ( My implementation is hardwired SPI and so no issues )

Thanks for the help and also the note about working only with libraries that are recognized by the Library manager.

Ardubit:
@david_prentice

Yes I did notice this from PJRC while searching but then thought it would be specific to Teensy family.

Anyway when I tried to use the XPT2046_Touchscreen it also asked for the ILI9341_t3

I hope these work with UNO. Will check out and let you know. ( My implementation is hardwired SPI and so no issues )

Thanks for the help and also the note about working only with libraries that are recognized by the Library manager.

The same :frowning:

@david_prentice

Well as expected the PJRC libraries did not go well. I did download and install the XPT2046_TouchScreen and ILI9431-t3 libraries.

The one problem I have always faced with PJRC libraries is that when it comes to WIRE or SPI libraries the original Arduino ones don't work.

And so also in this case when I tried to compile even the examples that shipped with the ILI9341_t3 library or XPT2046_Touchscreen library for UNO board, I got many errors and finally it gave up.

Looks like this is not going to work and will need to look around for XPT2046 library that is designed for UNO or MEGA.

( I am sure someone very conversant with C++ can work around the error messages but I am not :frowning:

Rubbish.

I have always used XPT2046_Touchscreen with ILI9341 displays on a 3.3V Uno.
Often with Adafruit_ILI9341 library.

From memory, current ILI9341_t3 only works with Teensy.
Original ILI9341_t3 worked on Uno.

If you state what display hardware, which library and which target you want to use, you will get an accurate answer.

Most importantly. Do you provide appropriate logic levels? e.g. 3.3V logic for a 3.3V ILI9341

David.

I am sorry for the scanty info that got you annoyed !

The complete details of the shield can be had from here :

Waveshar_3.2InchTFT_Display

Thanks !

I have the Waveshare 2.8 inch shield which uses a HX8347D
Your Waveshare 3.2 inch shield uses ILI9341 and has similar pinout.

The pcb is well designed and should work 100%.

Install the XPT2046_Touchscreen library via the IDE Library Manager.

I attach a couple of projects. I hope that they will run out of the box for you.

David.

button_mult_demo.zip (6.77 KB)

XPT2046_Calibration.zip (18.7 KB)

Tried the button_mult_demo.ino with the 3.2" TFT shield on a UNO. Just had to add one line to enable the Back light and apart from that rest worked as is . Good.

I have one issue though .. there was this left to right swap ! Like in the slider I had to click INC to decrease value and vice versa.

Since the TP is hardwired I am not sure what would be an easy fix for this ?

Appreciate your patient support and sending working codes.

Touch panels come in all shapes and sizes. That is why you calibrate them.
I have two identical Red SPI Touch displays. The touch directions are different.

Select the Paint button. You might have to click a mirrored position on the screen.

Draw a horizontal line. Observe direction.
Draw a vertical line. Observe direction.

If vertical is backwards, swap the TS_LEFT, TS_RT values. Because the TS_XXX values refer to the Portrait calibration.

The ideal solution is to run the Calibration sketch.

David.

david_prentice:
Touch panels come in all shapes and sizes. That is why you calibrate them.
I have two identical Red SPI Touch displays. The touch directions are different.

Select the Paint button. You might have to click a mirrored position on the screen.

Draw a horizontal line. Observe direction.
Draw a vertical line. Observe direction.

If vertical is backwards, swap the TS_LEFT, TS_RT values. Because the TS_XXX values refer to the Portrait calibration.

The ideal solution is to run the Calibration sketch.

David.

Finally that did it. Its working perfect as expected after I did the calibration. Thank you so much … but for your support I don't think it would have happened this fast or happened at all !!

Well I now have to go through both codes that you sent and understand many things about the Touch screens. Good home work for the week end !

Have a great weekend.