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