Search code examples
pythonraspberry-pispi

luma.oled SPI ssd1306 data to GPIO pins issue using package/module


I have an ssd1306 which is working on SPI0 using the Adafruit library using CircuitPython, However, I want to eventually move the oled to SPI1. Therefore I am using the luma.oled library as this has more flexibility around the SPI bus used.

I have the GPIO attached to a logic analyser and have a comparison between the CircuitPython and luma.oled implementation and can see that I am not outputting the correct data and all the wiring is correct but I am not sure about my implementation of the luma.oled

It looks to me like the SPI GPIO is not properly set up.

This is the documentation I have been referring to.

https://luma-core.readthedocs.io/en/latest/interface.html

from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.oled.device import ssd1306

serial = spi(device=0, port=0, SCLK=11, SDA=19, CE=5, DC=6, RST=4)

device = ssd1306(serial)

with canvas(device) as draw:
    draw.rectangle(device.bounding_box, outline="white", fill="black")
    draw.text((30, 40), "Hello", fill="white")

Would someone be able to help with this!

For reference SPI using CircutiPython enter image description here

For reference SPI using luma.oled enter image description here

UPDATE

Using code below seem to have a move convincing command of the GPIO but still doesn't correspond to real SPI.

try:
    serial = spi(device=0, port=0, gpio_CE=5, gpio_DC=6, gpio_RST=4)
    print(type(serial))
    print(serial)

Gives the following:

enter image description here


Solution

  • I was just doing some housework and looks as though I left this post open ended up using the Adafruit moduls and the issue I was seeing turned out to be a bug with the module, see the following link for details

    https://github.com/adafruit/Adafruit_CircuitPython_BusDevice/issues/89

    Although now this issue is fixed I guess no one will ever read this!