Simple test

Ensure your device works with this simple test.

examples/ssd1306_simpletest.py
 1# SPDX-FileCopyrightText: Tony DiCola
 2# SPDX-License-Identifier: CC0-1.0
 3
 4# Basic example of clearing and drawing pixels on a SSD1306 OLED display.
 5# This example and library is meant to work with Adafruit CircuitPython API.
 6
 7# Import all board pins.
 8from board import SCL, SDA
 9import busio
10
11# Import the SSD1306 module.
12import adafruit_ssd1306
13
14
15# Create the I2C interface.
16i2c = busio.I2C(SCL, SDA)
17
18# Create the SSD1306 OLED class.
19# The first two parameters are the pixel width and pixel height.  Change these
20# to the right size for your display!
21display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
22# Alternatively you can change the I2C address of the device with an addr parameter:
23# display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31)
24
25# Clear the display.  Always call show after changing pixels to make the display
26# update visible!
27display.fill(0)
28display.show()
29
30# Set a pixel in the origin 0,0 position.
31display.pixel(0, 0, 1)
32# Set a pixel in the middle 64, 16 position.
33display.pixel(64, 16, 1)
34# Set a pixel in the opposite 127, 31 position.
35display.pixel(127, 31, 1)
36display.show()