SH1106-based OLED driver
This module provides an interface for controlling an OLED display using the SH1106 driver over the I2C protocol. It allows users to control the display’s power, contrast, and pixel data, as well as render text and images. It inherits from the framebuf.FrameBuffer class to enable drawing on the display’s buffer and updating the OLED screen.
Example
from sh1106 import SH1106_I2C
# Init OLED display
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=400_000)
oled = SH1106_I2C(i2c)
# Add some text at (x, y)
oled.text("Using OLED and", 0, 40)
oled.text("ESP32", 50, 50)
# Update the OLED display so the text is displayed
oled.show()
Modification history
2024-11-11 : Added Sphinx-style comments for documentation.
2024-11-02 : Added demo method to demonstrate usage of the display.
2023-10-27 : File created, initial release.
- class sh1106.SH1106_I2C(*args: Any, **kwargs: Any)[source]
Bases:
FrameBuffer
- contrast(val)[source]
Set the contrast of the OLED display.
- Parameters:
val – Contrast value (0 to 255).