Tft/lcd on raspberry (gpio and python)?

Hi,

Id like your RTFM/help as Im not familiar with GPIO/TFTs. I lost contact with amtels 10+ years and I think my brain is way behind current knowledge..
So I have zero rpi/gpio knowledge lets say...

I got a Adafruit 1.3" Color TFT Bonnet for Raspberry Pi - 240x240 TFT + Joystick Add-on to play with, so I can build a menu system and control some scripts without ssh/web etc.

I tried to follow:
https://learn.adafruit.com/adafruit-1-3-color-tft-bonnet-for-raspberry-pi

and a couple of threads here about lcd/tft and rpi.gpio but Im not geeting to the end... for example rpi.gpio fails (error attached).

Has anyone used any of these tft with python to display something?

system is official openwrt on pi 3 B+

root@OpenWrt:~# opkg install python3-pip
xxx
root@OpenWrt:~# opkg install python3-pillow
xxx
Configuring libpng.
Configuring libfreetype.
Configuring libjpeg-turbo.
Configuring libtiff5.
Configuring python3-pillow.
root@OpenWrt:~# opkg install python3-numpy
Configuring python3-numpy.
root@OpenWrt:~# opkg install dejavu-fonts-ttf-DejaVuSerif dejavu-fonts-ttf-DejaVuSans
Configuring dejavu-fonts-ttf-DejaVuSans.
Configuring dejavu-fonts-ttf-DejaVuSerif.

root@OpenWrt:~# opkg install i2c-tools kmod-i2c-algo-bit kmod-i2c-algo-pcf kmod-i2c-core kmod-i2c-gpio kmod-i2c-mux libi2c python3-smbus

Package i2c-tools (4.3-1) installed in root is up to date.
Package kmod-i2c-algo-bit (5.4.154-1) installed in root is up to date.
Package kmod-i2c-algo-pcf (5.4.154-1) installed in root is up to date.
Package kmod-i2c-core (5.4.154-1) installed in root is up to date.
Package kmod-i2c-gpio (5.4.154-1) installed in root is up to date.
Package kmod-i2c-mux (5.4.154-1) installed in root is up to date.
Package libi2c (4.3-1) installed in root is up to date.
Package python3-smbus (4.3-1) installed in root is up to date.

root@OpenWrt:~# opkg install gcc
Configuring libbfd.
Configuring libopcodes.
Configuring libctf.
Configuring objdump.
Configuring ar.
Configuring binutils.
Configuring libstdcpp6.
Configuring gcc.

root@OpenWrt:~# opkg install python3-dev python3-setuptools
Package python3-setuptools (58.1.0-1) installed in root is up to date.
Configuring python3-lib2to3.
Configuring python3-dev.

root@OpenWrt:~# pip3 install virtualenv
Successfully installed distlib-0.3.4 filelock-3.4.2 platformdirs-2.4.1 six-1.16.0 virtualenv-20.13.1

root@OpenWrt:~# pip3 install wheel
Successfully installed wheel-0.37.1

root@OpenWrt:~# /usr/bin/python3 -m pip install --upgrade pip
Successfully installed pip-22.0.3

Main error

root@OpenWrt:~# pip3 install adafruit-circuitpython-rgb-display
Collecting adafruit-circuitpython-rgb-display
  Downloading adafruit-circuitpython-rgb-display-3.10.11.tar.gz (43 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.0/43.0 KB 1.4 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting Adafruit-Blinka
  Downloading Adafruit-Blinka-6.20.1.tar.gz (156 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 156.0/156.0 KB 1.7 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting adafruit-circuitpython-busdevice
  Downloading adafruit-circuitpython-busdevice-5.1.2.tar.gz (28 kB)
  Preparing metadata (setup.py) ... done
Collecting Adafruit-PlatformDetect>=3.13.0
  Downloading Adafruit-PlatformDetect-3.19.5.tar.gz (39 kB)
  Preparing metadata (setup.py) ... done
Collecting Adafruit-PureIO>=1.1.7
  Downloading Adafruit_PureIO-1.1.9.tar.gz (26 kB)
  Preparing metadata (setup.py) ... done
Collecting RPi.GPIO
  Using cached RPi.GPIO-0.7.1.tar.gz (29 kB)
  Preparing metadata (setup.py) ... done
Collecting pyftdi>=0.40.0
  Downloading pyftdi-0.53.3-py3-none-any.whl (141 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 141.5/141.5 KB 1.4 MB/s eta 0:00:00
Collecting rpi_ws281x>=4.0.0
  Downloading rpi_ws281x-4.3.1.tar.gz (64 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 64.1/64.1 KB 1.9 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting sysv_ipc>=1.1.0
  Downloading sysv_ipc-1.1.0.tar.gz (99 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 99.4/99.4 KB 1.3 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pyusb!=1.2.0,>=1.0.0 in /usr/lib/python3.9/site-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-rgb-display) (1.2.1)
Requirement already satisfied: pyserial>=3.0 in /usr/lib/python3.9/site-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-rgb-display) (3.5)
Building wheels for collected packages: adafruit-circuitpython-rgb-display, Adafruit-Blinka, adafruit-circuitpython-busdevice, Adafruit-PlatformDetect, Adafruit-PureIO, rpi_ws281x, sysv_ipc, RPi.GPIO
  Building wheel for adafruit-circuitpython-rgb-display (setup.py) ... done
  Created wheel for adafruit-circuitpython-rgb-display: filename=adafruit_circuitpython_rgb_display-3.10.11-py3-none-any.whl size=19483 sha256=fee1519d98ad46186ce197cb0ab48b74eb67ae1cb62a6d56b9c85c067d951cc0
  Stored in directory: /tmp/.cache/wheels/fc/2d/3a/8451522bce402b219bbd376811273e83d48ba9a20c8222b2b0
  Building wheel for Adafruit-Blinka (setup.py) ... done
  Created wheel for Adafruit-Blinka: filename=Adafruit_Blinka-6.20.1-py3-none-any.whl size=194776 sha256=c3e2e2437766f77584227b31b51b8e716ce46e19d1915a74e8ecf7b2605531f3
  Stored in directory: /tmp/.cache/wheels/88/ac/20/8ca8b157e2fdd80236d469d15b065dcf48efb84bd838df112b
  Building wheel for adafruit-circuitpython-busdevice (setup.py) ... done
  Created wheel for adafruit-circuitpython-busdevice: filename=adafruit_circuitpython_busdevice-5.1.2-py3-none-any.whl size=6947 sha256=a52f6400257e8a0810ff5dfde01624aeadb9ad73185564b04b84abe3b25a52ec
  Stored in directory: /tmp/.cache/wheels/45/39/4f/34c760c8d6132ed22f61b0f6c05212008c9c18fd20d2a03e57
  Building wheel for Adafruit-PlatformDetect (setup.py) ... done
  Created wheel for Adafruit-PlatformDetect: filename=Adafruit_PlatformDetect-3.19.5-py3-none-any.whl size=18029 sha256=62f191bc6f0ebf504163505b1f6f75200997dfa86f41b1ae7c2f1114d0198e73
  Stored in directory: /tmp/.cache/wheels/5b/f6/d0/cf174ce6d4de0bd4ed393becc1e72e3678b8cdabcf1992f893
  Building wheel for Adafruit-PureIO (setup.py) ... done
  Created wheel for Adafruit-PureIO: filename=Adafruit_PureIO-1.1.9-py3-none-any.whl size=11603 sha256=acfb9e4866790b45bdedbba05b635327b15ec404c0b98283d624ec992dae949b
  Stored in directory: /tmp/.cache/wheels/1b/3f/d0/fdbf50a2da5efd11b7dc632e0fbf8b77b82bc304c0ded6c206
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for rpi_ws281x (setup.py) ... error
  ERROR: Failed building wheel for rpi_ws281x
  Running setup.py clean for rpi_ws281x
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for sysv_ipc (setup.py) ... error
  ERROR: Failed building wheel for sysv_ipc
  Running setup.py clean for sysv_ipc
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for RPi.GPIO (setup.py) ... error
  ERROR: Failed building wheel for RPi.GPIO
  Running setup.py clean for RPi.GPIO
Successfully built adafruit-circuitpython-rgb-display Adafruit-Blinka adafruit-circuitpython-busdevice Adafruit-PlatformDetect Adafruit-PureIO
Failed to build rpi_ws281x sysv_ipc RPi.GPIO
Installing collected packages: sysv_ipc, rpi_ws281x, RPi.GPIO, pyftdi, Adafruit-PureIO, Adafruit-PlatformDetect, Adafruit-Blinka, adafruit-circuitpython-busdevice, adafruit-circuitpython-rgb-display
  error: subprocess-exited-with-error

  × Running setup.py install for sysv_ipc did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Running setup.py install for sysv_ipc ... error
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> sysv_ipc

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
root@OpenWrt:~#

RPI.gpio on its own:

root@OpenWrt:~# pip3 install rpi.gpio
Collecting rpi.gpio
  Using cached RPi.GPIO-0.7.1.tar.gz (29 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: rpi.gpio
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for rpi.gpio (setup.py) ... error
  ERROR: Failed building wheel for rpi.gpio
  Running setup.py clean for rpi.gpio
Failed to build rpi.gpio
Installing collected packages: rpi.gpio
  error: subprocess-exited-with-error

  × Running setup.py install for rpi.gpio did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Running setup.py install for rpi.gpio ... error
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> rpi.gpio

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
root@OpenWrt:~#

Im not sure what Im missing with enabling i2c and spi on this Pi3B+.

I have added all of them (and in combinations..):

dtparam=i2c_arm=on
dtparam=i2c0=on
dtparam=i2c1=on
dtparam=spi=on
dtparam=i2s=on

and installed a number of i2c and gpio related opkgs.

It seems to be way easier on other posts so im not sure if Im missing something silly...
Any help?!

root@OpenWrt:~# i2cdetect 0
Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory
root@OpenWrt:~# ls -la /dev/i2c*
ls: /dev/i2c*: No such file or directory
root@OpenWrt:~#
root@OpenWrt:~# opkg list |grep i2c
i2c-tools - 4.3-1
kmod-i2c-algo-bit - 5.4.154-1
kmod-i2c-algo-pcf - 5.4.154-1
kmod-i2c-core - 5.4.154-1
kmod-i2c-gpio - 5.4.154-1
kmod-i2c-mux - 5.4.154-1
kmod-i2c-mux-gpio - 5.4.154-1
kmod-i2c-smbus - 5.4.154-1
libi2c - 4.3-1
root@OpenWrt:~# opkg list |grep spi
kmod-spi-bitbang - 5.4.154-1
kmod-spi-gpio - 5.4.154-1
root@OpenWrt:~# opkg list |grep gpio
gpioctl-sysfs - 0.0.7-1
kmod-gpio-dev - 5.4.154-1
kmod-i2c-gpio - 5.4.154-1
kmod-i2c-mux-gpio - 5.4.154-1
kmod-spi-gpio - 5.4.154-1
libugpio - 0.0.7-1

for future reference the problem is:

gcc: error: unrecognized command line option '-fmacro-prefix-map=/home/use/openwrt_zero2_good/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/Python-3.10.0=Python-3.10.0'

You need python3-src and to delete this line (multiple times in the file!) from:
/usr/lib/python3.10/_sysconfigdata.py

All is fine!
The solution is mainly work from PaulFertser on IRC!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.