diff --git a/adafruit_ek79686.py b/adafruit_ek79686.py index 8ed9a07..940b3d5 100755 --- a/adafruit_ek79686.py +++ b/adafruit_ek79686.py @@ -26,7 +26,14 @@ """ import math -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 epaperdisplay import EPaperDisplay + from fourwire import FourWire +except ImportError: + from displayio import EPaperDisplay, FourWire __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EK79686.git" @@ -54,10 +61,10 @@ # pylint: disable=too-few-public-methods -class EK79686(displayio.EPaperDisplay): +class EK79686(EPaperDisplay): """EK79686 display driver""" - def __init__(self, bus: displayio.FourWire, **kwargs) -> None: + def __init__(self, bus: FourWire, **kwargs) -> None: start_sequence = bytearray(_START_SEQUENCE) width = 8 * math.ceil(kwargs["width"] / 8) diff --git a/examples/ek79686_simpletest.py b/examples/ek79686_simpletest.py index 13ae762..0bba1ac 100644 --- a/examples/ek79686_simpletest.py +++ b/examples/ek79686_simpletest.py @@ -15,6 +15,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 fourwire import FourWire +except ImportError: + from displayio import FourWire + import adafruit_ek79686 # Used to ensure the display is free in CircuitPython @@ -28,7 +36,7 @@ epd_busy = board.D6 # Create the displayio connection to the display pins -display_bus = displayio.FourWire( +display_bus = FourWire( spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000 ) time.sleep(1) # Wait a bit @@ -60,7 +68,7 @@ g.append(t) # Place the display group on the screen (does not refresh) - display.show(g) + display.root_group = g # Show the image on the display display.refresh()