Skip to content

FourWire support for both 8.x.x and 9.x.x #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions adafruit_st7735r.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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_ST7735R.git"
Expand Down Expand Up @@ -70,22 +76,17 @@


# pylint: disable=too-few-public-methods
class ST7735R(displayio.Display):
class ST7735R(BusDisplay):
"""
ST7735R display driver

:param displayio.FourWire bus: bus that the display is connected to
:param FourWire bus: bus that the display is connected to
:param bool bgr: (Optional) An extra init sequence to append (default=False)
:param bool invert: (Optional) Invert the colors (default=False)
"""

def __init__(
self,
bus: displayio.FourWire,
*,
bgr: bool = False,
invert: bool = False,
**kwargs: Any
self, bus: FourWire, *, bgr: bool = False, invert: bool = False, **kwargs: Any
):
init_sequence = _INIT_SEQUENCE
if bgr:
Expand Down
8 changes: 6 additions & 2 deletions examples/st7735r_128x160_colored_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@
import board
import terminalio
import displayio
import fourwire
from adafruit_display_text import label
from adafruit_st7735r import ST7735R

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.D5
tft_dc = board.D6

display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)

display = ST7735R(
display_bus, width=160, height=80, colstart=24, rotation=270, bgr=False
Expand Down
9 changes: 7 additions & 2 deletions examples/st7735r_128x160_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@
import board
import terminalio
import displayio
import fourwire
from adafruit_display_text import label
from adafruit_st7735r import ST7735R

# 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.D5
tft_dc = board.D6

display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)

display = ST7735R(display_bus, width=160, height=128, rotation=90, bgr=True)

Expand Down
9 changes: 7 additions & 2 deletions examples/st7735r_18tftshield_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
import time
import board
import displayio
import fourwire
from adafruit_seesaw.tftshield18 import TFTShield18
from adafruit_st7735r import ST7735R

# 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 @@ -20,7 +25,7 @@
tft_cs = board.D10
tft_dc = board.D8

display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs)
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)

ss.tft_reset()
display = ST7735R(display_bus, width=160, height=128, rotation=90, bgr=True)
Expand Down
9 changes: 7 additions & 2 deletions examples/st7735r_minitft_featherwing_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
import board
import terminalio
import displayio
import fourwire
from adafruit_display_text import label
from adafruit_seesaw.seesaw import Seesaw
from adafruit_st7735r import ST7735R

# 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.D5
tft_dc = board.D6

display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs)
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)

ss.digital_write(reset_pin, True)
display = ST7735R(
Expand Down
9 changes: 7 additions & 2 deletions examples/st7735r_minitft_revb_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@
import board
import terminalio
import displayio
import fourwire
from adafruit_display_text import label
from adafruit_st7735r import ST7735R

# 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.D5
tft_dc = board.D6

display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)

display = ST7735R(
display_bus,
Expand Down
9 changes: 7 additions & 2 deletions examples/st7735r_minitft_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@
import board
import terminalio
import displayio
import fourwire
from adafruit_display_text import label
from adafruit_st7735r import ST7735R

# 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.D5
tft_dc = board.D6

display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)

display = ST7735R(
display_bus, width=160, height=80, colstart=24, rotation=270, bgr=True
Expand Down
9 changes: 7 additions & 2 deletions examples/st7735r_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@
import board
import terminalio
import displayio
import fourwire
from adafruit_display_text import label
from adafruit_st7735r import ST7735R

# 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.D5
tft_dc = board.D6

display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)

display = ST7735R(display_bus, width=128, height=128, colstart=2, rowstart=1)

Expand Down