Skip to content

Commit

Permalink
Merge pull request #15 from dhalbert/fourwire
Browse files Browse the repository at this point in the history
FourWire support for 8.x.x and 9.x.x
  • Loading branch information
FoamyGuy committed Dec 18, 2023
2 parents 285c8aa + 4546968 commit b8d34d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
15 changes: 10 additions & 5 deletions adafruit_displayio_sh1106.py
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
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

0 comments on commit b8d34d6

Please sign in to comment.