Skip to content

Commit e7b7e4a

Browse files
authored
Merge pull request #17 from makermelissa/master
Added alternate address pins parameter so 32x16 matrices can use this
2 parents adc0fea + 89b31c1 commit e7b7e4a

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

adafruit_matrixportal/graphics.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,30 @@ class Graphics:
3838
3939
:param default_bg: The path to your default background image file or a hex color.
4040
Defaults to 0x000000.
41-
:param width: The width of the display in Pixels. Defaults to 64.
42-
:param height: The height of the display in Pixels. Defaults to 32.
41+
:param int width: The width of the display in Pixels. Defaults to 64.
42+
:param int height: The height of the display in Pixels. Defaults to 32.
4343
:param int bit_depth: The number of bits per color channel. Defaults to 2.
44+
:param list alt_addr_pins: An alternate set of address pins to use. Defaults to None
4445
:param debug: Turn on debug print outs. Defaults to False.
4546
4647
"""
4748

4849
# pylint: disable=too-many-instance-attributes, too-many-locals, too-many-branches, too-many-statements
4950
def __init__(
50-
self, *, default_bg=0x000000, width=64, height=32, bit_depth=2, debug=False
51+
self,
52+
*,
53+
default_bg=0x000000,
54+
width=64,
55+
height=32,
56+
bit_depth=2,
57+
alt_addr_pins=None,
58+
debug=False
5159
):
5260

5361
self._debug = debug
54-
matrix = Matrix(bit_depth=bit_depth, width=width, height=height)
62+
matrix = Matrix(
63+
bit_depth=bit_depth, width=width, height=height, alt_addr_pins=alt_addr_pins
64+
)
5565
self.display = matrix.display
5666

5767
if self._debug:

adafruit_matrixportal/matrix.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,20 @@ class Matrix:
3939
"""Class representing the Adafruit RGB Matrix. This is used to automatically
4040
initialize the display.
4141
42-
:param width: The width of the display in Pixels. Defaults to 64.
43-
:param height: The height of the display in Pixels. Defaults to 32.
44-
:param bit_depth: The number of bits per color channel. Defaults to 2.
42+
:param int width: The width of the display in Pixels. Defaults to 64.
43+
:param int height: The height of the display in Pixels. Defaults to 32.
44+
:param int bit_depth: The number of bits per color channel. Defaults to 2.
45+
:param list alt_addr_pins: An alternate set of address pins to use. Defaults to None
4546
4647
"""
4748

4849
# pylint: disable=too-few-public-methods
49-
def __init__(
50-
self, *, width=64, height=32, bit_depth=2,
51-
):
50+
def __init__(self, *, width=64, height=32, bit_depth=2, alt_addr_pins=None):
51+
52+
if alt_addr_pins is not None:
53+
addr_pins = alt_addr_pins
54+
else:
55+
addr_pins = [board.A0, board.A1, board.A2, board.A3]
5256

5357
try:
5458
displayio.release_displays()
@@ -57,7 +61,7 @@ def __init__(
5761
height=height,
5862
bit_depth=bit_depth,
5963
rgb_pins=[board.D2, board.D3, board.D4, board.D5, board.D6, board.D7],
60-
addr_pins=[board.A0, board.A1, board.A2, board.A3],
64+
addr_pins=addr_pins,
6165
clock_pin=board.A4,
6266
latch_pin=board.D10,
6367
output_enable_pin=board.D9,

adafruit_matrixportal/matrixportal.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class MatrixPortal:
5757
before calling the pyportal class. Defaults to ``None``.
5858
:param busio.SPI external_spi: A previously declared spi object. Defaults to ``None``.
5959
:param int bit_depth: The number of bits per color channel. Defaults to 2.
60+
:param list alt_addr_pins: An alternate set of address pins to use. Defaults to None
6061
:param debug: Turn on debug print outs. Defaults to False.
6162
6263
"""
@@ -75,12 +76,18 @@ def __init__(
7576
esp=None,
7677
external_spi=None,
7778
bit_depth=2,
79+
alt_addr_pins=None,
7880
debug=False
7981
):
8082

8183
self._debug = debug
8284
self.graphics = Graphics(
83-
default_bg=default_bg, bit_depth=bit_depth, width=64, height=32, debug=debug
85+
default_bg=default_bg,
86+
bit_depth=bit_depth,
87+
width=64,
88+
height=32,
89+
alt_addr_pins=alt_addr_pins,
90+
debug=debug,
8491
)
8592
self.display = self.graphics.display
8693

0 commit comments

Comments
 (0)