Adafruit is open and shipping! Let's build back better, together!
0

Resistive Touchscreen on Prod 1770 not returning values
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Resistive Touchscreen on Prod 1770 not returning values

by destockwell on Fri Oct 30, 2020 2:53 pm

Am trying to interface 2.8" 320x240 TFT with resistive touchscreen to RPi-0W using SPI (for display) and MCP3008 SPI for touchscreen

Display works fine, but touchscreen returns no good values.

SPI set up with MOSI, MISO, SCLK to normal pins on Cobbler breakout, shared with display. Display uses CE0/D8 for CS, MCP3008 uses CE1/D7. Swapping CS to another pin (D16) does not change result.

When running Python script, SPI-returned values do not change at all. Put ohmmeter across X+/X- and found about 343 ohms, no change wherever I touch. Across Y+/Y- less than an ohm, again no change wherever I touch.

I have an STMPE610 and will try it, but it looks like the touchscreen (or its interface) is borked.

Any ideas?


I like the two-sided breakout board.

destockwell
 
Posts: 18
Joined: Sun Sep 06, 2020 6:37 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by destockwell on Sat Oct 31, 2020 12:32 pm

I looked at the various photos of the Arduino connections and saw that instead of taking values directly off X+ and Y+, the wiring is a bit more complicated in that (for the Arduino, at least), the X- and Y+ need to be wired to analog (ADC) ports on the Arduino, and X+ and Y- to digital ports (which seem to be providing the voltage).

A further scan of the Arduino library provided for the device seemed to confirm this. It also showed me that the better approach will be to use the STMPE610 device: monitoring the momentary/noisy states of the touchscreen could take up most of the processing power of the device I am trying to build...

destockwell
 
Posts: 18
Joined: Sun Sep 06, 2020 6:37 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by adafruit_support_carter on Mon Nov 02, 2020 3:08 pm

Are you using one of these?
https://www.adafruit.com/product/1770

adafruit_support_carter
 
Posts: 17777
Joined: Tue Nov 29, 2016 2:45 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by destockwell on Mon Nov 02, 2020 4:10 pm

Yes, exactly...

destockwell
 
Posts: 18
Joined: Sun Sep 06, 2020 6:37 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by adafruit_support_carter on Mon Nov 02, 2020 4:15 pm

Try this:
https://learn.adafruit.com/adafruit-2-8 ... ouchscreen

You can checkout the library source to see what is actually being done with the pins to get a reading:
https://github.com/adafruit/Adafruit_To ... en.cpp#L78

adafruit_support_carter
 
Posts: 17777
Joined: Tue Nov 29, 2016 2:45 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by destockwell on Mon Nov 02, 2020 4:31 pm

Yes, I did that, but am not sure what to pass for the I2C parameter, as the device address on the I2C bus...an integer? An I2C object (how constructed?). Also, am using Python3 on RPi. Are these libraries/drivers compatible with Py3?

Thanks in advance. 45 years of software experience, but first with Python and RPi.

destockwell
 
Posts: 18
Joined: Sun Sep 06, 2020 6:37 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by adafruit_support_carter on Mon Nov 02, 2020 4:45 pm

Oh! Sorry, ignore that. I was thinking Arduino for some reason.

You're on a Pi. The Pi doesn't have analog in, so can't wire in the same fashion. So, yep, need to use something like the MCP3008 (to add analog in) or the STMPE610 which is specific to touch screen:
https://www.adafruit.com/product/1571

If you are using the MCP3008, you can use the Arduino code as a guide.

For the STMPE610, you can use this library:
https://github.com/adafruit/Adafruit_Ci ... n_STMPE610
You'll want to go through this first:
https://learn.adafruit.com/circuitpytho ... spberry-pi

Looks like the one example in the library is SPI based:
https://github.com/adafruit/Adafruit_Ci ... pletest.py

For I2C, you'd do something like:
Code: Select all | TOGGLE FULL SIZE
import board
from adafruit_stmpe610 import Adafruit_STMPE610_I2C

st = Adafruit_STMPE610_I2C(board.I2C())

It will use a default I2C address that way. If you need to specify address, then pass that in like this:
Code: Select all | TOGGLE FULL SIZE
st = Adafruit_STMPE610_I2C(board.I2C(), address=0x41)

You can use hex literals like that if you want. Or the integer equivalent.

adafruit_support_carter
 
Posts: 17777
Joined: Tue Nov 29, 2016 2:45 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by destockwell on Mon Nov 02, 2020 4:59 pm

Ah, board.I2C as the parameter. Exactly what I needed! Thanks. Will try using I2C, then if all is well, come back to SPI to sort out the issues found there.

destockwell
 
Posts: 18
Joined: Sun Sep 06, 2020 6:37 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by adafruit_support_carter on Mon Nov 02, 2020 8:41 pm

If you see code that looks like this:
Code: Select all | TOGGLE FULL SIZE
import board
import busio

i2c = busio.I2C(board.SCL, board.SDA)

that is equivalent to:
Code: Select all | TOGGLE FULL SIZE
import board

i2c = board.I2C()


The later feature was added at some point and some examples still have the older original boiler plate.

Either will work though.

adafruit_support_carter
 
Posts: 17777
Joined: Tue Nov 29, 2016 2:45 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by destockwell on Tue Nov 03, 2020 12:36 pm

Have successfully run the I2C version. Then switched back to the SPI version. It turns out that the real problem was that I declared the SPI bus as:

spi = busio.SPI(board.SCK, board.MOSI, board.MISO) and then
cs1 = digitalio.DigitalInOut(board.D7)
st = Adafruit_STMPE610_SPI(spi, cs1)

The problem was that in selecting SCK for the clock, this really refers to the I2C clock pin...

Replaced that with board.SCLK and things are happy. Then, since I am using hardware SPI anyway (but different Chip Select), have changing the st declaration to:

st = Adafruit_STMPE610_SPI(board.SPI(), cs1)

Still working. Suspect I can trim that further and will continue experiment as I learn my way around both Python3 and these libraries...what fun ;-)

destockwell
 
Posts: 18
Joined: Sun Sep 06, 2020 6:37 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by adafruit_support_carter on Tue Nov 03, 2020 1:56 pm

board.SCK and board. SCLK should be the same:
https://github.com/adafruit/Adafruit_Bl ... pin.py#L26

board.SCL is the I2C clock:
https://github.com/adafruit/Adafruit_Bl ... pin.py#L11

adafruit_support_carter
 
Posts: 17777
Joined: Tue Nov 29, 2016 2:45 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by destockwell on Tue Nov 03, 2020 2:10 pm

Sorry, I meant board.SCL, which I believe was the foundation of my SPI problem.

Thanks...

destockwell
 
Posts: 18
Joined: Sun Sep 06, 2020 6:37 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by adafruit_support_carter on Tue Nov 03, 2020 2:13 pm

Ah, OK. Yep, that would cause that issue.

adafruit_support_carter
 
Posts: 17777
Joined: Tue Nov 29, 2016 2:45 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by destockwell on Fri Nov 06, 2020 5:30 pm

One more related topic...

In CircuitPython, I can create a Pin object, e.g., board.D26 (hopefully) to trap an interrupt.

However, when I try to do so, I see that there is no mode attribute (e.g, Pin.IN) and no irq attribute to set up the callback.

What am I missing??

destockwell
 
Posts: 18
Joined: Sun Sep 06, 2020 6:37 pm

Re: Resistive Touchscreen on Prod 1770 not returning values

by destockwell on Sun Nov 08, 2020 8:18 pm

Looks like the following link may provide guidance on how to use interrupts to monitor my (relatively infrequently used) touchscreen...

https://raspi.tv/2013/how-to-use-interr ... pio-part-3

I will let you know how this turns out...

destockwell
 
Posts: 18
Joined: Sun Sep 06, 2020 6:37 pm

Please be positive and constructive with your questions and comments.