A working recipe to display raster images on a ssd1306 display using CircuitPython. Developed for use with Trinket M0. As this is a minimal environment for CircuitPython support, better performance is expected with better hardware.
As configured, this updates the image shown on a ssd1306 one line at a time. Uses I2C bus. Included image file is example used for demo at local Python club.
- CircuitPython 2.3.1 -adafruit_ssd1306 library didn't work with the newly released 3.0.0; Not sure if framebuf.py is 3.0.0 compatible.
- In the lib directory the following are required:
- From the v2 circuit python library bundle:
- adafruit_bus_device/
- adafruit_register/
- adafruit_ssd1306.mpy
- framebuf.mpy
- From the v2 circuit python library bundle:
- In the main CIRCUITPY directory of the device place:
- main.py (From this repo)
- image_to_display.txt
- Each image refresh is slow. Working with the Arduino libraries, this display is very responsive. It's not clear yet if this is a limitation of my hardware, or of the libraries being used. Takes ~1sec for oled.show() to complete. Due to limited flash memory of the Trinket M0, a pure Python implementation of framebuf module. I suspect a device supporting the native C module will refresh nearly instantly.
- As written, loading the full 128x64 image into RAM consumes all memory and dumps uc into the REPL (white LED). Working with 64x64 images completely fit into ram. Used tuples of 8bit binary literals when testing.
- Process used to generate image is slow. Although accurate scaling of images will likely remain a manual task, once the image is the correct size, a program could be written that converts a multicolored image into a monochrome binary image easily interpreted for display on the ssd1306.
- Use binary file rather than text file for image. Current image is 8K, but should reduce to 1K.