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
805 stars 161 forks source link

Details on python usage #195

Closed craver2000 closed 6 years ago

craver2000 commented 6 years ago

I relied on the info here under python usage (https://luma-oled.readthedocs.io/en/latest/python-usage.html#examples) to use the OLED device in my python script. So far in my code, I have used the following snippet of code to initialise display my SS1351 OLED using my raspberry:

from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.oled.device import ssd1351
serial = spi(device=0, port=0)
device = ssd1351(serial)
device.width=128
device.height=128

However, the display appears distorted and I think that is because the changes to the GPIO DC pin to pin 20 is not in the script. I wanted to ask how can I include this parameter in my script such that changes of my GPIO data command pin to BCM20 of my raspberry pin is taken into account?

I have tried to include gpio-data-command 20 but that does not seem to work. That may probably only be used for bash commands. Can I find out the equivalent for python?

CRImier commented 6 years ago

Here's an example of what works for my setup, where both RST and DC are non-default:

serial = spi(port=0, device=0, gpio_DC=6, gpio_RST=5)
rm-hull commented 6 years ago

device.width=128 device.height=128

You dont need to set that - ssd1351 only supports 128x128 by default

CRImier commented 6 years ago

It seems like you've deleted a message or something, it appears in my email but not on this page. Anyway, all the other parameters look good to me (and I'm not even using SSD1351, mostly 1106, 1306 and 1331s).

thijstriemstra commented 6 years ago

@CRImier any news?

thijstriemstra commented 6 years ago

No feedback, closing. Let us know if it's still not working.