I finally managed to get this work. Things I was doing wrong:
Not using the OPi.GPIO replacement library - others aren't compatible with the NanoPi M4;
DIN LCD pin was connected to the SBC RXD instead of TXD;
Passed wrong pin numbers to the libraries (should be the real physical pins numers);
Mistaking SPI port with device...
Here the full guide on how to it properly. Start by installing:
apt-get install python3 python3-pip python3-pil libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libtiff5 -y
pip3 install luma.oled
apt-get remove python3-rpi.gpio rpi.gpio-common
pip3 install --upgrade OPi.GPIO
Wire up your LCD as:
MISO > GPIO1_B0 > SPI1_TXD > 19 > LCD DIN | Blue
SCK > GPIO1_B1 > SPI1_CLK > 23 > LCD CLK | Yellow
CS > GPIO1_B2 > SPI1_CSn0 > 24 > LCD CS | Orange
RST > GPIO1_A1(3V) > M4 Pin 11 > LCD RST Pin | White
DC > GPIO1_A3(3V) > M4 Pin 13 > LCD DC Pin | Green
Download an run an example:
git clone https://github.com/rm-hull/luma.examples.git
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
And you should get something like this:
It seems to be able to drive the display up to around 45fps without noises like I've experienced before in an Arduino.
Enjoy.