AssertionError with SSD1309
See original GitHub issueHi, I got an “AssertionError” with an SSD1309 Display. The Situation: I got a Python Code for the SSD1322 running SSD1322-Code, which is working fine.
Now I wanted to port it to an SSD1309 Display SSD1309-Code, and keep getting an Assertion Error.
Here’s the log:
Apr 27 07:28:48 raspberrypi systemd[1]: Started RC2-UI.
Apr 27 07:28:53 raspberrypi rc2ui-nightly[825]: string of image.mode in __init__.py 1
Apr 27 07:28:53 raspberrypi rc2ui-nightly[825]: string of self.mode in __init__.py 1
Apr 27 07:28:53 raspberrypi rc2ui-nightly[825]: string of image.mode in __init__.py 1
Apr 27 07:28:53 raspberrypi rc2ui-nightly[825]: string of self.mode in __init__.py 1
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: Cannot open file volumio_logo.ppm
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: string of image.mode in __init__.py RGB
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: string of self.mode in __init__.py 1
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: Traceback (most recent call last):
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: File "/home/pi/RC2-UI/rc2ui.py", line 873, in <module>
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: show_logo("volumio_logo.ppm", oled)
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: File "/home/pi/RC2-UI/modules/display.py", line 15, in show_logo
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: device.display(logoImage)
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: File "/home/pi/.local/lib/python3.7/site-packages/luma/oled/device/__init__.py", line 202, in display
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: assert(image.mode == self.mode)
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: AssertionError
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: string of image.mode in __init__.py 1
Apr 27 07:28:54 raspberrypi rc2ui-nightly[825]: string of self.mode in __init__.py 1
Apr 27 07:28:55 raspberrypi systemd[1]: rc2ui.service: Main process exited, code=exited, status=1/FAILURE
Apr 27 07:28:55 raspberrypi systemd[1]: rc2ui.service: Failed with result 'exit-code'.
My Code has a main-script which tells a submodule to display a logo at startup. I’ve tried it with .ppm .bpm and .jpg files, error persists. To figure out what happend i added 2 prionts in init.py: “string of image.mode” and “string of self.mode” right before line 196 in init.py, to see what is given there.
In my display submodule i start the image processing to luma with:
def show_logo(filename, device): logoImage = Image.new(‘RGB’, (device.width, device.height))
In the API Documentation is stated that “mode” (1, RGB or RGBA) is supported since Luma 3.1 -> I’m using 3.4.
In the init.py ssd1309 is redirected to ssd1306. ssd1306 has a different opener than ssd1322, which is stated to be a “greyscale” device.
My Hardware: -PiZeroWH (Raspbian Buster Lite) -ssd1309 SPI Display (Resistors solderd correctly to use spi)
Maybe anyone has an Idea what I am doing wrong?
Cheers!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Hey Guys! Thank you for your Reply’s! That my display doesn’t show anything -> was my fault, bad cables…
With your advice “.convert”… i was able to solve my problem.
Thank you!!!
If you use the display method directly, it is the callers responsibility to set the correct mode (bit depth) that the device supports. The canvas will always construct one which is correct to match the device, but display doesnt.
See here how to convert: https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.convert
You can get the target mode from device.mode
Also see: