About coordinate systems
nopnop2002 opened this issue · 0 comments
There are two coordinate systems, physical and logical coordinates.
Logical coordinates are the positions of pixels on the TFT screen.
For a 240x320 TFT, the logical X coordinates range from 0 to 239, and the logical Y coordinates range from 0 to 319.
Logical coordinates can be changed according to the memory access control settings.
Physical coordinates are coordinates provided by hardware.
You can get the physical coordinates from XPT2046.
By performing calibration, you will get the conversion factor that will be converted from physical coordinates to logical coordinates.
Converts from physical coordinates to logical coordinates using the conversion factor.
-
When you touch the location of A:
physical coordinates from XPT2046 are x=134 y=114.
Physical coordinates are different values for each TFT.
For a 240x320 TFT, logical coordinates after conversion using the conversion factor are X = 239 and Y = 0.
For a 320x480 TFT, logical coordinates after conversion using the conversion factor are X = 319 and Y = 0.
The logical coordinates depend on the maximum resolution of the TFT. -
When you touch the location of B:
physical coordinates from XPT2046 are x=1809 y=1772.
For a 240x320 TFT, logical coordinates after conversion are X=0,Y=319.
For a 320x480 TFT, logical coordinates after conversion are X=0,Y=479. -
For a 240x320 TFT, the conversion coefficient is as follows.
X=fx(134)=239
Y=fy(114)=0
X=fx(1809)=0
Y=fy(1772)=319 -
For a 320x480 TFT, the conversion coefficient is as follows.
X=fx(134)=319
Y=fy(114)=0
X=fx(1809)=0
Y=fy(1772)=479
+----------------------+
| B |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| A |
+----------------------+
When you move the touch pen from A to a, only the X coordinate is updated.
+----------------------+
| B |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| A----------------->a |
+----------------------+
When you move the touch pen from A to a, only the Y coordinate is updated.
+----------------------+
| a B |
| ^ |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| A |
+----------------------+