adafruit / Adafruit_CircuitPython_STMPE610

Adafruit CircuitPython driver for the STMPE610 resistive touchscreen controller
MIT License
1 stars 10 forks source link

Add `touch_point` parameter for compatibility with Displayio Button #22

Closed CedarGroveStudios closed 2 years ago

CedarGroveStudios commented 2 years ago

Added a touch_point parameter and some instantiation kwargs for display size, touch calibration (duplicating how adafruit_touchscreen works) as well as kwargs for display rotation and touch axis range reversal. The existing arguments and parameters were not altered, allowing backward compatibility.

The touch_flip kwarg was needed because the touchscreen's x-axis is reversed on the 3.5" TFT Wing compared to the 2.4" TFT Wing (a PCB wiring difference). This argument also supports potential wiring configuration issues related to the Resistive Touch Screen Controller - STMPE610 breakout board (#1571).

Also added three examples that exploit the touch_point parameter. Two show alternative methods for the existing simple paint demo and simpletest. The third is an example of use with Displayio Button.

A touchscreen calibration method was added to the examples folder. The calibrator is used to empirically measure touchscreen x and y axis minimum/maximum raw values. The resulting tuple is used in the STMPE610 instantiation statement to significantly improve touchscreen accuracy.

Tests were conducted using the 2.4" (#3315) and 3.5" (#3651) TFT display Wings with a Feather M4 Express running CircuitPython v7.1.1.

jerryneedell commented 2 years ago

I tested all but the calibration demo with a 2.4 inch TFT Featherwing on a GrandCentral M4 -- all worked well. Where can I find the OpenSans-9.bdf font file to try the Calibration demo?

jerryneedell commented 2 years ago

Also verified that the stmpe610_touch_point_simpletest works via I2C with an stmpe610 breakout on a qtpy esp32s2 and on the grand central m4. Note - I2C is not used by any of the tft boards with the stmpe610. It is available on the breakout board and sometime result in issues (Unsupported operation) This is not new to this PR. I don't see that an issue was ever opened for it, likely because it is never used...and even that the breakout board is no longer sold, probably not worth pursuing. I wonder if we should drop the I2C support entirely. I will raise that is a separate issue after looking into it a bit more. See #23

jerryneedell commented 2 years ago

Tested axes flip -- worked nicely!

CedarGroveStudios commented 2 years ago

I tested all but the calibration demo with a 2.4 inch TFT Featherwing on a GrandCentral M4 -- all worked well. Where can I find the OpenSans-9.bdf font file to try the Calibration demo?

Thank you for the review! The latest version (just submitted) replaces the potentially-licensed font with terminalio.FONT.

jerryneedell commented 2 years ago

I tested all but the calibration demo with a 2.4 inch TFT Featherwing on a GrandCentral M4 -- all worked well. Where can I find the OpenSans-9.bdf font file to try the Calibration demo?

Thanks for changing the font to the default. I ran the touch_calibrator_stmpe610.py on a GrandCentral M4 with a 2.4inch TFT -- worked well.

Thanks for adding this compatibility with the touchscreen library.