Closed TCB13 closed 3 years ago
Yet another example, simple code:
#!/usr/bin/env python3
from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.oled.device import ssd1351
from time import sleep
import nanopi.m4
import OPi.GPIO as GPIO
GPIO.setmode(nanopi.m4.BOARD)
interface = spi(gpio=GPIO ,device=1, port=0, bus_speed_hz=16000000, gpio_DC=33, gpio_RST=35)
device = ssd1351(interface, rotate=1)
with canvas(device) as draw:
draw.rectangle(device.bounding_box, outline="white", fill="black")
draw.text((10, 40), "Hello World", fill="white")
sleep(10)
Now if I run it:
# ./test.py
Traceback (most recent call last):
File "./test.py", line 11, in <module>
interface = spi(gpio=GPIO ,device=1, port=0, bus_speed_hz=16000000, gpio_DC=33, gpio_RST=35)
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
Apparently it seems like I've to specify the physical pins:
python3 luma.examples/examples/3d_box.py --display=ssd1351 --interface=spi --width=128 --height=128 --spi-bus-speed=16000000 --spi-device=0 --spi-port=1 --gpio-reset=11 --gpio-data-command=13 --gpio OPi.GPIO --gpio-mode nanopi.m4.BOARD
Version: luma.oled 3.8.1 (luma.core 2.3.1)
Display: ssd1351
Interface: spi
Dimensions: 128 x 128
------------------------------------------------------------
No errors now, but unfortunately I still don't get an image on the LCD.
My pin assignment was also wrong. I was connecting the LCD DIN to the SBC RXD pin. Switched to TXD and it works just fine!
The final wiring is:
MISO > GPIO1_B0 > SPI1_TXD > 19 > DIN | Azul
SCK > GPIO1_B1 > SPI1_CLK > 23 > CLK | Amarelo
CS > GPIO1_B2 > SPI1_CSn0 > 24 > CS | Laranja
RST > GPIO1_A1(3V) > M4 Pin 11 > LCD RST Pin (white)
DC > GPIO1_A3(3V) > M4 Pin 13 > LCD DC Pin (green)
Now running:
python3 luma.examples/examplebounce.py \
--display=ssd1351 \
--interface=spi --width=128 --height=128 \
--spi-bus-speed=50000000 \
--spi-device=0 \
--spi-port=1 \
--gpio-reset=11 \
--gpio-data-command=13 \
--gpio OPi.GPIO \
--gpio-mode nanopi.m4.BOARD
Produces the expected output:
It even runs over 40fps!
Thank you all for the time invested in this library and for being my rubber duck debugging ears :)
Hello,
I've posted about this here but I'm not sure if this isn't a luma.oled issue.
Device Info
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
Expected behaviour
Working SSD1351 SPI LCD with the provided luma.oled examples on the NanoPi M4v2 board.
Actual behaviour
RST > GPIO1_A1(3V) > M4 Pin 11 > LCD RST Pin (white) DC > GPIO1_A3(3V) > M4 Pin 13 > LCD DC Pin (green)
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
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