@@ -47,14 +47,29 @@ class Matrix:
47
47
:param list alt_addr_pins: An alternate set of address pins to use. Defaults to None
48
48
:param string color_order: A string containing the letter "R", "G", and "B" in the
49
49
order you want. Defaults to "RGB"
50
-
50
+ :param int width: The total width of the display(s) in Pixels. Defaults to 64.
51
+ :param int height: The total height of the display(s) in Pixels. Defaults to 32.
52
+ :param bool Serpentine: Used when panels are arranged in a serpentine pattern rather
53
+ than a Z-pattern. Defaults to True.
54
+ :param int tiles_rows: Used to indicate the number of rows the panels are arranged in.
55
+ Defaults to 1.
51
56
"""
52
57
53
- # pylint: disable=too-few-public-methods,too-many-branches
58
+ # pylint: disable=too-few-public-methods,too-many-branches,too-many-statements,too-many-locals
54
59
def __init__ (
55
- self , * , width = 64 , height = 32 , bit_depth = 2 , alt_addr_pins = None , color_order = "RGB"
60
+ self ,
61
+ * ,
62
+ width = 64 ,
63
+ height = 32 ,
64
+ bit_depth = 2 ,
65
+ alt_addr_pins = None ,
66
+ color_order = "RGB" ,
67
+ serpentine = True ,
68
+ tile_rows = 1
56
69
):
57
70
71
+ panel_height = height // tile_rows
72
+
58
73
if not isinstance (color_order , str ):
59
74
raise ValueError ("color_index should be a string" )
60
75
color_order = color_order .lower ()
@@ -67,9 +82,9 @@ def __init__(
67
82
if "Matrix Portal M4" in os .uname ().machine :
68
83
# MatrixPortal M4 Board
69
84
addr_pins = [board .MTX_ADDRA , board .MTX_ADDRB , board .MTX_ADDRC ]
70
- if height > 16 :
85
+ if panel_height > 16 :
71
86
addr_pins .append (board .MTX_ADDRD )
72
- if height > 32 :
87
+ if panel_height > 32 :
73
88
addr_pins .append (board .MTX_ADDRE )
74
89
rgb_pins = [
75
90
board .MTX_R1 ,
@@ -87,13 +102,13 @@ def __init__(
87
102
if "nrf52" in os .uname ().sysname :
88
103
# nrf52840 Style Feather
89
104
addr_pins = [board .D11 , board .D5 , board .D13 ]
90
- if height > 16 :
105
+ if panel_height > 16 :
91
106
addr_pins .append (board .D9 )
92
107
rgb_pins = [board .D6 , board .A5 , board .A1 , board .A0 , board .A4 , board .D11 ]
93
108
clock_pin = board .D12
94
109
else :
95
110
addr_pins = [board .A5 , board .A4 , board .A3 ]
96
- if height > 16 :
111
+ if panel_height > 16 :
97
112
addr_pins .append (board .A2 )
98
113
rgb_pins = [
99
114
board .D6 ,
@@ -124,23 +139,50 @@ def __init__(
124
139
125
140
try :
126
141
displayio .release_displays ()
127
- matrix = rgbmatrix .RGBMatrix (
128
- width = width ,
129
- height = height ,
130
- bit_depth = bit_depth ,
131
- rgb_pins = (
132
- rgb_pins [red_index ],
133
- rgb_pins [green_index ],
134
- rgb_pins [blue_index ],
135
- rgb_pins [red_index + 3 ],
136
- rgb_pins [green_index + 3 ],
137
- rgb_pins [blue_index + 3 ],
138
- ),
139
- addr_pins = addr_pins ,
140
- clock_pin = clock_pin ,
141
- latch_pin = latch_pin ,
142
- output_enable_pin = oe_pin ,
143
- )
142
+ if tile_rows > 1 :
143
+ matrix = rgbmatrix .RGBMatrix (
144
+ width = width ,
145
+ height = height ,
146
+ bit_depth = bit_depth ,
147
+ rgb_pins = (
148
+ rgb_pins [red_index ],
149
+ rgb_pins [green_index ],
150
+ rgb_pins [blue_index ],
151
+ rgb_pins [red_index + 3 ],
152
+ rgb_pins [green_index + 3 ],
153
+ rgb_pins [blue_index + 3 ],
154
+ ),
155
+ addr_pins = addr_pins ,
156
+ clock_pin = clock_pin ,
157
+ latch_pin = latch_pin ,
158
+ output_enable_pin = oe_pin ,
159
+ tile = tile_rows ,
160
+ serpentine = serpentine ,
161
+ )
162
+ else :
163
+ matrix = rgbmatrix .RGBMatrix (
164
+ width = width ,
165
+ height = height ,
166
+ bit_depth = bit_depth ,
167
+ rgb_pins = (
168
+ rgb_pins [red_index ],
169
+ rgb_pins [green_index ],
170
+ rgb_pins [blue_index ],
171
+ rgb_pins [red_index + 3 ],
172
+ rgb_pins [green_index + 3 ],
173
+ rgb_pins [blue_index + 3 ],
174
+ ),
175
+ addr_pins = addr_pins ,
176
+ clock_pin = clock_pin ,
177
+ latch_pin = latch_pin ,
178
+ output_enable_pin = oe_pin ,
179
+ )
144
180
self .display = framebufferio .FramebufferDisplay (matrix )
181
+ except TypeError :
182
+ if tile_rows > 1 :
183
+ raise RuntimeError (
184
+ "Make sure you are running CircuitPython 6.2.0.alpha-1 or later"
185
+ ) from TypeError
186
+ raise
145
187
except ValueError :
146
188
raise RuntimeError ("Failed to initialize RGB Matrix" ) from ValueError
0 commit comments