@@ -77,50 +77,34 @@ def _get_coords(self):
77
77
# of (state, x, y) or None if no touch even has occured
78
78
raise NotImplementedError
79
79
80
- def _calc_coords (self , xt , yt ):
81
- """
82
- Convert the raw touch coordinates into screen coordinates using
83
- the calibration data if available.
84
- :param xt: The raw x coordinate from the touch device
85
- :param yt: The raw y coordinate from the touch device
86
- :return: The converted (x, y) screen coordinates
87
- """
88
-
89
- # xs, ys are the transformed screen coordinates
90
-
80
+ def _calc_coords (self , x , y ):
91
81
if self .is_calibrated :
92
82
cal = self ._cal
93
83
94
- xs = xt * cal .alphaX + yt * cal .betaX + cal .deltaX
95
- ys = xt * cal .alphaY + yt * cal .betaY + cal .deltaY
84
+ # save original x value for use in y calculation
85
+ xt = x
86
+ x = int (round (x * cal .alphaX + y * cal .betaX + cal .deltaX ))
87
+ y = int (round (xt * cal .alphaY + y * cal .betaY + cal .deltaY ))
96
88
97
- # The above transformation should take care of mirroring if the calibration
98
- # data has been collected using the 3 point calbration method. However,
99
- # maybe mirroring would be useful if swapping calibration data between displays
100
- # that are connected with the axes reversed.
101
89
if cal .mirrorX :
102
90
xs = self ._orig_width - xs - 1
103
91
if cal .mirrorY :
104
92
ys = self ._orig_height - ys - 1
105
93
else :
106
- # Assume touch coordinates map directly to screen coordinates
107
-
108
- xs , ys = xt , yt # initialise in case neither rotation is applied
109
-
110
94
if (
111
95
self ._startup_rotation == lv .DISPLAY_ROTATION ._180 or # NOQA
112
96
self ._startup_rotation == lv .DISPLAY_ROTATION ._270 # NOQA
113
97
):
114
- xs = self ._orig_width - xt - 1
115
- ys = self ._orig_height - yt - 1
98
+ x = self ._orig_width - x - 1
99
+ y = self ._orig_height - y - 1
116
100
117
101
if (
118
102
self ._startup_rotation == lv .DISPLAY_ROTATION ._90 or # NOQA
119
103
self ._startup_rotation == lv .DISPLAY_ROTATION ._270 # NOQA
120
104
):
121
- xs , ys = self ._orig_height - yt - 1 , xt
105
+ x , y = self ._orig_height - y - 1 , x
122
106
123
- return int ( round ( xs )), int ( round ( ys ))
107
+ return x , y
124
108
125
109
def _read (self , drv , data ): # NOQA
126
110
coords = self ._get_coords ()
0 commit comments