Skip to content

Commit 3e46e10

Browse files
authored
Merge pull request #25 from CedarGroveStudios/patch-1
Limit x and y values to pixel address maximum
2 parents d392b31 + 74fedf4 commit 3e46e10

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

adafruit_touchscreen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def touch_point(
158158
x_size = 65535
159159
if self._size:
160160
x_size = self._size[0]
161-
x = int(map_range(x, self._calib[0][0], self._calib[0][1], 0, x_size))
161+
x = int(map_range(x, self._calib[0][0], self._calib[0][1], 0, x_size - 1))
162162

163163
with DigitalInOut(self._xp_pin) as x_p:
164164
with DigitalInOut(self._xm_pin) as x_m:
@@ -173,7 +173,7 @@ def touch_point(
173173
y_size = 65535
174174
if self._size:
175175
y_size = self._size[1]
176-
y = int(map_range(y, self._calib[1][0], self._calib[1][1], 0, y_size))
176+
y = int(map_range(y, self._calib[1][0], self._calib[1][1], 0, y_size - 1))
177177

178178
return (x, y, z)
179179
return None

0 commit comments

Comments
 (0)