Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/rm-hull/luma.oled/llms.txt

Use this file to discover all available pages before exploring further.

OLED displays default to landscape orientation, but many physical enclosures mount the screen sideways or upside down. luma.oled handles rotation in software — pass a rotate parameter when creating the device and all subsequent drawing will be oriented correctly without any changes to your drawing code.

The rotate parameter

The rotate parameter accepts an integer from 0 to 3:
ValueEffect
0No rotation (landscape, default)
1Rotate 90° clockwise (portrait)
2Rotate 180° (landscape, upside down)
3Rotate 270° clockwise (portrait, upside down)

Portrait mode example

The following example creates an SSD1306 in portrait orientation. For a 128×64 display, rotate=1 makes the usable canvas 64 pixels wide and 128 pixels tall.
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306
from time import sleep

serial = i2c(port=1, address=0x3C)
device = ssd1306(serial, rotate=1)

with canvas(device) as draw:
    draw.rectangle(device.bounding_box, outline="white", fill="black")
    draw.text((10, 40), "Hello World", fill="white")
sleep(10)

Rotated dimensions

After applying rotation, device.size, device.width, and device.height all reflect the rotated dimensions, not the physical pixel layout of the panel. This means device.bounding_box is always correct for the current orientation and you never need to swap width and height manually. For an SSD1306 with its default 128×64 physical resolution:
rotatedevice.widthdevice.height
012864
164128
212864
364128
The default landscape orientation for the SSD1306 is 128×64 pixels. Other devices may have different default dimensions — check the device class docstring for its default width and height values.

Build docs developers (and LLMs) love