Thx, David !
Conceptually, it is indeed straightforward.
However, the details of implementation makes me curious.
Proposed code in post #19 uses two point calibration, which is OK for small TFT.
The goal of the calibration is to refine the default values (TS_MINX, TS_MAXX) for "improved" mapping.
Assuming no skew, the standard calibration equation is: x2=x1*k +a;
- k is a slope, and "a" is an offset;
- obviously k= (TS_MAXX-TS_MINX)/width, while I do not have a good idea how to define "a" via TMINX.
Pls see below excerpt from TS_calibration code, as in #19.
As you can see, both coefficients are calculated, using two sample points (opposite corners).
In the code derivation, I use, points p1, p2 are obtained via map(), using defaults TS_MINX, TS_MAXX (some manipulation should be implemented due to rotation of TFT screen vs. Touch screen).
The process starts with the defaults for LEFT-RIGHT (150, 930), which are used for 1st mapping "guess".
Then TS_MINX is being adjusted for the offset, but I don't understand the math behind the code...
Note:(width-20), (height-20) are used because two sample dots are shown with the offset of (10,10) from the corners.
Thx, VZ.
temp=p2.x-p1.x; // Calculate the new coefficients, get X difference
tempL=((long)temp*1024)/(tft.width()-20);
TS_MINX=p1.x-( (tempL*10)>>10);// 10 pixels du bord
TS_MAXX=p1.x+( (tempL*tft.width())>>10);// 220 pixels entre points
temp=p2.y-p1.y; // ¨get Y difference
tempL=((long)temp*1024)/(tft.height()-20);
TS_MINY=p1.y-( (tempL*10)>>10);// 10 pixels du bord
TS_MAXY=TS_MINY+( (tempL*tft.height())>>10);