analysis of the touch screen calibration algorithmThis paper introduces a simple four-wire resistive touch screen calibration algorithm, the algorithm has been used in the actual project, the effect is good, we are relieved to use!
First, the preparatory work
1, set LCD resolution of LCDX,lcdy(such as:800X480)
2,LCD coordinates for the logical coordinates with L , touch screen coordinates for physical coordinates (AD value) with P Represents
3, touch the point logical coordinates (lx,ly) for the final coordinates
4, the principle of the use of touch by the physical coordinates of the point to find the logical coordinates of the point, the touch screen coordinates to convert to LCD coordinates
Second, the realization process:
1, on the LCD display 5 of the known logical coordinates of the point A1,B1,C1 , D1 , E1 .
2, starting from A1 Each display point, touch the corresponding point once, and then sequentially collect records 5 Physical coordinate points,
set it to a2 b2 c2 d2 , e2
3, by a2 b2 pfx c2 d2
By the A2,D2 of the ordinate averaging can be obtained Piy, by B2,C2 can be obtained by averaging the ordinate pgy .
(Note: Averaging is to make the physical coordinates collected more accurate)
4. By (3) (4) (5) (6) can find a touch screen4a limit physical coordinatePxmin,Pxmax,pymin|,Pymax, substituting it (1) (2) to find the logical coordinates of the pressed point (Px,PyThe physical coordinates of the captured point).
5, it can be seen that the key is to find the ultimate physical coordinates of the touch screen (that is, the leftmost, most right, the top, the bottom edge of the AD sample Value)
6, the essence of calibration is to re-determine the touch screen limit physical coordinates pxmin,Pxmax,pymin| , Pymax .
7, point E is used to determine whether the touch is valid. Use A2,B2,C2,D2 to calculate E2 , the calculated value is compared with the actual E2 compared with the sample values, the touch calibration is valid, but the difference is not valid, and the above process must be repeated until it is valid.
Four-wire resistive touch screen calibration