Simple test

Ensure your device works with this simple test.

examples/ssd1305_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4# Import all board pins.
 5from board import SCL, SDA, D4
 6import busio
 7import digitalio
 8
 9# Import the SSD1305 module.
10import adafruit_ssd1305
11
12# Define the Reset Pin
13oled_reset = digitalio.DigitalInOut(D4)
14
15# Create the I2C interface.
16i2c = busio.I2C(SCL, SDA)
17
18# Create the SSD1305 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_ssd1305.SSD1305_I2C(128, 32, i2c, addr=0x3C, reset=oled_reset)
22
23# Alternatively you can change the I2C address of the device with an addr parameter:
24# display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, addr=0x31, reset=oled_reset)
25
26# Clear the display.  Always call show after changing pixels to make the display
27# update visible!
28display.fill(0)
29
30display.show()
31
32# Set a pixel in the origin 0,0 position.
33display.pixel(0, 0, 1)
34# Set a pixel in the middle 64, 16 position.
35display.pixel(64, 16, 1)
36# Set a pixel in the opposite 127, 31 position.
37display.pixel(127, 31, 1)
38display.show()