Skip to content

Commit

Permalink
Merge pull request #41 from FoamyGuy/9x_compatibility
Browse files Browse the repository at this point in the history
9.x compatibility in examples
  • Loading branch information
FoamyGuy authored Apr 1, 2024
2 parents 2e37857 + e8d6577 commit 85c854e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
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
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# SPDX-License-Identifier: Unlicense

Adafruit-Blinka
Adafruit-Blinka-Displayio

0 comments on commit 85c854e

Please sign in to comment.