GithubHelp home page GithubHelp logo

circuitpython_gt911's Issues

Lilygo T-Deck: I2C address is 0x5D, but reset is not connected

Thank you for this beautiful library. However, I have a problem with the I2C addresses on the T-Deck. I am not entirely sure if this is the correct spot in the schematic. If it is, then the reset pin for the touch device can't be controlled:

Bildschirmfoto von 2024-04-28 22 40 57

This means, I can't set the rst_pin parameter in the constructor of the GP911 class as suggested in your documentation.

According to the code, this means that the secondary address is chosen: 0x14. Unfortunately, the actual address should be 0x5D, at least for this board.

Only when I swap the addresses in your code, I get the expected result, touches can be detected:

Bildschirmfoto von 2024-04-28 22 46 33

My touch.py contains the code from your https://github.com/rgrizzell/CircuitPython_GT911/blob/main/examples/gt911_simpletest.py

Blinka compatibility (Raspberry Pi)

I think that this library is not compatible with Adafruit Blinka boards yet.
I would like to use this library on a Raspberry Pi. It looks like there are some major issues with the compatibility to this library.

(The TFT LCD works without any problems with the Adafruit_CircuitPython_RGB_Display library)

Here you can see the steps i tried to get this library running:

  1. Download the gt911.py and move it to my work directory
  2. Modified the example so it should work on my hardware - This is the code i used:
import time
import board
import gt911
import digitalio

# Pin declaration
interrupt_pin = digitalio.DigitalInOut(board.D17)
reset_pin = digitalio.DigitalInOut(board.D27)

i2c = board.I2C()

gt = gt911.GT911(i2c, int_pin=interrupt_pin, rst_pin=reset_pin)

while True:
    # Wait for a touch on the display
    for i, touch in enumerate(gt.touches):
        x, y, a = touch
        print(f"[{i+1}]({x},{y}) size:{a}")
    time.sleep(1)

And by executing, i get the following error message:

>>> %Run touchtest.py
Traceback (most recent call last):
  File "/home/pi/Desktop/touchtest.py", line 11, in <module>
    gt = gt911.GT911(i2c, int_pin=interrupt_pin, rst_pin=reset_pin)
  File "/home/pi/Desktop/gt911.py", line 82, in __init__
    self._reset()
  File "/home/pi/Desktop/gt911.py", line 135, in _reset
    self.int_pin.switch_to_output(
  File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 199, in switch_to_output
    self.drive_mode = drive_mode
  File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 278, in drive_mode
    self._pin.init(mode=Pin.OPEN_DRAIN)
AttributeError: type object 'Pin' has no attribute 'OPEN_DRAIN'

So after posting this error in the Adafruit Tech Support Forum here it seems like the Raspberry Pi does not have the Open Drain feature. I tried to fix this error by replacing the self._reset() command with a pass-statement in the init-function of the gt911.py. As a continued, i got the following error message as an output:

>>> %Run touchtest.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/i2c_device.py", line 175, in __probe_for_device
    self.i2c.writeto(self.device_address, b"")
  File "/usr/local/lib/python3.11/dist-packages/busio.py", line 213, in writeto
    return self._i2c.writeto(address, buffer, stop=True)
  File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 60, in writeto
    self._i2c_bus.write_bytes(address, buffer[start:end])
  File "/usr/local/lib/python3.11/dist-packages/Adafruit_PureIO/smbus.py", line 303, in write_bytes
    self._device.write(buf)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/i2c_device.py", line 181, in __probe_for_device
    self.i2c.readfrom_into(self.device_address, result)
  File "/usr/local/lib/python3.11/dist-packages/busio.py", line 203, in readfrom_into
    return self._i2c.readfrom_into(address, buffer, stop=True)
  File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 67, in readfrom_into
    readin = self._i2c_bus.read_bytes(address, end - start)
  File "/usr/local/lib/python3.11/dist-packages/Adafruit_PureIO/smbus.py", line 170, in read_bytes
    return self._device.read(number)
OSError: [Errno 5] Input/output error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/Desktop/touchtest.py", line 11, in <module>
    gt = gt911.GT911(i2c, int_pin=interrupt_pin, rst_pin=reset_pin)
  File "/home/pi/Desktop/gt911.py", line 94, in __init__
    self.i2c_device = I2CDevice(i2c, self._i2c_addr)
  File "/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/i2c_device.py", line 62, in __init__
    self.__probe_for_device()
  File "/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/i2c_device.py", line 184, in __probe_for_device
    raise ValueError("No I2C device at address: 0x%x" % self.device_address)
ValueError: No I2C device at address: 0x14

So because the I2C device was not recognized, i tried to execute the i2cdetect, which successfully detected a device on the address 5d. I changed the variable _GT_DEFAULT_I2C_ADDR to 0x14 and _GT_SECONDARY_I2C_ADDR to 0x5d and executed again. This time, the error message was much smaller, but the OSError / I/O error remains.

>>> %Run touchtest.py
Traceback (most recent call last):
  File "/home/pi/Desktop/touchtest.py", line 15, in <module>
    for i, touch in enumerate(gt.touches):
  File "/home/pi/Desktop/gt911.py", line 110, in touches
    data = self._read(_GT_POINT_START + i * 8, 8)
  File "/home/pi/Desktop/gt911.py", line 150, in _read
    i2c.write_then_readinto(payload, result)
  File "/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/i2c_device.py", line 140, in write_then_readinto
    self.i2c.writeto_then_readfrom(
  File "/usr/local/lib/python3.11/dist-packages/busio.py", line 230, in writeto_then_readfrom
    return self._i2c.writeto_then_readfrom(
  File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 98, in writeto_then_readfrom
    readin = self._i2c_bus.read_i2c_block_data(
  File "/usr/local/lib/python3.11/dist-packages/Adafruit_PureIO/smbus.py", line 264, in read_i2c_block_data
    ioctl(self._device.fileno(), I2C_RDWR, request)
OSError: [Errno 5] Input/output error

At this point, I have absolutely no idea how to continue or to verify if the stuff i tried even works correctly.
An native support for Adafruit Blinka would be pretty cool.

Installation via pip

To install the library on boards, which natively not run CircuitPython, but use Adafruit Blinka to emulate parts of CircuitPython, it is not possible to use the circup program, since it is not recognizing any CircuitPython devices.

With the integration of pip, it would be much more easy to implement the library on any Blinka-compatible board,
for example the Raspberry Pi

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.