Skip to content

Commit 05a1ca1

Browse files
authored
Merge pull request #16 from dhalbert/fourwire
FourWire support for both 8.x.x and 9.x.x
2 parents 997ef2f + aea9b98 commit 05a1ca1

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

adafruit_il0398.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@
2323
2424
"""
2525

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

2834
__version__ = "0.0.0+auto.0"
2935
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_IL0398.git"
@@ -48,10 +54,10 @@
4854

4955

5056
# pylint: disable=too-few-public-methods
51-
class IL0398(displayio.EPaperDisplay):
57+
class IL0398(EPaperDisplay):
5258
"""IL0398 driver"""
5359

54-
def __init__(self, bus: displayio.FourWire, **kwargs) -> None:
60+
def __init__(self, bus: FourWire, **kwargs) -> None:
5561
start_sequence = bytearray(_START_SEQUENCE)
5662

5763
width = kwargs["width"]

examples/il0398_4.2_color.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@
1414
import time
1515
import board
1616
import displayio
17-
import fourwire
1817
import adafruit_il0398
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+
2026
displayio.release_displays()
2127

2228
# This pinout works on a Feather M4 and may need to be altered for other boards.
@@ -26,7 +32,7 @@
2632
epd_reset = board.D5
2733
epd_busy = board.D6
2834

29-
display_bus = fourwire.FourWire(
35+
display_bus = FourWire(
3036
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
3137
)
3238
time.sleep(1)

examples/il0398_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_il0398
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)