Skip to content

on ILI9341 more pressure results in higher z values #22

@rtwfroody

Description

@rtwfroody

I have https://www.adafruit.com/product/2478, and the only way I can get it to work is with the following diff:

diff --git a/adafruit_touchscreen.py b/adafruit_touchscreen.py
index 5bf0fe0..4f28761 100644
--- a/adafruit_touchscreen.py
+++ b/adafruit_touchscreen.py
@@ -136,7 +136,7 @@ class Touchscreen:
                 with AnalogIn(self._yp_pin) as y_p:
                     z_2 = y_p.value
         # print(z_1, z_2)
-        z = 65535 - (z_2 - z_1)
+        z = z_2 + z_1
         if z > self._zthresh:
             with DigitalInOut(self._yp_pin) as y_p:

and a threshold value of around 40000.
Without this diff, the bottom right of the screen never registers a press.

I don't know much about these kinds of screens. Presumably this code works for other screens. Do some screens reverse this? I triple checked my wires and I don't think I wired anything backwards.

I also had to reverse the X calibration to make the coordinates correspond to the ones used when drawing on the screen:

                calibration=([59889, 12545], [16373, 61473]),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions