Skip to content

Added alternate address pins parameter so 32x16 matrices can use this #17

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 4 commits into from
Sep 11, 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
18 changes: 14 additions & 4 deletions adafruit_matrixportal/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,30 @@ class Graphics:

:param default_bg: The path to your default background image file or a hex color.
Defaults to 0x000000.
:param width: The width of the display in Pixels. Defaults to 64.
:param height: The height of the display in Pixels. Defaults to 32.
:param int width: The width of the display in Pixels. Defaults to 64.
:param int height: The height of the display in Pixels. Defaults to 32.
:param int bit_depth: The number of bits per color channel. Defaults to 2.
:param list alt_addr_pins: An alternate set of address pins to use. Defaults to None
:param debug: Turn on debug print outs. Defaults to False.

"""

# pylint: disable=too-many-instance-attributes, too-many-locals, too-many-branches, too-many-statements
def __init__(
self, *, default_bg=0x000000, width=64, height=32, bit_depth=2, debug=False
self,
*,
default_bg=0x000000,
width=64,
height=32,
bit_depth=2,
alt_addr_pins=None,
debug=False
):

self._debug = debug
matrix = Matrix(bit_depth=bit_depth, width=width, height=height)
matrix = Matrix(
bit_depth=bit_depth, width=width, height=height, alt_addr_pins=alt_addr_pins
)
self.display = matrix.display

if self._debug:
Expand Down
18 changes: 11 additions & 7 deletions adafruit_matrixportal/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,20 @@ class Matrix:
"""Class representing the Adafruit RGB Matrix. This is used to automatically
initialize the display.

:param width: The width of the display in Pixels. Defaults to 64.
:param height: The height of the display in Pixels. Defaults to 32.
:param bit_depth: The number of bits per color channel. Defaults to 2.
:param int width: The width of the display in Pixels. Defaults to 64.
:param int height: The height of the display in Pixels. Defaults to 32.
:param int bit_depth: The number of bits per color channel. Defaults to 2.
:param list alt_addr_pins: An alternate set of address pins to use. Defaults to None

"""

# pylint: disable=too-few-public-methods
def __init__(
self, *, width=64, height=32, bit_depth=2,
):
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
else:
addr_pins = [board.A0, board.A1, board.A2, board.A3]

try:
displayio.release_displays()
Expand All @@ -57,7 +61,7 @@ def __init__(
height=height,
bit_depth=bit_depth,
rgb_pins=[board.D2, board.D3, board.D4, board.D5, board.D6, board.D7],
addr_pins=[board.A0, board.A1, board.A2, board.A3],
addr_pins=addr_pins,
clock_pin=board.A4,
latch_pin=board.D10,
output_enable_pin=board.D9,
Expand Down
9 changes: 8 additions & 1 deletion adafruit_matrixportal/matrixportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class MatrixPortal:
before calling the pyportal class. Defaults to ``None``.
:param busio.SPI external_spi: A previously declared spi object. Defaults to ``None``.
:param int bit_depth: The number of bits per color channel. Defaults to 2.
:param list alt_addr_pins: An alternate set of address pins to use. Defaults to None
:param debug: Turn on debug print outs. Defaults to False.

"""
Expand All @@ -75,12 +76,18 @@ def __init__(
esp=None,
external_spi=None,
bit_depth=2,
alt_addr_pins=None,
debug=False
):

self._debug = debug
self.graphics = Graphics(
default_bg=default_bg, bit_depth=bit_depth, width=64, height=32, debug=debug
default_bg=default_bg,
bit_depth=bit_depth,
width=64,
height=32,
alt_addr_pins=alt_addr_pins,
debug=debug,
)
self.display = self.graphics.display

Expand Down