Skip to content

Commit e52041e

Browse files
committed
Refactored to use os.uname
1 parent 13711e4 commit e52041e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

adafruit_matrixportal/matrix.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
2727
"""
2828

29+
import os
2930
import board
3031
import displayio
3132
import rgbmatrix
@@ -50,9 +51,8 @@ class Matrix:
5051
# pylint: disable=too-few-public-methods,too-many-branches
5152
def __init__(self, *, width=64, height=32, bit_depth=2, alt_addr_pins=None):
5253

53-
# Detect the board type based on available pins
54-
if hasattr(board, "MTX_ADDRA"):
55-
# MatrixPortal M4
54+
if "Matrix Portal M4" in os.uname().machine:
55+
# MatrixPortal M4 Board
5656
addr_pins = [board.MTX_ADDRA, board.MTX_ADDRB, board.MTX_ADDRC]
5757
if height > 16:
5858
addr_pins.append(board.MTX_ADDRD)
@@ -69,9 +69,18 @@ def __init__(self, *, width=64, height=32, bit_depth=2, alt_addr_pins=None):
6969
clock_pin = board.MTX_CLK
7070
latch_pin = board.MTX_LAT
7171
oe_pin = board.MTX_OE
72-
elif hasattr(board, "D7"):
72+
elif "Feather" in os.uname().machine:
73+
print("Feather Detected")
74+
# Feather Style Board
75+
if height > 16:
76+
addr_pins.append(board.A2)
77+
rgb_pins = [board.D6, board.D5, board.D9, board.D11, board.D10, board.D12]
78+
clock_pin = board.D13
79+
latch_pin = board.D0
80+
oe_pin = board.D1
81+
else:
7382
# Metro/Grand Central Style Board
74-
if height <= 16:
83+
if alt_addr_pins is None and height <= 16:
7584
raise RuntimeError(
7685
"Pin A2 unavailable in this mode. Please specify alt_addr_pins."
7786
)
@@ -80,15 +89,6 @@ def __init__(self, *, width=64, height=32, bit_depth=2, alt_addr_pins=None):
8089
clock_pin = board.A4
8190
latch_pin = board.D10
8291
oe_pin = board.D9
83-
else:
84-
# Feather Style Board
85-
addr_pins = [board.A5, board.A4, board.A3]
86-
if height > 16:
87-
addr_pins.append(board.A2)
88-
rgb_pins = [board.D6, board.D5, board.D9, board.D11, board.D10, board.D12]
89-
clock_pin = board.D13
90-
latch_pin = board.D0
91-
oe_pin = board.D1
9292

9393
# Alternate Address Pins
9494
if alt_addr_pins is not None:

0 commit comments

Comments
 (0)