Hi folks, finally getting on with my RasPi projects, with some success, but having some difficulty with the OLED when it comes to doing my own thing with it.
For reference, this is what Im trying to recreate https://www.raspberrypi-spy.co.uk/2019/10/pi-hole-oled-status-screen/ but with an SPI interface OLED instead.
Everything is working, the OLED is running on SPI0 as device 1, and I can run the bounce example perfectly fine - however, when I try to use the luma library I get nothing, zip, nada :(
heres what I do to run bounce
python3 bounce.py --display sh1106 --height 128 --rotate 2 --interface spi --spi-port 0 --spi-device 1 --gpio-data-command 9
heres the relevant snippet of my code, based on the example in the docu, the led blinks so I know the code and subsequent loop is running, but the screen stays blank. (Nothing changes about the wiring or settings in between running this, and bounce.)
#!/usr/bin/python3
Graphics libraries
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
from luma.core.interface.serial import i2c,spi
from luma.core.render import canvas
from luma.oled.device import sh1106
serial = spi(device=0, port=1)
device = sh1106(serial, width=128, height=128, rotate=2, mode=1)
led.value=1
with canvas(device) as draw:
draw.rectangle(device.bounding_box, outline=“white”, fill=“black”)
draw.text((10, 40), “Hello World”, fill=“white”)
device.display # ??
led.value=0
with canvas(device) as draw:
draw.rectangle(device.bounding_box, outline=“white”, fill=“white”)
draw.text((10,40), “Hello World”, fill=“black”)
device.display # ??
It’s obviously something I’m missing or doing wrong but I’m not familiar with this library and it’s eluding me, any pointers please? TIA