Skip to content

FourWire support for 8.x.x and 9.x.x #15

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

Merged
merged 1 commit into from
Dec 18, 2023
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
15 changes: 10 additions & 5 deletions adafruit_displayio_sh1106.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@

"""

# imports
import displayio
# Support both 8.x.x and 9.x.x. Change when 8.x.x is discontinued as a stable release.
try:
from fourwire import FourWire
from busdisplay import BusDisplay
except ImportError:
from displayio import FourWire
from displayio import Display as BusDisplay

__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SH1106.git"
Expand Down Expand Up @@ -52,17 +57,17 @@
)


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

:param bus: The bus that the display is connected to.
:param int width: The width of the display. Maximum of 132
:param int height: The height of the display. Maximum of 64
:param int rotation: The rotation of the display. 0, 90, 180 or 270.
"""

def __init__(self, bus: displayio.FourWire, **kwargs) -> None:
def __init__(self, bus: FourWire, **kwargs) -> None:
init_sequence = bytearray(_INIT_SEQUENCE)
super().__init__(
bus,
Expand Down
10 changes: 8 additions & 2 deletions examples/displayio_sh1106_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@
import board
import busio
import displayio
import fourwire
import terminalio
from adafruit_display_text import label
import adafruit_displayio_sh1106

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

displayio.release_displays()

spi = busio.SPI(board.SCK, board.MOSI)
display_bus = fourwire.FourWire(
display_bus = FourWire(
spi,
command=board.OLED_DC,
chip_select=board.OLED_CS,
Expand Down