Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions adafruit_touchscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def __init__(
samples: int = 4,
z_threshold: int = 10000,
calibration: Optional[Tuple[Tuple[int, int], Tuple[int, int]]] = None,
size: Optional[Tuple[int, int]] = None
size: Optional[Tuple[int, int]] = None,
invert_pressure: bool = True
) -> None:

self._xm_pin = x1_pin
Expand All @@ -119,6 +120,7 @@ def __init__(
self._calib = calibration
self._size = size
self._zthresh = z_threshold
self.invert_pressure = invert_pressure

@property
def touch_point(
Expand All @@ -136,7 +138,10 @@ def touch_point(
with AnalogIn(self._yp_pin) as y_p:
z_2 = y_p.value
# print(z_1, z_2)
z = 65535 - (z_2 - z_1)
if self.invert_pressure:
z = 65535 - (z_2 - z_1)
else:
z = z_2 + z_1
if z > self._zthresh:
with DigitalInOut(self._yp_pin) as y_p:
with DigitalInOut(self._ym_pin) as y_m:
Expand Down