GithubHelp home page GithubHelp logo

Comments (8)

briankaemingk avatar briankaemingk commented on June 12, 2024 1

thanks for assigning this/helping me out, @ladyada and @makermelissa . i did a little more debugging.. this particular error is caused after the first get version/initialization step fails.

in other words, it tries to find the stmpe610 version first on this line. That version check fails (the version returned is 0x0).

next, it executes the following code to switch the polarity, related to this issue

            # if it fails try SPI MODE 1  -- that is what Arduino does
            self._spi = spidev.SPIDevice(spi, cs, baudrate=baudrate, polarity=0, phase=1)

it then tries to find the stmpe610 version on this line. that is when i get the below error:

Traceback (most recent call last):
  File "examples/stmpe610_simpletest.py", line 12, in <module>
    st = Adafruit_STMPE610_SPI(spi, cs)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_stmpe610.py", line 278, in __init__
    version = self.get_version
  File "/usr/local/lib/python3.7/dist-packages/adafruit_stmpe610.py", line 193, in get_version
    v_1 = self._read_byte(0)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_stmpe610.py", line 164, in _read_byte
    return self._read_register(register, 1)[0]
  File "/usr/local/lib/python3.7/dist-packages/adafruit_stmpe610.py", line 291, in _read_register
    spi.write(bytearray([register]))
  File "/usr/local/lib/python3.7/dist-packages/busio.py", line 325, in write
    return self._spi.write(buf, start, end)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 81, in write
    self._spi.mode = self.mode
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/spi.py", line 355, in mode
    self._ioctl(SPI._IOC_WR_MODE, mode)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/spi.py", line 224, in _ioctl
    ioctl(self.handle, ioctl_bytes, arg)
OSError: [Errno 22] Invalid argument

from adafruit_circuitpython_stmpe610.

briankaemingk avatar briankaemingk commented on June 12, 2024 1

Thanks for your efforts, @makermelissa. Hoping this will make things better for users down the road.

from adafruit_circuitpython_stmpe610.

ladyada avatar ladyada commented on June 12, 2024

if you have the kernel overlay you cannot connect to it over SPI 'user space' - you can only do one or the other.

from adafruit_circuitpython_stmpe610.

briankaemingk avatar briankaemingk commented on June 12, 2024

Thanks for the quick response, @ladyada. Trying to interpret and get to a next step... Not sure if I have the kernel overlay, just installed Buster as directed.. Should I try this all as root or...?

from adafruit_circuitpython_stmpe610.

ladyada avatar ladyada commented on June 12, 2024

oh you just mean overlay, not kernel overlay. not sure what it is then, we'll leave this open for now!

from adafruit_circuitpython_stmpe610.

briankaemingk avatar briankaemingk commented on June 12, 2024

ah, yes, the touch overlay is what i mean, which i have used in the past to great success with this microcontroller. the example "make my day" script works like a charm, but now, alas, no dice. not sure what, if anything, changed. also, not really sure how to debug it....

any logs i can provide? any tips from users is much appreciated.

from adafruit_circuitpython_stmpe610.

briankaemingk avatar briankaemingk commented on June 12, 2024

Hi everyone,

Just another quick update here. We just got the chip working by pulling "up" the MODE pin on the breakout board (aka setting it to 1). We did this physically on the board by connecting the MODE pin to an open 3.3v pin on the raspberry pi and cycling power to the controller. There is also probably a way to do it via python, which we will try next.

So, it seems like our board was in I2C mode, which initially cause it to fail the version check and not find the board. Then it switched the polarity to try to initialize with...

# if it fails try SPI MODE 1  -- that is what Arduino does
            self._spi = spidev.SPIDevice(spi, cs, baudrate=baudrate, polarity=0, phase=1)

After it ran that, for some reason it couldn't read the output it got back about the version, and it errored out with the below. So maybe there is a way for a more descriptive error message or something, or a warning about setting the controller to SPI mode...? Hope that helps, let me know if you need anything more to help debug. Thanks for the great stuff, Adafruit!! Love playing with it.

  File "examples/stmpe610_simpletest.py", line 12, in <module>
    st = Adafruit_STMPE610_SPI(spi, cs)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_stmpe610.py", line 278, in __init__
    version = self.get_version
  File "/usr/local/lib/python3.7/dist-packages/adafruit_stmpe610.py", line 193, in get_version
    v_1 = self._read_byte(0)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_stmpe610.py", line 164, in _read_byte
    return self._read_register(register, 1)[0]
  File "/usr/local/lib/python3.7/dist-packages/adafruit_stmpe610.py", line 291, in _read_register
    spi.write(bytearray([register]))
  File "/usr/local/lib/python3.7/dist-packages/busio.py", line 325, in write
    return self._spi.write(buf, start, end)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 81, in write
    self._spi.mode = self.mode
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/spi.py", line 355, in mode
    self._ioctl(SPI._IOC_WR_MODE, mode)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/spi.py", line 224, in _ioctl
    ioctl(self.handle, ioctl_bytes, arg)
OSError: [Errno 22] Invalid argument

from adafruit_circuitpython_stmpe610.

makermelissa avatar makermelissa commented on June 12, 2024

I've been trying various strategies to try and reproduce this error without much luck. I also found it defaulted to I2C mode and tying the mode to 3.3v and then fully shutting down the pi and restarting got it working, though I suspect removing power from the breakout for a minute or so would have also worked due to capacitors.

I have tried reproducing the error with both a Raspberry Pi 4 and a Raspberry Pi Zero WH running the latest Raspberry Pi OS. I even tried forcing it to Mode 1 (which didn't work, but didn't produce the OSError). The only states I was able to get are working or I2C mode.

I like your suggestion about making the error message a bit better, so I think I will go with that for the fix.

from adafruit_circuitpython_stmpe610.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.