XPT2046 Touch Panel

Hi,

I am looking for some clarification. I have an XPT2046 driven touch panel (on an East Rising/Buy Display TFT).

There is no supplied Arduino code for it, and I have struggled to get it to work using URTouch (uses 'bitbanging' ) or spapadim library (uses SPI) .

However still early days as I am still trying... I am breaking out the pins of the TFT to run touch panel only.

My question is the actual chip requires

NOT CS and NOT PENIRQ (i.e Low or 0 is active)

and the libraries seem to assume

CS and PENIRQ ( i.e. High or 1 is active).

Can anyone confirm this is a problem and has anyone had a similar problem?

Also can someone confirm URTouch can work with an XPT2046 (google has failed me)?

Thanks

I'm dealing with a similar issue. My post is before yours with "3.2" with no Y axis." I've got a sketch uploaded it allows you to see the X & Y axis on the screen without using the serial monitor.
I think there's a compatibility issue with xpt2046, or possibly the URTouch library. I'm still hoping somebody has an idea. I have 3 screens now with perfect displays that all exibit the same issue.....not Y axis. Tried on 2 different sheilds.
It's probably somthing simple i screwed up on. My model numbers are on my post. See if they match your hardware.

Hi JoeySC,

Incredibly :slight_smile: I got my touch panel (XPT2046) to work last night. Short story .. there is a wiring problem on the supplied shield !!!!

Having had no success with URTouch and spapadim ( which is your XPT2046_master), I removed the shield and using DuPont jumpers wired only the power pins and the touch panel pins from the TFT into the shield ( on a Due).

The power pins were as before, but I wired the touch panel into the SPI pins on the shield and selected two other pins for CS and IRQ.

I then loaded the XPTPaint ( example from spapadim XPT2046_master) and stripped out all graphics commands and modified it to report X and Y readings to the Serial monitor (and set correct CS and IRQ pins definitions). I ran loaded the sketch and it worked instantly. The numbers were random but tracked my finger movements correctly... i.e the default calibration values were wrong for my panel.

Using the 'raw' function in the XPTcalibrate I worked out the left most, right most, top most, bottom most readings or I and J readings as the example calls them ... note J is X and I is Y on my TFT.

I then wrote two simple functions that converts raw readings to my pixel readings, I will make these more accurate later. So I now can read my touch panel and print out almost correct X and Y pixels.

So spapadim XPT2046_master does work DIRECTLY with the XPT2046 chip - it is expecting NOT CS and NOT IRQ.

My shield had an I2C interface that had only 4 pins wired to the touch panel (which has an SPI interface) , the DOUT on my touch panel was randomly wired to a RESET pin on the shield !!!!! Shield was for an earlier version of the touch panel.

On your post....my suggestions

  • If you are getting reasonable X values then we can assume your wiring must be right. Use the 'raw' function in XPTCalibrate to see what raw values you get.

  • Note if your Y values are ZERO you may have a mis calibration (in code). As you say you do get Y readings when you rotate. When I wrote my own calibration function using ints all values came out as zero, I then converted them to floats and they worked.

  • try wiring the touch panel and power only directly to your Arduino as a test( as I did.. if you have not).

I may try URTouch sometime, but XPT2046_master is so light weight and uses SPI which is readily available on my Due. Note ignore the NOT CS and NOT IRQ problem above - they are expected.

Hope that helps