Skip to content

Commit 6434022

Browse files
committed
Update simpletest with 8.0 standards
Includes displayio initiatlization missing from outdated example. This was an issue dealing with support questions related to missing displayio import. Also added height and width ints to make it easier for beginners to change screen sizes as these OLED displays come in a variety of sizes now.
1 parent 49caf70 commit 6434022

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

examples/ssd1306_simpletest.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
# Basic example of clearing and drawing pixels on a SSD1306 OLED display.
55
# This example and library is meant to work with Adafruit CircuitPython API.
66

7-
# Import all board pins.
8-
from board import SCL, SDA
7+
import time
8+
import board
99
import busio
10-
11-
# Import the SSD1306 module.
10+
import displayio
1211
import adafruit_ssd1306
1312

13+
displayio.release_displays()
1414

15-
# Create the I2C interface.
16-
i2c = busio.I2C(SCL, SDA)
15+
# Create the I2C bus interface.
16+
i2c = board.I2C() # uses board.SCL and board.SDA
17+
# i2c = busio.I2C(board.GP1, board.GP0) # Pi Pico RP2040
1718

1819
# 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!
21-
display = 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)
20+
display_width = 128
21+
display_height = 32
22+
display = adafruit_ssd1306.SSD1306_I2C(display_width, display_height, i2c)
23+
# You can change the I2C address with an addr parameter:
24+
# display = adafruit_ssd1306.SSD1306_I2C(display_width, display_height, i2c, addr=0x31)
2425

25-
# Clear the display. Always call show after changing pixels to make the display
26-
# update visible!
26+
# fills display with black pixels clearing it
2727
display.fill(0)
2828
display.show()
2929

0 commit comments

Comments
 (0)