26
26
27
27
"""
28
28
29
+ import os
29
30
import board
30
31
import displayio
31
32
import rgbmatrix
@@ -50,9 +51,8 @@ class Matrix:
50
51
# pylint: disable=too-few-public-methods,too-many-branches
51
52
def __init__ (self , * , width = 64 , height = 32 , bit_depth = 2 , alt_addr_pins = None ):
52
53
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
56
56
addr_pins = [board .MTX_ADDRA , board .MTX_ADDRB , board .MTX_ADDRC ]
57
57
if height > 16 :
58
58
addr_pins .append (board .MTX_ADDRD )
@@ -69,9 +69,18 @@ def __init__(self, *, width=64, height=32, bit_depth=2, alt_addr_pins=None):
69
69
clock_pin = board .MTX_CLK
70
70
latch_pin = board .MTX_LAT
71
71
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 :
73
82
# Metro/Grand Central Style Board
74
- if height <= 16 :
83
+ if alt_addr_pins is None and height <= 16 :
75
84
raise RuntimeError (
76
85
"Pin A2 unavailable in this mode. Please specify alt_addr_pins."
77
86
)
@@ -80,15 +89,6 @@ def __init__(self, *, width=64, height=32, bit_depth=2, alt_addr_pins=None):
80
89
clock_pin = board .A4
81
90
latch_pin = board .D10
82
91
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
92
92
93
93
# Alternate Address Pins
94
94
if alt_addr_pins is not None :
0 commit comments