You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adafruit CircuitPython driver for SSD1306 or SSD1305 OLED displays. Note that SSD1305 displays are back compatible so they can be used in-place of SSD1306 with the same code and commands.
Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
the Adafruit library and driver bundle.
Installing from PyPI
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from
PyPI. To install for current user:
pip3 install adafruit-circuitpython-ssd1306
To install system-wide (this may be required in some cases):
sudo pip3 install adafruit-circuitpython-ssd1306
To install in a virtual environment in your current project:
# Basic example of clearing and drawing pixels on a SSD1306 OLED display.# This example and library is meant to work with Adafruit CircuitPython API.# Author: Tony DiCola# License: Public Domain# Import all board pins.fromboardimportSCL, SDAimportbusio# Import the SSD1306 module.importadafruit_ssd1306# Create the I2C interface.i2c=busio.I2C(SCL, SDA)
# Create the SSD1306 OLED class.# The first two parameters are the pixel width and pixel height. Change these# to the right size for your display!display=adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
# Alternatively you can change the I2C address of the device with an addr parameter:#display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31)# Clear the display. Always call show after changing pixels to make the display# update visible!display.fill(0)
display.show()
# Set a pixel in the origin 0,0 position.display.pixel(0, 0, 1)
# Set a pixel in the middle 64, 16 position.display.pixel(64, 16, 1)
# Set a pixel in the opposite 127, 31 position.display.pixel(127, 31, 1)
display.show()