Skip to content

Commit b9c8eed

Browse files
authored
Merge pull request #12 from dhalbert/fourwire
support 8.x.x. and 9.x.x FourWire
2 parents 3203fba + de0d006 commit b9c8eed

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

adafruit_uc8151d.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@
2626
2727
"""
2828

29-
import displayio
29+
# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this.
30+
try:
31+
from fourwire import FourWire
32+
from epaperdisplay import EPaperDisplay
33+
except ImportError:
34+
from displayio import FourWire
35+
from displayio import EPaperDisplay
36+
3037

3138
__version__ = "0.0.0+auto.0"
3239
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_UC8151D.git"
@@ -101,7 +108,7 @@
101108

102109

103110
# pylint: disable=too-few-public-methods
104-
class UC8151D(displayio.EPaperDisplay):
111+
class UC8151D(EPaperDisplay):
105112
r"""UC8151D driver
106113
107114
:param bus: The data bus the display is on
@@ -117,7 +124,7 @@ class UC8151D(displayio.EPaperDisplay):
117124
Display rotation
118125
"""
119126

120-
def __init__(self, bus: displayio.FourWire, **kwargs) -> None:
127+
def __init__(self, bus: FourWire, **kwargs) -> None:
121128
color_bits_inverted = kwargs.pop("color_bits_inverted", False)
122129
write_color_ram_command = 0x10
123130
write_black_ram_command = 0x13

examples/uc8151d_1.54_grayscale.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
import board
1414
import displayio
1515
import busio
16-
import fourwire
1716
import adafruit_uc8151d
1817

18+
# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this.
19+
try:
20+
from fourwire import FourWire
21+
except ImportError:
22+
from displayio import FourWire
23+
1924
displayio.release_displays()
2025

2126
# Pinout intended for use with a Raspberry Pi Pico
@@ -26,7 +31,7 @@
2631
rst = board.GP12
2732
busy = board.GP13
2833

29-
display_bus = fourwire.FourWire(
34+
display_bus = FourWire(
3035
busio.SPI(clk, si), command=dc, chip_select=cs, reset=rst, baudrate=1000000
3136
)
3237

examples/uc8151d_2.9_color.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010
import time
1111
import board
1212
import displayio
13-
import fourwire
1413
import adafruit_uc8151d
1514

15+
# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this.
16+
try:
17+
from fourwire import FourWire
18+
except ImportError:
19+
from displayio import FourWire
20+
1621
# Used to ensure the display is free in CircuitPython
1722
displayio.release_displays()
1823

@@ -25,7 +30,7 @@
2530
epd_busy = board.D6
2631

2732
# Create the displayio connection to the display pins
28-
display_bus = fourwire.FourWire(
33+
display_bus = FourWire(
2934
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
3035
)
3136
time.sleep(1) # Wait a bit

examples/uc8151d_simpletest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@
1414
import time
1515
import board
1616
import displayio
17-
import fourwire
1817
import adafruit_uc8151d
1918

19+
# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this.
20+
try:
21+
from fourwire import FourWire
22+
except ImportError:
23+
from displayio import FourWire
24+
2025
displayio.release_displays()
2126

2227
# This pinout works on a Feather M4 and may need to be altered for other boards.
@@ -26,7 +31,7 @@
2631
epd_reset = board.D5
2732
epd_busy = None
2833

29-
display_bus = fourwire.FourWire(
34+
display_bus = FourWire(
3035
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
3136
)
3237
time.sleep(1)

0 commit comments

Comments
 (0)