Use tslib for Android touch screen Calibration

Source: Internet
Author: User

 

 

1. Touch Screen calibration principle

For more information, see http://blog.sina.com.cn/wyw1976.

 

2. General Method of touch screen Calibration

The following formula is used to implement touch screen correction. XL, yl are the display coordinate, XT, and yt are the touch screen coordinate,

XL = XT * A + yt * B + C;

YL = yt * D + yt * E + F; formula (1)

 

Because the specific calculation is to be an integer operation, the abcdef actually saved is an integer, and a parameter div is added, which is implemented by the following companies:

XL = (XT * A + yt * B + C)/div;

YL = (yt * D + yt * E + F)/div; formula (2)

Therefore, the stored parameters are usually seven.

 

Generally, three sampling points can be used for calibration. tslib uses five sampling points for more accurate calibration.

 

3. Use the proc file system in Linux to implement touch screen correction

Android does not require touch screen calibration. Therefore, it is best to calibrate the touch screen completely in the underlying driver. The data obtained by Android is the calibrated coordinate data.

1) First, create a proc file during touchscreen driver loading, such:

Ts_proc_entry = create_proc_entry ("Driver/micc_ts", 0, null );

If (ts_proc_entry ){

Ts_proc_entry-> write_proc = ts_proc_write;

}

You can define your own proc data transfer format in ts_proc_write.

2) use the default parameters on the touchscreen driver to complete the calibration. If no calibration is required, set it:

A = 1, B = 0, c = 0, D = 0, E = 1, F = 0, DIV = 1

 

3) modify the tslib-ts_calibrate to obtain the required parameters A, B, C, D, E, F, div;

Note that the following parameters should be changed before running:

A = 1, B = 0, c = 0, D = 0, E = 1, F = 0, DIV = 1

For example:

Echo + A 1>/proc/driver/micc_ts

Echo + B 0>/proc/driver/micc_ts

Echo + C 0>/proc/driver/micc_ts

Echo + D 0>/proc/driver/micc_ts

Echo + E 1>/proc/driver/micc_ts

Echo + F 0>/proc/driver/micc_ts

Echo + G 1>/proc/driver/micc_ts

Make sure that ts_calibrate obtains the uncalibrated data and copies it to the/etc/directory.

 

4) Pass the parameter to the kernel.

After running ts_calibrate, A pointercal file is output. You 'd better modify the output format, as shown in the following code:

 

Cat $ tslib_calibfile>/proc/driver/micc_ts,

 

You can enter seven parameters at a time.

Of course, you can also input them one by one, which is too troublesome,

 

5) Use ts_test to test the calibration effect.

Note: ts_test does not calibrate the output data by default, and another calibration is performed. You need to change ts_read () in the main () function to ts_read_raw (). After running, the calibrated results are displayed.

 

6) when the Linux kernel is started, the calibration parameters are passed into the kernel.

Modify/etc/init. d/RCs and add the following lines to load the calibration data at startup:

CAT/etc/pointercal>/proc/driver/micc_ts

 

In this way, the calibrated data can be obtained by Directly Reading the touch screen data.

 

Related Article

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.