Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9.x compatibility in examples #41

Merged
merged 3 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion examples/displayio_ssd1306_64x32_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@

import board
import displayio

# Compatibility with both CircuitPython 8.x.x and 9.x.x.
# Remove after 8.x.x is no longer a supported release.
try:
from i2cdisplaybus import I2CDisplayBus
except ImportError:
from displayio import I2CDisplay as I2CDisplayBus

import terminalio
from adafruit_display_text import label
import adafruit_displayio_ssd1306
Expand All @@ -18,7 +26,7 @@
i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller

display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)
display_bus = I2CDisplayBus(i2c, device_address=0x3C)
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=64, height=32)

# Make the display context
Expand Down
10 changes: 9 additions & 1 deletion examples/displayio_ssd1306_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

import board
import displayio

# Compatibility with both CircuitPython 8.x.x and 9.x.x.
# Remove after 8.x.x is no longer a supported release.
try:
from i2cdisplaybus import I2CDisplayBus
except ImportError:
from displayio import I2CDisplay as I2CDisplayBus

import terminalio
from adafruit_display_text import label
import adafruit_displayio_ssd1306
Expand All @@ -16,7 +24,7 @@

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

# Make the display context
Expand Down
10 changes: 9 additions & 1 deletion examples/displayio_ssd1306_picowbell_tempsensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
import time
import board
import displayio

# Compatibility with both CircuitPython 8.x.x and 9.x.x.
# Remove after 8.x.x is no longer a supported release.
try:
from i2cdisplaybus import I2CDisplayBus
except ImportError:
from displayio import I2CDisplay as I2CDisplayBus

import busio
import terminalio
from adafruit_display_text import label
Expand All @@ -29,7 +37,7 @@
ssd_height = 32

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

# Manually set your sea_level_pressure to your area
Expand Down
16 changes: 14 additions & 2 deletions examples/displayio_ssd1306_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@

import board
import displayio

# Compatibility with both CircuitPython 8.x.x and 9.x.x.
# Remove after 8.x.x is no longer a supported release.
try:
from i2cdisplaybus import I2CDisplayBus

# from fourwire import FourWire
except ImportError:
from displayio import I2CDisplay as I2CDisplayBus

# from displayio import FourWire

import terminalio
from adafruit_display_text import label
import adafruit_displayio_ssd1306
Expand All @@ -19,13 +31,13 @@
# Use for I2C
i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C, reset=oled_reset)
display_bus = I2CDisplayBus(i2c, device_address=0x3C, reset=oled_reset)

# Use for SPI
# spi = board.SPI()
# oled_cs = board.D5
# oled_dc = board.D6
# display_bus = displayio.FourWire(spi, command=oled_dc, chip_select=oled_cs,
# display_bus = FourWire(spi, command=oled_dc, chip_select=oled_cs,
# reset=oled_reset, baudrate=1000000)

WIDTH = 128
Expand Down
Loading