ilbertt / XPT2046-Python

Python library for XPT2046 Touchscreen
10 stars 5 forks source link

AttributeError: 'DigitalOutputDevice' object has no attribute 'direction' #1

Closed mattmofr closed 3 years ago

mattmofr commented 3 years ago

Hi Luca8991,

I'm trying to use your driver for my TFT screen, but when running python3 touch-test.py I get an error from gpiozero stating :

Traceback (most recent call last):
  File "touch-test.py", line 19, in <module> xpt = Touch(spi, cs=cs, int_pin=irq, int_handler=touchscreen_press)
  File "/home/pi/XPT2046-Python/xpt2046.py", line 38, in __init__ self.cs.direction = digitalio.Direction.OUTPUT
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 147, in __setattr__ self.__class__.__name__, name))
AttributeError: 'DigitalOutputDevice' object has no attribute 'direction'

Hardware is Pi Zero W with circuit python and gpiozero installed.

Any clues ?

Thanks for your help,

Matt

ilbertt commented 3 years ago

As I can see from here, it seems that the direction attribute is not available anymore on DigitalOutputDevice class. Have you tried commenting out/removing line 38 of xpt2046.py? https://github.com/Luca8991/XPT2046-Python/blob/e835052333cddac4f73ec7fb3c081a33f0eb3a4a/xpt2046.py#L38 Then, rerun touch-test.py. Please let me know if this works.

mattmofr commented 3 years ago

Hi Luca,

Thank you for your help.

I commente out line 38. But also line 57 using the attribute Direction too. I also corrected line 62 self.int_pin.when_relesed = self.int_release by self.int_pin.when_released = self.int_release

Now system is looping without error but only printing None when uncommenting line 22 of touch-test.py

I need to look deeper in the code to see what is going but I'm missing time.

Take care,

Matt

ilbertt commented 3 years ago

Hi @mattmo92270, thanks to the @dgshue's #3 pull request, now it seems to work