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
 7import board
 8
 9import adafruit_ssd1306
10
11# Create the I2C bus interface.
12i2c = board.I2C()  # uses board.SCL and board.SDA
13# i2c = busio.I2C(board.GP1, board.GP0)    # Pi Pico RP2040
14
15# Create the SSD1306 OLED class.
16display_width = 128
17display_height = 32
18display = adafruit_ssd1306.SSD1306_I2C(display_width, display_height, i2c)
19# You can change the I2C address with an addr parameter:
20# display = adafruit_ssd1306.SSD1306_I2C(display_width, display_height, i2c, addr=0x31)
21
22# fills display with black pixels clearing it
23display.fill(0)
24display.show()
25
26# Set a pixel in the origin 0,0 position.
27display.pixel(0, 0, 1)
28# Set a pixel in the middle 64, 16 position.
29display.pixel(64, 16, 1)
30# Set a pixel in the opposite 127, 31 position.
31display.pixel(127, 31, 1)
32display.show()