rm-hull / OPi.GPIO

RPi.GPIO drop-in replacement library for Orange Pi Zero and other SBCs
https://opi-gpio.readthedocs.io/
MIT License
186 stars 98 forks source link

NanoPi M4v2 + OPi.GPIO + Luma.OLED + SSD1351 Error #58

Closed TCB13 closed 3 years ago

TCB13 commented 3 years ago

Hello,

I'm sure this library works just fine but I'm missing some piece here. I'm trying to drive an SSD1351 LCD with OPi.GPIO + Luma.OLED however I'm not having much luck. Here is what I did:

  1. Install Luma.OLED:
    apt-get update
    apt-get install python3 python3-pip python3-pil libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libtiff5 -y
    pip3 install luma.oled
  2. Install OPi.GPIO:
    pip3 install --upgrade OPi.GPIO
  3. Wire my LCD as:
    
    MOSI > GPIO1_A7 > SPI1_RXD > M4 Pin 21   > LCD DIN Pin (blue)
    SCK > GPIO1_B1 > SPI1_CLK > M4 Pin 23     > LCD CLK Pin (yellow)
    CS > GPIO1_B2  > SPI1_CSn0 > M4 Pin 24    > LCD CS Pin (orange)

RST > GPIO1_A1(3V) > M4 Pin 11 > LCD RST Pin (white) DC > GPIO1_A3(3V) > M4 Pin 13 > LCD DC Pin (green)

4. Find the spidev and run a Luma.OLED example as:

ls /dev/spi* /dev/spidev1.0

python3 luma.examples/examples/3d_box.py --display=ssd1351 --interface=spi --width=128 --height=128 --spi-bus-speed=16000000 --bgr --spi-device=1 --spi-port=0 --gpio-reset=35 --gpio-data-command=33 --gpio=OPi.GPIO --gpio-mode=nanopi.m4.BOARD


From what I understand of https://github.com/rm-hull/OPi.GPIO/blob/master/nanopi/m4.py my physical pin 11 maps to GPIO 33 and physical pin 13 to GPIO 35. Is this even correct?

Now it fails with the following output:

Traceback (most recent call last): File "luma.examples/examples/3d_box.py", line 129, in device = get_device() File "/root/luma.examples/examples/demo_opts.py", line 61, in get_device device = cmdline.create_device(args) File "/usr/local/lib/python3.7/dist-packages/luma/core/cmdline.py", line 246, in create_device device = Device(serial_interface=interface(), **params) File "/usr/local/lib/python3.7/dist-packages/luma/core/cmdline.py", line 161, in spi gpio=self.gpio or GPIO) File "/usr/local/lib/python3.7/dist-packages/luma/core/interface/serial.py", line 299, in init bitbang.init(self, gpio, transfer_size, reset_hold_time, reset_release_time, DC=gpio_DC, RST=gpio_RST) File "/usr/local/lib/python3.7/dist-packages/luma/core/interface/serial.py", line 187, in init self._DC = self._configure(kwargs.get("DC")) File "/usr/local/lib/python3.7/dist-packages/luma/core/interface/serial.py", line 200, in _configure self._gpio.setup(pin, self._gpio.OUT) File "/usr/local/lib/python3.7/dist-packages/OPi/GPIO.py", line 470, in setup pin = get_gpio_pin(_mode, channel) File "/usr/local/lib/python3.7/dist-packages/OPi/pin_mappings.py", line 80, in get_gpio_pin return _pin_map[mode][channel] KeyError: 33



SBC: NanoPi M4V2
System: Armbian 5.10.35-rockchip64 #21.05.1 SMP PREEMPT Fri May 7 13:53:11 UTC 2021 aarch64 GNU/Linux
Display: https://www.ebay.com/itm/203101646517
Datasheet: https://www.waveshare.com/w/upload/5/5b/1.5inch_RGB_OLED_Module_User_Manual_EN.pdf 

Thank you.
TCB13 commented 3 years ago

My mistake, fixed at https://github.com/rm-hull/luma.oled/issues/331#issuecomment-922372005 and https://github.com/rm-hull/luma.oled/issues/331#issuecomment-922375789

Thank you all.