Skip to content

Commit

Permalink
Merge pull request #35 from dhalbert/fourwire
Browse files Browse the repository at this point in the history
FourWire support for both 8.x.x and 9.x.x
  • Loading branch information
FoamyGuy authored Dec 18, 2023
2 parents 8a2253d + 69f74f8 commit b1063ed
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
14 changes: 10 additions & 4 deletions adafruit_ili9341.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@
except ImportError:
pass

import displayio
# Support both 8.x.x and 9.x.x. Change when 8.x.x is discontinued as a stable release.
try:
from fourwire import FourWire
from busdisplay import BusDisplay
except ImportError:
from displayio import FourWire
from displayio import Display as BusDisplay

__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ILI9341.git"
Expand Down Expand Up @@ -85,12 +91,12 @@


# pylint: disable=too-few-public-methods
class ILI9341(displayio.Display):
class ILI9341(BusDisplay):
"""
ILI9341 display driver
:param displayio.FourWire bus: bus that the display is connected to
:param FourWire bus: bus that the display is connected to
"""

def __init__(self, bus: displayio.FourWire, **kwargs: Any):
def __init__(self, bus: FourWire, **kwargs: Any):
super().__init__(bus, _INIT_SEQUENCE, **kwargs)
9 changes: 7 additions & 2 deletions examples/ili9341_pitft_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@
import board
import terminalio
import displayio
import fourwire
from adafruit_display_text import label
import adafruit_ili9341

# Support both 8.x.x and 9.x.x. Change when 8.x.x is discontinued as a stable release.
try:
from fourwire import FourWire
except ImportError:
from displayio import FourWire

# Release any resources currently in use for the displays
displayio.release_displays()

spi = board.SPI()
tft_cs = board.CE0
tft_dc = board.D25

display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs)
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)

# Make the display context
Expand Down
9 changes: 7 additions & 2 deletions examples/ili9341_shield_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
import board
import terminalio
import displayio
import fourwire
from adafruit_display_text import label
import adafruit_ili9341

# Support both 8.x.x and 9.x.x. Change when 8.x.x is discontinued as a stable release.
try:
from fourwire import FourWire
except ImportError:
from displayio import FourWire

# Release any resources currently in use for the displays
displayio.release_displays()

Expand All @@ -27,7 +32,7 @@
tft_cs = board.D10
tft_dc = board.D9

display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs)
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)

# Make the display context
Expand Down
9 changes: 7 additions & 2 deletions examples/ili9341_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@
import board
import terminalio
import displayio
import fourwire
from adafruit_display_text import label
import adafruit_ili9341

# Support both 8.x.x and 9.x.x. Change when 8.x.x is discontinued as a stable release.
try:
from fourwire import FourWire
except ImportError:
from displayio import FourWire

# Release any resources currently in use for the displays
displayio.release_displays()

spi = board.SPI()
tft_cs = board.D9
tft_dc = board.D10

display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D6)
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D6)
display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)

# Make the display context
Expand Down

0 comments on commit b1063ed

Please sign in to comment.