Android touch screen coordinate manual calibration/adjustment successful

Source: Internet
Author: User
Tags dmesg

1. Brief Introduction
Coordinate Conversion for Android:
This implementation is a linear transformation using 7 Parameters
(A, B, C, D, E, F and S) to transform the device coordinates (XD, YD)
Into screen coordinates (XS, ys) using the following equations:

S * xs = A * XD + B * YD + c
S * ys = D * XD + E * YD + F
 
XS, YS: LCD coordinates
XD, YD: Touch screen coordinates

In the compiled Android root file system's system/etc/pointercal file, there are 7 data records,
The seven numbers correspond to A, B, C, D, E, F, S in the above formula.
For example, I used to: (if the table is not aligned, copy it to notepad)
+ ---- + ----- + -------- + ------ + -- + -------- + ---- +
| A | B | c | d | E | f | S |
+ ---- + ----- + -------- + ------ + -- + -------- + ---- +
|-411 | 37818 |-3636780 |-51325 | 39 | 47065584 | 6553 |
+ ---- + ----- + -------- + ------ + -- + -------- + ---- +

2. handling instructions:
The "system/etc/pointercal" file is read and used by Java programs. The file directory is as follows:
F rameworks/base/services/Java/COM/Android/Server/inputdevice. Java
--- Note: I use the koolu source code (http://git.koolu.org/), please search for the official source code.
Line 1 of this file defines: static final string calibration_file = "/system/etc/pointercal ";
The calibration_file variable is used to open the file in row 237th:
Fileinputstream is = new fileinputstream (calibration_file );
The code below reads the seven data records from the file for the upper-layer function coordinate conversion.
Therefore, you only need to manually calculate the seven values based on the formula, and then you can perform the touch operation accurately.

3. Computing
We need to obtain the coordinates of the four touch screens before calculation. We need to take the coordinates of the four diagonal axes of the LCD, because only the four coordinates know the exact LCD coordinates.
To take coordinates, you must turn on the touch screen debugging code in the kernel. After startup, you can use the dmesg command on the console to trace and obtain the coordinates.
I clicked a pen on a corner, used dmesg to call up the record, and then recorded it. The following is the result of my 320x240 screen record:
The touch screen coordinates provided by the debugging information are in the parentheses () in the coordinate axis, and the LCD coordinates are in the brackets.

X coordinate
/| \
| (X: 870, Y: 140) (X: 870, Y: 890)
| [320,240] []
|
|
|
+ -------------------------------> Y coordinate
(X: 120, Y: 140) (X: 120, Y: 890)
[0,240] []

* LCD resolution: 320x240, which is also the maximum value of the LCD coordinate.
X Y

Set S = 65536.
The four coordinates can be substituted into the formula to produce eight equations.

0 = A * 120 + B * 140 + c
0 = D * 120 + E * 140 + F
0 = A * 120 + B * 890 + c
65536*240 = D * 120 + E * 890 + F
65536*320 = A * 870 + B * 140 + c
0 = D * 870 + E * 140 + F
65536*320 = A * 870 + B * 890 + c
65536*240 = D * 870 + E * 890 + F
After solving the equations, you can:
A = 0
B = 20971
C =-2935940
D = 27962
E = 0
F =-3355440
S = 65535
Then, use a tool to open andriod's "system/etc/pointercal" file, input these numbers, and separate them with spaces,
Do not change the two byte 0x00 0x0a at the end of the file. I opened it using the ghex tool and input it in the right window. In the compile window, you can switch the insert and overwrite modes.
Start at this time.

////////////////////////////
After the screen reaches this step, the left and right operations are changed to up and down operations,
Solution: Correct the values A, B, C, D, E, and F respectively.
Try again ..
Or not, the left and right are correct, and the up and down are reversed.
Solution:
The formula that reversely returns Y coordinates:
YS '= 320-Ys = 320-(A * XD + B * YD + C)/s
Re-calculate the values of A, B, and C.

Now I click the calculator button and other operations are very accurate.

The coordinates in the video above are the coordinates adjusted in the kernel, which is not very accurate.

This is a manual method. If you want to use the program for calibration, you can use tslib and try again later.

Note: The Development Board I used is mini2440 and the LCD screen is 320x240.


Http://blog.21ic.com/user1/2537/archives/2009/61231.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.