API Documentation

OLED display driver for SSD1306, SSD1325, SSD1331 and SH1106 devices.

Inheritance diagram of luma.core.device, luma.core.emulator, luma.core.mixin, luma.core.virtual, luma.oled.device

Breaking changes

Warning

Version 2.0.0 was released on 11 January 2017: this came with a rename of the project in github from ssd1306 to luma.oled to reflect the changing nature of the codebase. It introduces some structural changes to the package structure, namely breaking the library up into smaller components and renaming existing packages.

This should largely be restricted to having to update import statements only. To upgrade any existing code that uses the old package structure:

  • rename instances of oled.device to luma.oled.device.
  • rename any other usages of oled.* to luma.core.*.

This breaking change was necessary to be able to add different classes of devices, so that they could reuse core components.

luma.oled.device

class luma.oled.device.sh1106(serial_interface=None, width=128, height=64, rotate=0)[source]

Bases: luma.core.device.device

Encapsulates the serial interface to the monochrome SH1106 OLED display hardware. On creation, an initialization sequence is pumped to the display to properly configure it. Further control commands can then be called to affect the brightness and other settings.

display(image)[source]

Takes a 1-bit PIL.Image and dumps it to the SH1106 OLED display.

class luma.oled.device.ssd1306(serial_interface=None, width=128, height=64, rotate=0)[source]

Bases: luma.core.device.device

Encapsulates the serial interface to the monochrome SSD1306 OLED display hardware. On creation, an initialization sequence is pumped to the display to properly configure it. Further control commands can then be called to affect the brightness and other settings.

display(image)[source]

Takes a 1-bit PIL.Image and dumps it to the SSD1306 OLED display.

class luma.oled.device.ssd1325(serial_interface=None, width=128, height=64, rotate=0)[source]

Bases: luma.core.device.device

Encapsulates the serial interface to the 4-bit greyscale SSD1325 OLED display hardware. On creation, an initialization sequence is pumped to the display to properly configure it. Further control commands can then be called to affect the brightness and other settings.

display(image)[source]

Takes a 24-bit RGB PIL.Image and dumps it to the SSD1325 OoledLED display, converting the image pixels to 4-bit greyscale using a simplified Luma calculation, based on Y’=0.299R’+0.587G’+0.114B’.

class luma.oled.device.ssd1331(serial_interface=None, width=96, height=64, rotate=0)[source]

Bases: luma.core.device.device

Encapsulates the serial interface to the 16-bit color (5-6-5 RGB) SSD1331 OLED display hardware. On creation, an initialization sequence is pumped to the display to properly configure it. Further control commands can then be called to affect the brightness and other settings.

contrast(level)[source]

Switches the display contrast to the desired level, in the range 0-255. Note that setting the level to a low (or zero) value will not necessarily dim the display to nearly off. In other words, this method is NOT suitable for fade-in/out animation.

Parameters:level (int) – Desired contrast level in the range of 0-255.
display(image)[source]

Takes a 24-bit RGB PIL.Image and dumps it to the SSD1331 OLED display.