question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AssertionError with SSD1309

See original GitHub issue

Hi, 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:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Maschine2501commented, Apr 29, 2020

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!!!

0reactions
rm-hullcommented, Apr 27, 2020

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:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Assertionerror - Display only error message - Stack Overflow
I've the folowing code and want to print only the error (No data found, symbol may be delisted). Is it possible write better...
Read more >
Porting Openware to Daisy - #17 by antisvin - Firmware
Or it's possible to add an encoder and a SSD1309 OLED to “upgrade” ... I've caught assertion error a few times in FascinationMachine...
Read more >
Search Results - CVE
This command injection vulnerability allows an unauthenticated user to execute arbitrary commands if a `poller_item` with the `action` type ` ...
Read more >
ssd使用
它还可以与与SSD1306兼容的SH1106,SH1107和SSD1309一起使用。 请参阅ssd1306/ssd1306_conf_template.h和examples目录以获取更多详细信息。
Read more >
Thank you for 100 subscribers! Arduino Uno, 128x64px ...
Thank you for 100 subscribers! Arduino Uno, 128x64px Transparent OLED SSD1309, Tutorial Beginners.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found