rm-hull / luma.oled

Python module to drive a SSD1306 / SSD1309 / SSD1322 / SSD1325 / SSD1327 / SSD1331 / SSD1351 / SH1106 OLED
https://luma-oled.readthedocs.io
MIT License
811 stars 163 forks source link

SSD1306 not working via SPI #223

Closed ski7777 closed 1 year ago

ski7777 commented 6 years ago

Type of Raspberry Pi

tested on both RPi 1 B+ and RPi 3 B+

Linux Kernel version

Linux raspberrypi 4.14.70+ #1144 Tue Sep 18 17:20:50 BST 2018 armv6l GNU/Linux

Expected behaviour

I expect an image on the display

Actual behaviour

Nothing is happening

This is my wiring: img_20181009_145636 Please ignore the paper thing. The alignment is a bit wrong... img_20181009_145740

Display---RPI GND---GND VCC---3V3 DO---SPI0 SCLK D1---SPI0 MOSI RES---GPIO BCM 25 DC---GPIO BCM 24 CS---SPI0 CE0

my test code:

from luma.core.interface.serial import i2c, spi
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
from RPi import GPIO
GPIO.setmode(GPIO.BCM)
serial = spi(device=0, port=0, gpio=GPIO)
device = ssd1306(serial)
with canvas(device) as draw:
    draw.rectangle(device.bounding_box, outline="white", fill="black")
    draw.text((30, 40), "Hello World", fill="white")

input()
GPIO.cleanup()

My SSD1306 I²C displays are working with similar code. Why is this not working?

rm-hull commented 6 years ago

You should let the luma code manage the GPIO to get a working baseline. I highly suspect that it is down to setting the GPIO mode

ski7777 commented 6 years ago

I also tried without initializing the GPIO and not setting the gpio parameter. It didn't work, too.

Raphael

Richard Hull notifications@github.com schrieb am Di., 9. Okt. 2018, 16:19:

You should let the luma code manage the GPIO to get a working baseline. I highly suspect that it is down to setting the GPIO mode

— You are receiving this because you authored the thread.

Reply to this email directly, view it on GitHub https://github.com/rm-hull/luma.oled/issues/223#issuecomment-428210748, or mute the thread https://github.com/notifications/unsubscribe-auth/AQa6kUeevryJgeWooyZlu5yoaEWb3r0_ks5ujLB7gaJpZM4XTO3W .

ski7777 commented 6 years ago

Bump!

thijstriemstra commented 3 years ago

did this ever get resolved..

khwajay commented 3 years ago

Looks like I have the exact same display and wiring. (I have the same code minus managing GPIO)

Sometimes it flashes white for a millisecond, but most of the time it's a black screen.

DJ-Dingo commented 3 years ago

If you are using SPI, you should use the gpio_RST and gpio_DC funktions to make it work Something like this: serial = spi(device=0, port=0, gpio_DC=16, gpio_RST=18)

where GPIO 16 and 18 on your PI are connected to your display DC and RST or RES