Skip to content

Commit 40fb198

Browse files
authored
Merge pull request #454 from glennra/fix-touch-coords-mapping
Fix pointer coordinate mapping
2 parents c9235c8 + 8880411 commit 40fb198

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

api_drivers/py_api_drivers/frozen/indev/pointer_framework.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ def _get_coords(self):
7878
raise NotImplementedError
7979

8080
def _calc_coords(self, x, y):
81-
if self.is_calibrated:
81+
if self.is_calibrated:
8282
cal = self._cal
83+
84+
# save original x value for use in y calculation
85+
xt = x
8386
x = int(round(x * cal.alphaX + y * cal.betaX + cal.deltaX))
84-
y = int(round(x * cal.alphaY + y * cal.betaY + cal.deltaY))
87+
y = int(round(xt * cal.alphaY + y * cal.betaY + cal.deltaY))
8588

8689
if cal.mirrorX:
8790
x = self._orig_width - x - 1

api_drivers/py_api_drivers/frozen/indev/touch_calibration/touch_calibrate.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def calibrate(indev, cal_data):
109109
target.remove_flag(lv.obj.FLAG.CHECKABLE) # NOQA
110110
target.remove_flag(lv.obj.FLAG.SCROLLABLE) # NOQA
111111

112+
instruction_text = 'Press and hold\n red square'
112113
for i in range(3):
113114
print('point', i + 1, 'of 3')
114115

@@ -119,7 +120,7 @@ def calibrate(indev, cal_data):
119120
lcd_bus._pump_main_thread() # NOQA
120121
time.sleep_ms(2000) # NOQA
121122

122-
label.set_text('Press and hold\n red circle')
123+
label.set_text(instruction_text)
123124
label.center()
124125
lcd_bus._pump_main_thread() # NOQA
125126

@@ -142,7 +143,7 @@ def calibrate(indev, cal_data):
142143
if text_on:
143144
label.set_text('')
144145
else:
145-
label.set_text('Press and hold\n red circle')
146+
label.set_text(instruction_text)
146147
label.center()
147148

148149
text_on = not text_on
@@ -209,6 +210,7 @@ def calibrate(indev, cal_data):
209210
# else:
210211
# mirror_y = False
211212

213+
# The 3 point method uses an affine transformation so mirroring should not be needed.
212214
mirror_x = False
213215
mirror_y = False
214216

0 commit comments

Comments
 (0)