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 #21

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 18 additions & 3 deletions adafruit_displayio_sh1107.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,26 @@
"""

import sys
import displayio


try:
from busdisplay import BusDisplay as Display
from fourwire import FourWire
except ImportError:
from displayio import Display
from displayio import FourWire

from micropython import const

try:
from typing import Union

try:
from i2cdisplaybus import I2CDisplayBus
except ImportError:
# pylint: disable=ungrouped-imports
from displayio import I2CDisplay as I2CDisplayBus

except ImportError:
pass

Expand Down Expand Up @@ -130,7 +145,7 @@
_ROTATION_OFFSET = 90


class SH1107(displayio.Display):
class SH1107(Display):
"""
SH1107 driver for use with DisplayIO

Expand All @@ -146,7 +161,7 @@ class SH1107(displayio.Display):

def __init__(
self,
bus: Union[displayio.I2CDisplay, displayio.FourWire],
bus: Union[I2CDisplayBus, FourWire],
display_offset: int = DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650,
rotation: int = 0,
**kwargs
Expand Down
10 changes: 9 additions & 1 deletion examples/displayio_sh1107_game_of_life.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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 adafruit_displayio_sh1107

displayio.release_displays()
Expand Down Expand Up @@ -93,7 +101,7 @@ def conway(output):

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)

# SH1107 is vertically oriented 64x128
WIDTH = 128
Expand Down
16 changes: 14 additions & 2 deletions examples/displayio_sh1107_mono_128x128_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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 bitmap_label as label
from adafruit_displayio_sh1107 import SH1107, DISPLAY_OFFSET_ADAFRUIT_128x128_OLED_5297
Expand All @@ -18,12 +30,12 @@
# 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=0x3D)
display_bus = I2CDisplayBus(i2c, device_address=0x3D)

# For SPI:
# import busio
# spi_bus = busio.SPI(board.SCK, board.MOSI)
# display_bus = displayio.FourWire(spi_bus, command=board.D6, chip_select=board.D5, reset=board.D9)
# display_bus = FourWire(spi_bus, command=board.D6, chip_select=board.D5, reset=board.D9)

# Width, height and rotation for Monochrome 1.12" 128x128 OLED
WIDTH = 128
Expand Down
10 changes: 9 additions & 1 deletion examples/displayio_sh1107_random_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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 terminalio

# can try import bitmap_label below for alternative
Expand All @@ -24,7 +32,7 @@
# 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)
display_bus = I2CDisplayBus(i2c, device_address=0x3C)

# SH1107 is vertically oriented 64x128
WIDTH = 128
Expand Down
10 changes: 9 additions & 1 deletion examples/displayio_sh1107_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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

# can try import bitmap_label below for alternative
Expand All @@ -23,7 +31,7 @@
# 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)
display_bus = I2CDisplayBus(i2c, device_address=0x3C)

# SH1107 is vertically oriented 64x128
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
Loading