@@ -45,15 +45,25 @@ class Matrix:
45
45
:param int height: The height of the display in Pixels. Defaults to 32.
46
46
:param int bit_depth: The number of bits per color channel. Defaults to 2.
47
47
:param list alt_addr_pins: An alternate set of address pins to use. Defaults to None
48
- :param list alt_rgb_pins: An alternate set of rgb pins to use. Defaults to None
48
+ :param string color_order: A string containing the letter "R", "G", and "B" in the
49
+ order you want. Defaults to "RGB"
49
50
50
51
"""
51
52
52
53
# pylint: disable=too-few-public-methods,too-many-branches
53
54
def __init__ (
54
- self , * , width = 64 , height = 32 , bit_depth = 2 , alt_addr_pins = None , alt_rgb_pins = None
55
+ self , * , width = 64 , height = 32 , bit_depth = 2 , alt_addr_pins = None , color_order = "RGB"
55
56
):
56
57
58
+ if not isinstance (color_order , str ):
59
+ raise ValueError ("color_index should be a string" )
60
+ color_order = color_order .lower ()
61
+ red_index = color_order .find ("r" )
62
+ green_index = color_order .find ("g" )
63
+ blue_index = color_order .find ("b" )
64
+ if - 1 in (red_index , green_index , blue_index ):
65
+ raise ValueError ("color_order should contain R, G, and B" )
66
+
57
67
if "Matrix Portal M4" in os .uname ().machine :
58
68
# MatrixPortal M4 Board
59
69
addr_pins = [board .MTX_ADDRA , board .MTX_ADDRB , board .MTX_ADDRC ]
@@ -108,10 +118,6 @@ def __init__(
108
118
latch_pin = board .D10
109
119
oe_pin = board .D9
110
120
111
- # Alternate Address Pins
112
- if alt_rgb_pins is not None :
113
- rgb_pins = alt_rgb_pins
114
-
115
121
# Alternate Address Pins
116
122
if alt_addr_pins is not None :
117
123
addr_pins = alt_addr_pins
@@ -122,7 +128,14 @@ def __init__(
122
128
width = width ,
123
129
height = height ,
124
130
bit_depth = bit_depth ,
125
- rgb_pins = rgb_pins ,
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
+ ),
126
139
addr_pins = addr_pins ,
127
140
clock_pin = clock_pin ,
128
141
latch_pin = latch_pin ,
0 commit comments