OLED displays default to landscape orientation, but many physical enclosures mount the screen sideways or upside down. luma.oled handles rotation in software — pass aDocumentation 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.
rotate parameter when creating the device and all subsequent drawing will be oriented correctly without any changes to your drawing code.
The rotate parameter
Therotate parameter accepts an integer from 0 to 3:
| Value | Effect |
|---|---|
0 | No rotation (landscape, default) |
1 | Rotate 90° clockwise (portrait) |
2 | Rotate 180° (landscape, upside down) |
3 | Rotate 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.
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:
| rotate | device.width | device.height |
|---|---|---|
0 | 128 | 64 |
1 | 64 | 128 |
2 | 128 | 64 |
3 | 64 | 128 |
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.