From 2aa8c34ac27e26fc2e10a1d448ae5307ec0f7bbd Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 18 Dec 2023 11:38:53 -0500 Subject: [PATCH] support 8.x.x. and 9.x.x FourWire --- adafruit_ssd1680.py | 12 +++++++++--- examples/ssd1680_2.13_featherwing.py | 11 +++++++---- examples/ssd1680_2.13_mono_eink_bonnet.py | 9 +++++++-- examples/ssd1680_2.13_tricolor_breakout.py | 11 +++++++---- examples/ssd1680_four_corners.py | 9 +++++++-- examples/ssd1680_simpletest.py | 9 +++++++-- 6 files changed, 44 insertions(+), 17 deletions(-) diff --git a/adafruit_ssd1680.py b/adafruit_ssd1680.py index d65f4c2..5e6e668 100755 --- a/adafruit_ssd1680.py +++ b/adafruit_ssd1680.py @@ -28,7 +28,13 @@ """ -import displayio +try: + from epaperdisplay import EPaperDisplay + from fourwire import FourWire +except ImportError: + from displayio import EPaperDisplay + from displayio import FourWire + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SSD1680.git" @@ -50,7 +56,7 @@ # pylint: disable=too-few-public-methods -class SSD1680(displayio.EPaperDisplay): +class SSD1680(EPaperDisplay): r"""SSD1680 driver :param bus: The data bus the display is on @@ -66,7 +72,7 @@ class SSD1680(displayio.EPaperDisplay): Display rotation """ - def __init__(self, bus: displayio.FourWire, **kwargs) -> None: + def __init__(self, bus: FourWire, **kwargs) -> None: if "colstart" not in kwargs: kwargs["colstart"] = 8 stop_sequence = bytearray(_STOP_SEQUENCE) diff --git a/examples/ssd1680_2.13_featherwing.py b/examples/ssd1680_2.13_featherwing.py index d97df53..2f2665d 100644 --- a/examples/ssd1680_2.13_featherwing.py +++ b/examples/ssd1680_2.13_featherwing.py @@ -17,9 +17,14 @@ import time import board import displayio -import fourwire import adafruit_ssd1680 +# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this. +try: + from fourwire import FourWire +except ImportError: + from displayio import FourWire + displayio.release_displays() # This pinout works on a Metro M4 and may need to be altered for other boards. @@ -27,9 +32,7 @@ epd_cs = board.D9 epd_dc = board.D10 -display_bus = fourwire.FourWire( - spi, command=epd_dc, chip_select=epd_cs, baudrate=1000000 -) +display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, baudrate=1000000) time.sleep(1) display = adafruit_ssd1680.SSD1680( diff --git a/examples/ssd1680_2.13_mono_eink_bonnet.py b/examples/ssd1680_2.13_mono_eink_bonnet.py index e09fdc8..12c571b 100644 --- a/examples/ssd1680_2.13_mono_eink_bonnet.py +++ b/examples/ssd1680_2.13_mono_eink_bonnet.py @@ -18,9 +18,14 @@ import time import board import displayio -import fourwire import adafruit_ssd1680 +# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this. +try: + from fourwire import FourWire +except ImportError: + from displayio import FourWire + displayio.release_displays() # This pinout works on a Metro M4 and may need to be altered for other boards. @@ -30,7 +35,7 @@ epd_reset = board.D27 # Set to None for FeatherWing epd_busy = board.D17 # Set to None for FeatherWing -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/ssd1680_2.13_tricolor_breakout.py b/examples/ssd1680_2.13_tricolor_breakout.py index e8066b6..e3df90e 100644 --- a/examples/ssd1680_2.13_tricolor_breakout.py +++ b/examples/ssd1680_2.13_tricolor_breakout.py @@ -14,9 +14,14 @@ import time import board import displayio -import fourwire import adafruit_ssd1680 +# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this. +try: + from fourwire import FourWire +except ImportError: + from displayio import FourWire + displayio.release_displays() # This pinout works on a Metro M4 and may need to be altered for other boards. @@ -26,9 +31,7 @@ epd_reset = board.D5 epd_busy = board.D6 -display_bus = fourwire.FourWire( - spi, command=epd_dc, chip_select=epd_cs, baudrate=1000000 -) +display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, baudrate=1000000) time.sleep(1) display = adafruit_ssd1680.SSD1680( diff --git a/examples/ssd1680_four_corners.py b/examples/ssd1680_four_corners.py index 24218ad..ee49703 100644 --- a/examples/ssd1680_four_corners.py +++ b/examples/ssd1680_four_corners.py @@ -13,10 +13,15 @@ import board import busio import displayio -import fourwire import terminalio import adafruit_ssd1680 +# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this. +try: + from fourwire import FourWire +except ImportError: + from displayio import FourWire + displayio.release_displays() # This pinout works on a Feather RP2040 EPD and may need to be altered for other @@ -28,7 +33,7 @@ epd_reset = board.EPD_RESET epd_busy = board.EPD_BUSY -display_bus = fourwire.FourWire( +display_bus = FourWire( spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000 ) display = adafruit_ssd1680.SSD1680( diff --git a/examples/ssd1680_simpletest.py b/examples/ssd1680_simpletest.py index 6fa459d..6c3d4e6 100644 --- a/examples/ssd1680_simpletest.py +++ b/examples/ssd1680_simpletest.py @@ -18,9 +18,14 @@ import time import board import displayio -import fourwire import adafruit_ssd1680 +# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this. +try: + from fourwire import FourWire +except ImportError: + from displayio import FourWire + displayio.release_displays() # This pinout works on a Metro M4 and may need to be altered for other boards. @@ -30,7 +35,7 @@ epd_reset = board.D8 # Set to None for FeatherWing epd_busy = board.D7 # Set to None for FeatherWing -display_bus = fourwire.FourWire( +display_bus = FourWire( spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000 ) time.sleep(1)