TFT_Touch_calibrate_v2 example with 800x480 touch screen

I currently have a BuyDisplay 800x480 TFT display with a resistive touch screen attached to a shield. Screen is a SSD1963 and touch screen is attached to a XPT2046 chip. The shield is attached to an Arduino Mega.
The shield s is set for hardware SPI.
The screen and touch screen work fine via UTFT and URTouch, and MCUFRIEND_kbv with XPT2046_TouchScreen or URTouch. Calibration routines on URTouch and XPT2046_TouchScreen work fine.
I wanted to try and use TFT_Touchscreen with MCUFRIEND_kbv.
The calibration example is designed to be use with TFT_ILI9341 library which is not compatiable with my TFT.
So I rewrote the TFT_Touch_calibrate_v2 example to use MCUFRIEND_kbv and a 800x480 screen
In Portrait setup, the example works fine. Coordinates reported are right and when you put the stylus on the screen, the green cross is right underneath and follows the stylus exactly.
In Landscape mode there is a problem. The coordinates are spot on after the calibration is run with the TL corner reading 4x15, TR corner reading 782x18, BL corner reading 2x478 and BR corner reading 791x464 when you test using the stylus, however the green cross is a quarter of a screen away horizontally. The calibration values reported are very close to each other no matter how many times you run is.
With the following cal values (337,3852,572,3662,800,480,0) entered in the sketch, after running the calibration routine the stylus and green cross go in opposite directions both vertically and horizontally
If I change the last value to "1" in the sketch cal value, the cal routine reports
(317, 3843, 82, 3595, 800, 480, 1) and the green cross is now half a screen away horizontally and it will follow the stylus vertically but in the opposite direction horizontally

As I would like to use my screen in a landscape direction and use TFT_Touch, I would like to get this calibration spot on.

I'd like to post the code but I keep getting warnings about ~~~ or </> formatting??

One other thing. I’d like to check is whether the cal data given on the serial port is accurate by entering it into an actual program. If it is, then it doesn’t matter if the green cross is inaccurate in the cal data routine.
Where do you enter the cal data? I see a file called calibrate.h in the library. Does it go in there? If so, where does it go?
Thanks
Edited.
I found the answer to where to put the cal data in a sketch so i will try that and see if its accurate even if the green crosses aren't.

Update.
I fed the cal figures I got from the screen in portrait rotation into the TFT_Touch_draw_2.4 example with the screen in Portrait mode and they were spot on.
Cal figures were (639, 3552, 3824, 307, 480, 800, 1)
This is where it gets weird. All I did was to change the screen and touch rotation (from (0) to (1) - Landscape (I didn't even change the order of 480,800 to 800,480) and it was spot on!! Lines followed the stylus and the colour palette was all selectable.

Yes, code tags, read this How to get the best out of this forum

Thanks Perry. All sorted now.

Thanks but it would be appreciated if you explained what the solution was both for my curiosity and for anyone in the future finding this topic and wanting to know the answer.

Thank you.

All sorted re how to put code into a forum message Perry.
If you look at my original post, it has the solution as well as the question. Ie. I found where to put the cal data and noted that once calibrated for portrait it was also calibrated when the display when rotated to Landscape.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.