Arduino Due + Sainsmart 4.3" TFT / Shield = Touch works... then stops???

Hi,

A few months ago I purchased a couple of these for a project:

Sainsmart Due + TFT + Shield (eBay)

So now that 'life' has granted me a bit of spare time I am starting work on it...

After trawling the internet for tips and help I downloaded the UTFT Library, uncommented the CTE shield definition and entered the model as follows (which seemed to have worked for others):

UTFT myGLCD(ITDB43,25,26,27,28);

I then uploaded various of the example files to the Due and to my amazement, they all ran without any problems.

Impressed with my progress I then downloaded the UTouch Library and set about trying to calibrate the touch side of things...

... and here's where things got a bit less impressive.

I used the UTFT model details from above and set the pins as suggested by the instructions in the file, namely:

UTouch myTouch(6, 5, 4, 3, 2);

I then uploaded the calibration sketch to the Due.

When I touched the initial screen the crosshairs screen came up but would not respond to touches.
Resetting the Due resulted in no change. No touches were being registered (at least not apparently).

I then went for a hunt for a power adapter (thinking it may be underpowered from the USB).

Disconnecting from the USB and now powered from the wall socket (7.5v 1A) I was able to complete the calibration and the Due returned these values:

Displaytype : ITead Studio - ITDB02-4.3
Your CAL_X : 0x00000000UL
Your CAL_Y : 0x00000000UL
Your CAL_S : 0x801DF10FUL

However they appear to be incorrect (according to this link)

I have tried several times to repeat the calibration but each time I am unable to complete all the crosshairs. Sometimes I get no touches at all, sometimes I manage only to proceed past the initial screen, occasionally I get half way through the crosshairs.

I have tried this will all combinations of Displays / Shields / Dues from both sets with the same results each time.

I have had a very close look at all of the soldering on the shields and all appears to be good. Nothing messy or missing that I can see.

It seems that the longer I leave it unplugged the longer the touch functions work. Eventually it stops working each time.

I have learnt since my purchase that maybe this is not the best brand out there... but it's what I have and I would quite like to be able to use the touch functionality if possible.

Can anyone shed any light on what may be the root of the problem? (Human Error expected in one form or another)

Also can anyone recommend a better replacement option if all else fails?

Thanks.

Just to add - I'm using version 1.6.9 - in case that makes a difference.

Update...

I now have touches working, in a manner of speaking...

It appears that D_IN was not connected to pin 4, but instead to pin 32. Changing this in the pin set up has resulted in stable touch functionality (thus far) but there is still an issue.

The new values I get from calibration are along the lines of:

0x03EA8032UL (CAL_X)
0x039E40D5UL (CAL_Y)
0x801DF10FUL (CAL_S)

When I enter these values on the Calibration Data Verifier, I get the message:

Your CAL_X data seems to have switched left and right. This should not happen on a supported display module.
Your CAL_Y data seems to have switched left and right. This should not happen on a supported display module.

So the display is basically mirrored in both axis.

To verify this I pressed crosses on the calibration screen in reverse order and received perfectly good calibration codes.

Is thee something I can do to correct for this? Or will I need to do something like invert all the touch coordinates in my code. It seems to display everything in the correct orientation so maybe that would be a fairly simple work around...

Sort of solved... posting this in case it helps anyone else.

What I did:

I modified lines 103 & 104 in the UTouch_Calibration file to read:

tx += 4000 - myTouch.TP_X;
ty += 4000 - myTouch.TP_Y;

This gave me valid calibration results.

Then in the UTouch_Button file I modified lines 150 & 151 to read:

x = 480 - myTouch.getX();
y = 272 - myTouch.getY();

Which seems to give me working buttons.

The numbers I have used are just a rough estimate that may need some tweaking, but they seem pretty good so far for my displays.

Of course YMMV depending on your display but just print out the values for TP_X & TP_Y as you edge towards the limits of the screen and you should get there.

I guess the values for TP_X & TP_Y could be modified in the library using the defined values for touch_x and _y limits if required.

It might not be the only way, the best way, or even the right way to address this issue but (so far at least) I have something that does what I need it to. Any better suggestions appreciated.