To add to this experience, I had some trouble getting the URTouch calibration to work with my device. It would not calibrate correctly, the results I was getting just would not work as they should when copied over to the URTouchCD.h file.
So I set about trying to resolve the issue... and resolve it I did. In the end I actually manually calculated the hex value for CAL_S because the calibration results where way off base for that value.
To do this I opened windows calculator and set it to programming mode,
typed in 480 in decimal and then shift left 12 places and stored that in memory,
then I put in 1 and left shifted 31 places and then ored with the memory recall,
then ored the result with 320.
so... ((1 << 31) | (480 << 12)) | 320
Thus resulted in a closer working solution to the calibration problem, it would now happy display touch values close to the actual XY screen coordinates instead of displaying incorrect values as I note in the code segment below.
On further inspection of the value just now (XORING the resulting value from calibration and my calculated value) it appears the main difference is in portrait vs landscape flag, with a minor difference in the rest.
The result of 0x0013F1DFUL XOR 0x801DF13FUL is 0x800E00E0. So perhaps it was my own fault for failing to change the code in the calibration program to LANDSCAPE or something for why it did not seem to work as intended...
Anyway here is the code section from my modified UrTouchCD.h file
// 3.5" TFT ILI9488 shield for MEGA 2560 Calibrations
// My calibration Values from the calibration tool
// They did not work properly as they would return only the min (0,0) and max (320, 480) XY
// values only for any screen press depending on where the screen was
// pressed eg 0,480 / 320,0 / 0,0 / 320, 480
// #define CAL_X 0x020C8844UL
// #define CAL_Y 0x022687F6UL
// #define CAL_S 0x0013F1DFUL
// my manual calculations for landscape 480 x 320
// displayed touch responses getting closer to actual display XY coordinates now
// #define CAL_S 0x801DF13FUL
// Refined calculations for landscape 480 x 320 (setting X 495 Y 335)
// #define CAL_S 0x801EF14FUL
// Downloaded from github GitHub - dgolda/UTouch: UTouch fork configured for 3.5" TFT LCD from mcufriend.com
// Calibration values from DGOLDA
// #define CAL_X 0x002D4FADUL
// #define CAL_Y 0x03B440FCUL
// #define CAL_S 0x8018F0EFUL
// working calibration for my 3.5" screen
#define CAL_S 0x801EF14FUL // My refined manual calculation
#define CAL_X 0x002D4FADUL // DGOLDA Calibration Data
#define CAL_Y 0x03B440FCUL // DGOLDA Calibration Data
I am still trying to understand fully how the CAL_X and CAL_Y are created - in the code it looks mostly like it is just multiple sampling of the touch results into an array and averaging the results and then storing the results in 2 halves of the X and Y display. I get the impression this is to actually calibrate the touch sensitive area of the screen with the display area of the screen.
Still it is working so I probably do not really need to delve into the why and wherefore of how it works.