Skip to content

Commit 7778c34

Browse files
committed
9.x compatibility in examples
1 parent 2e37857 commit 7778c34

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

examples/displayio_ssd1306_64x32_simpletest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99

1010
import board
1111
import displayio
12+
13+
# Compatibility with both CircuitPython 8.x.x and 9.x.x.
14+
# Remove after 8.x.x is no longer a supported release.
15+
try:
16+
from i2cdisplaybus import I2CDisplayBus
17+
except ImportError:
18+
from displayio import I2CDisplay as I2CDisplayBus
19+
1220
import terminalio
1321
from adafruit_display_text import label
1422
import adafruit_displayio_ssd1306
@@ -18,7 +26,7 @@
1826
i2c = board.I2C() # uses board.SCL and board.SDA
1927
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
2028

21-
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)
29+
display_bus = I2CDisplayBus(i2c, device_address=0x3C)
2230
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=64, height=32)
2331

2432
# Make the display context

examples/displayio_ssd1306_featherwing.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88

99
import board
1010
import displayio
11+
12+
# Compatibility with both CircuitPython 8.x.x and 9.x.x.
13+
# Remove after 8.x.x is no longer a supported release.
14+
try:
15+
from i2cdisplaybus import I2CDisplayBus
16+
except ImportError:
17+
from displayio import I2CDisplay as I2CDisplayBus
18+
1119
import terminalio
1220
from adafruit_display_text import label
1321
import adafruit_displayio_ssd1306
@@ -16,7 +24,7 @@
1624

1725
i2c = board.I2C() # uses board.SCL and board.SDA
1826
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
19-
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)
27+
display_bus = I2CDisplayBus(i2c, device_address=0x3C)
2028
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
2129

2230
# Make the display context

examples/displayio_ssd1306_picowbell_tempsensor.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
import time
77
import board
88
import displayio
9+
10+
# Compatibility with both CircuitPython 8.x.x and 9.x.x.
11+
# Remove after 8.x.x is no longer a supported release.
12+
try:
13+
from i2cdisplaybus import I2CDisplayBus
14+
except ImportError:
15+
from displayio import I2CDisplay as I2CDisplayBus
16+
917
import busio
1018
import terminalio
1119
from adafruit_display_text import label
@@ -29,7 +37,7 @@
2937
ssd_height = 32
3038

3139
# Ensure the physical address of your SSD1306 is set here:
32-
ssd_bus = displayio.I2CDisplay(i2c0, device_address=0x3C)
40+
ssd_bus = I2CDisplayBus(i2c0, device_address=0x3C)
3341
display = ssd1306.SSD1306(ssd_bus, width=ssd_width, height=ssd_height)
3442

3543
# Manually set your sea_level_pressure to your area

examples/displayio_ssd1306_simpletest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88

99
import board
1010
import displayio
11+
12+
# Compatibility with both CircuitPython 8.x.x and 9.x.x.
13+
# Remove after 8.x.x is no longer a supported release.
14+
try:
15+
from i2cdisplaybus import I2CDisplayBus
16+
except ImportError:
17+
from displayio import I2CDisplay as I2CDisplayBus
18+
1119
import terminalio
1220
from adafruit_display_text import label
1321
import adafruit_displayio_ssd1306
@@ -19,7 +27,7 @@
1927
# Use for I2C
2028
i2c = board.I2C() # uses board.SCL and board.SDA
2129
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
22-
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C, reset=oled_reset)
30+
display_bus = I2CDisplayBus(i2c, device_address=0x3C, reset=oled_reset)
2331

2432
# Use for SPI
2533
# spi = board.SPI()

0 commit comments

Comments
 (0)