Hi,
I am using an inkyphat display with the inkyphat library installed via sudo apt-get install python3-inkyphat
on a fresh install of the latest Raspbian Lite (2018-04-18 Stretch) on a Pi Zero W. I am intending to attach buttons, and update the display depending on what was pressed. I’m trying to use RPi.GPIO with the inkyphat library, but I’m having no luck. I’ve read the docs and looked at all the examples, neither of which mention GPIO, and looking at the library source shows that it is also using RPi.GPIO. Unfortunately I don’t know enough Python to go any further - I don’t know if it’s a quirk of the libraries or, more likely, simply me not knowing something obvious. I couldn’t find anything helpful via Google either, which is unusual.
It appears as though the inkyphat library is setting the GPIO mode to BCM (11), so it gives me an error when I try to set it myself, which I have to do in order to use the pins. I pared the script down to the absolute basics:
pi@raspberrypi:~ $ cat test.py
#!/usr/bin/env python3
import inkyphat
import RPi.GPIO as GPIO
print (GPIO.getmode())
#GPIO.setmode(GPIO.BCM)
GPIO.cleanup()
pi@raspberrypi:~ $ ./test.py
11
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/inkyphat/inky212x104.py", line 132, in _display_exit
self._display_fini()
File "/usr/lib/python3/dist-packages/inkyphat/inky212x104.py", line 230, in _v1_fini
self._busy_wait()
File "/usr/lib/python3/dist-packages/inkyphat/inky212x104.py", line 378, in _busy_wait
while(GPIO.input(self.busy_pin) != wait_for):
RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
… which is fair enough. However:
pi@raspberrypi:~ $ cat test.py
#!/usr/bin/env python3
import inkyphat
import RPi.GPIO as GPIO
print (GPIO.getmode())
GPIO.setmode(GPIO.BCM)
GPIO.cleanup()
pi@raspberrypi:~ $ ./test.py
11
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/inkyphat/inky212x104.py", line 132, in _display_exit
self._display_fini()
File "/usr/lib/python3/dist-packages/inkyphat/inky212x104.py", line 230, in _v1_fini
self._busy_wait()
File "/usr/lib/python3/dist-packages/inkyphat/inky212x104.py", line 378, in _busy_wait
while(GPIO.input(self.busy_pin) != wait_for):
RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
What’s the correct way to be able to use RPi.GPIO with inkyphat?
Thanks,
Lee