OLED Display¶
raspbot.display.oled.OLEDDisplay
128x32 SSD1306 OLED display controller using luma.oled as the hardware driver and Pillow for
framebuffer rendering.
Optional extra
This module requires the oled extras group:
Importing without luma.oled and Pillow raises ImportError with a helpful message.
Constructor¶
| Parameter | Type | Default | Description |
|---|---|---|---|
i2c_port |
int |
1 |
Linux I2C bus number |
i2c_address |
int |
0x3C |
I2C address of the SSD1306 |
The display is not initialised until begin() is called, keeping import-time side-effect free.
Methods¶
begin()¶
Initialise the OLED hardware.
Returns: True on success, False if the display cannot be found (e.g. not connected).
clear(refresh=False)¶
Blank the framebuffer.
| Parameter | Type | Default | Description |
|---|---|---|---|
refresh |
bool |
False |
Push blank frame to display immediately |
add_text(x, y, text, refresh=False)¶
Draw text at pixel coordinates (x, y).
The origin is the top-left corner.
Coordinates outside the 128x32 panel are silently ignored.
add_line(text, line=1, refresh=False)¶
Write text to one of the four logical display lines (1-4, top to bottom).
Each line is 8 pixels tall.
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
str |
-- | String to render |
line |
int |
1 |
Line number 1-4 |
refresh |
bool |
False |
Push to display immediately |
refresh()¶
Push the current framebuffer to the physical OLED display.
Context manager¶
OLEDDisplay supports the context manager protocol.
begin() is called on entry; the display is cleared on exit.
Constants¶
| Constant | Value | Description |
|---|---|---|
OLED_WIDTH |
128 |
Panel width in pixels |
OLED_HEIGHT |
32 |
Panel height in pixels |