Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About coordinate systems #39

Open
nopnop2002 opened this issue Dec 26, 2021 · 0 comments
Open

About coordinate systems #39

nopnop2002 opened this issue Dec 26, 2021 · 0 comments

Comments

@nopnop2002
Copy link
Owner

nopnop2002 commented Dec 26, 2021

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                    |
+----------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant