diff --git a/adafruit_il0398.py b/adafruit_il0398.py index 73dd744..937b3f0 100644 --- a/adafruit_il0398.py +++ b/adafruit_il0398.py @@ -23,7 +23,13 @@ """ -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 epaperdisplay import EPaperDisplay +except ImportError: + from displayio import FourWire + from displayio import EPaperDisplay __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_IL0398.git" @@ -48,10 +54,10 @@ # pylint: disable=too-few-public-methods -class IL0398(displayio.EPaperDisplay): +class IL0398(EPaperDisplay): """IL0398 driver""" - def __init__(self, bus: displayio.FourWire, **kwargs) -> None: + def __init__(self, bus: FourWire, **kwargs) -> None: start_sequence = bytearray(_START_SEQUENCE) width = kwargs["width"] diff --git a/examples/il0398_4.2_color.py b/examples/il0398_4.2_color.py index 8342b10..af4e701 100644 --- a/examples/il0398_4.2_color.py +++ b/examples/il0398_4.2_color.py @@ -14,9 +14,15 @@ import time import board import displayio -import fourwire import adafruit_il0398 +# 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() # This pinout works on a Feather M4 and may need to be altered for other boards. @@ -26,7 +32,7 @@ epd_reset = board.D5 epd_busy = board.D6 -display_bus = fourwire.FourWire( +display_bus = FourWire( spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000 ) time.sleep(1) diff --git a/examples/il0398_simpletest.py b/examples/il0398_simpletest.py index b166fd9..8b76f6b 100644 --- a/examples/il0398_simpletest.py +++ b/examples/il0398_simpletest.py @@ -12,9 +12,15 @@ import time import board import displayio -import fourwire import adafruit_il0398 +# 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() # This pinout works on a Feather M4 and may need to be altered for other boards. @@ -24,7 +30,7 @@ epd_reset = board.D5 epd_busy = board.D6 -display_bus = fourwire.FourWire( +display_bus = FourWire( spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000 ) time.sleep(1)