Skip to content

Commit 8c83e14

Browse files
committed
FourWire support for 8.x.x and 9.x.x
1 parent 2c58bb2 commit 8c83e14

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

adafruit_ssd1681.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525
2626
"""
2727

28-
import displayio
28+
# Support both 8.x.x and 9.x.x. Change when 8.x.x is discontinued as a stable release.
29+
try:
30+
from fourwire import FourWire
31+
from epaperdisplay import EPaperDisplay
32+
except ImportError:
33+
from displayio import FourWire
34+
from displayio import EPaperDisplay
2935

3036
__version__ = "0.0.0+auto.0"
3137
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SSD1681.git"
@@ -45,7 +51,7 @@
4551

4652

4753
# pylint: disable=too-few-public-methods
48-
class SSD1681(displayio.EPaperDisplay):
54+
class SSD1681(EPaperDisplay):
4955
r"""SSD1681 driver
5056
5157
:param bus: The data bus the display is on
@@ -61,7 +67,7 @@ class SSD1681(displayio.EPaperDisplay):
6167
Display rotation
6268
"""
6369

64-
def __init__(self, bus: displayio.FourWire, **kwargs) -> None:
70+
def __init__(self, bus: FourWire, **kwargs) -> None:
6571
start_sequence = bytearray(_START_SEQUENCE)
6672

6773
width = kwargs["width"]

examples/ssd1681_four_corners.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@
1313
import board
1414
import busio
1515
import displayio
16-
import fourwire
1716
import terminalio
1817
import adafruit_ssd1681
1918

19+
# Compatibility with both CircuitPython 8.x.x and 9.x.x.
20+
# Remove after 8.x.x is no longer a supported release.
21+
try:
22+
from fourwire import FourWire
23+
except ImportError:
24+
from displayio import FourWire
25+
26+
2027
displayio.release_displays()
2128

2229
# This pinout works on a Feather RP2040 EPD and may need to be altered for other
@@ -28,7 +35,7 @@
2835
epd_reset = board.EPD_RESET
2936
epd_busy = board.EPD_BUSY
3037

31-
display_bus = fourwire.FourWire(
38+
display_bus = FourWire(
3239
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
3340
)
3441
display = adafruit_ssd1681.SSD1681(

examples/ssd1681_simpletest.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212
import time
1313
import board
1414
import displayio
15-
import fourwire
1615
import adafruit_ssd1681
1716

17+
# Compatibility with both CircuitPython 8.x.x and 9.x.x.
18+
# Remove after 8.x.x is no longer a supported release.
19+
try:
20+
from fourwire import FourWire
21+
except ImportError:
22+
from displayio import FourWire
23+
1824
displayio.release_displays()
1925

2026
# This pinout works on a Feather M4 and may need to be altered for other boards.
@@ -24,7 +30,7 @@
2430
epd_reset = board.D5
2531
epd_busy = board.D6
2632

27-
display_bus = fourwire.FourWire(
33+
display_bus = FourWire(
2834
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
2935
)
3036
time.sleep(1)

0 commit comments

Comments
 (0)