adafruit / Adafruit_CircuitPython_STMPE610

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

Add a `touch_point` parameter to `adafruit_stmpe610` for use with `adafruit_button` #21

Closed CedarGroveStudios closed 2 years ago

CedarGroveStudios commented 2 years ago

I have a slightly revised version of adafruit_stmpe610 that is working nicely with adafruit_button. Without changing the existing parameters and kwargs, I added a touch_point parameter and instantiation kwargs for display size and touch calibration (duplicating how adafruit_touchscreen works) as well as a new argument for display rotation. Defining the rotation at instantiation greatly simplifies usage particularly with on-screen buttons, something I'm planning to suggest for adafruit_touchscreen as well.

The current round of tests are being conducted using the 2.4" (#3315) and 3.5" (#3651) TFT wings with a Feather M4 Express running v7.1.1. The touchscreen's x-axis is reversed on the 3.5" TFT, so I'm planning to add another kwarg to flip the minimum/maximum touch axis values to accommodate the wiring difference.

Before proceeding with a PR, I need to know if the 2.4" and 3.5" TFT wings are the only Adafruit products using the STMPE610 controller. I wasn't able to find any others, but wanted to be certain before adding the touch axis flip kwarg.

@jerryneedell and @FoamyGuy : can you help?

Thanks!

new instantiation example without the proposed axis flip kwarg:

ts = adafruit_stmpe610.Adafruit_STMPE610_SPI(
            spi, ts_cs_pin, calibration=((357, 3812), (390, 3555)),
            size=(display.width, display.height), display_rotation=display.rotation,
        )
jerryneedell commented 2 years ago

There is also an STMPE610 breakout that can be used as desired…

Jerry Needell @.*** +1 603 969 6723

On Jan 19, 2022, at 13:35, Cedar Grove Maker Studios @.***> wrote:

 I have a slightly revised version of adafruit_stmpe610 that is working nicely with adafruit_button. I added a touch_point parameter and instantiation kwargs for display size and touch calibration (duplicating how adafruit_touchscreen works) as well as a new argument for display rotation. Defining the rotation at instantiation greatly simplifies usage particularly with on-screen buttons, something I'm planning to suggest for adafruit_touchscreen as well.

The current round of tests are being conducted using the 2.4" (#3315) and 3.5" (#3651) TFT wings with a Feather M4 Express running v7.1.1. The touchscreen's x-axis is reversed on the 3.5" TFT, so I'm planning to add another kwarg to flip the minimum/maximum touch axis values to accommodate the wiring difference.

Before proceeding with a PR, I need to know if the 2.4" and 3.5" TFT wings are the only Adafruit products using the STMPE610 controller. I wasn't able to find any others, but wanted to be certain before adding the touch axis flip kwarg.

@jerryneedell and @FoamyGuy : can you help?

Thanks!

new instantiation example without the proposed axis flip kwarg:

ts = adafruit_stmpe610.Adafruit_STMPE610_SPI( spi, ts_cs_pin, calibration=((357, 3812), (390, 3555)), size=(display.width, display.height), display_rotation=display.rotation, ) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

CedarGroveStudios commented 2 years ago

Ah yes, thanks. The discontinued #1571. I don't have one for testing but will anticipate that either or both axis ranges might need to be swapped since breakout wiring isn't fixed. Thinking about adding a kwarg like:

(... touch_flip=None ...)  # for no axis range change
(... touch_flip=(True, False) ...)  # to flip the touch x-axis range
(... touch_flip=(False, True) ...)  # to flip the touch y-axis range
(... touch_flip=(True, True) ...)  # to flip both touch axis ranges
jerryneedell commented 2 years ago

Ah -- I did not realize it had been discontinued -- then I would not worry about it. I do have one and will try to test the PR on it when its in if I can find it.... That axis flip kwarg sounds ok to me. It's been a long time since I looked at the driver. It was one of the very first things I ever did in python so I hope it was not to painful to modify....

CedarGroveStudios commented 2 years ago

I'd guess that there are a few of the old breakouts out there, but it's not likely that they'll need the new features unless they are repurposed. I'll add the more flexible version of the axis flip kwarg just in case. Walking through the driver code was a great experience. I know the approach to register management has changed a bit, but your code was easy to follow. Nicely done. I enjoy looking through other folks' code as part of my education 'cause I still feel like every python project I work on is my first.

CedarGroveStudios commented 2 years ago

Will submit a PR with the Displayio Button compatible touch_point property.