Skip to content

Updated to work with Matrix Portal #18

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
Sep 18, 2020
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
56 changes: 51 additions & 5 deletions adafruit_matrixportal/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

**Hardware:**

* `Adafruit Matrix Portal <https://www.adafruit.com/product/4745>`_
* `Adafruit Metro M4 Express AirLift <https://www.adafruit.com/product/4000>`_
* `Adafruit RGB Matrix Shield <https://www.adafruit.com/product/2601>`_
* `64x32 RGB LED Matrix <https://www.adafruit.com/product/2278>`_
Expand Down Expand Up @@ -46,25 +47,70 @@ class Matrix:

"""

# pylint: disable=too-few-public-methods
# pylint: disable=too-few-public-methods,too-many-branches
def __init__(self, *, width=64, height=32, bit_depth=2, alt_addr_pins=None):

if alt_addr_pins is not None:
addr_pins = alt_addr_pins
elif hasattr(board, "MTX_ADDRA"):
if height <= 16:
addr_pins = [board.MTX_ADDRA, board.MTX_ADDRB, board.MTX_ADDRC]
elif height <= 32:
addr_pins = [
board.MTX_ADDRA,
board.MTX_ADDRB,
board.MTX_ADDRC,
board.MTX_ADDRD,
]
else:
addr_pins = [
board.MTX_ADDRA,
board.MTX_ADDRB,
board.MTX_ADDRC,
board.MTX_ADDRD,
board.MTX_ADDRE,
]
else:
addr_pins = [board.A0, board.A1, board.A2, board.A3]

if hasattr(board, "MTX_R1"):
rgb_pins = [
board.MTX_R1,
board.MTX_G1,
board.MTX_B1,
board.MTX_R2,
board.MTX_G2,
board.MTX_B2,
]
else:
rgb_pins = [board.D2, board.D3, board.D4, board.D5, board.D6, board.D7]

if hasattr(board, "MTX_CLK"):
clock_pin = board.MTX_CLK
else:
clock_pin = board.A4

if hasattr(board, "MTX_CLK"):
latch_pin = board.MTX_LAT
else:
latch_pin = board.D10

if hasattr(board, "MTX_OE"):
oe_pin = board.MTX_OE
else:
oe_pin = board.D9

try:
displayio.release_displays()
matrix = rgbmatrix.RGBMatrix(
width=width,
height=height,
bit_depth=bit_depth,
rgb_pins=[board.D2, board.D3, board.D4, board.D5, board.D6, board.D7],
rgb_pins=rgb_pins,
addr_pins=addr_pins,
clock_pin=board.A4,
latch_pin=board.D10,
output_enable_pin=board.D9,
clock_pin=clock_pin,
latch_pin=latch_pin,
output_enable_pin=oe_pin,
)
self.display = framebufferio.FramebufferDisplay(matrix)
except ValueError:
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Table of Contents
.. toctree::
:caption: Related Products

* Adafruit Matrix Portal <https://www.adafruit.com/product/4745>
* Adafruit Metro M4 Express AirLift <https://www.adafruit.com/product/4000>
* Adafruit RGB Matrix Shield <https://www.adafruit.com/product/2601>
* 64x32 RGB LED Matrix <https://www.adafruit.com/product/2278>
Expand Down