Skip to content

Commit 9e9dff4

Browse files
authored
Merge pull request #8400 from jepler/update-rgbmatrix-docs
rgbmatrix: more small doc improvements
2 parents f13edcc + ee86c76 commit 9e9dff4

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

ports/atmel-samd/boards/matrixportal_m4/pins.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
1+
#include "py/objtuple.h"
12
#include "shared-bindings/board/__init__.h"
23

4+
STATIC const mp_rom_obj_tuple_t matrix_addr_tuple = {
5+
{&mp_type_tuple},
6+
5,
7+
{
8+
MP_ROM_PTR(&pin_PB07),
9+
MP_ROM_PTR(&pin_PB08),
10+
MP_ROM_PTR(&pin_PB09),
11+
MP_ROM_PTR(&pin_PB15),
12+
MP_ROM_PTR(&pin_PB13),
13+
}
14+
};
15+
16+
STATIC const mp_rom_obj_tuple_t matrix_data_tuple = {
17+
{&mp_type_tuple},
18+
6,
19+
{
20+
MP_ROM_PTR(&pin_PB00),
21+
MP_ROM_PTR(&pin_PB01),
22+
MP_ROM_PTR(&pin_PB02),
23+
24+
MP_ROM_PTR(&pin_PB03),
25+
MP_ROM_PTR(&pin_PB04),
26+
MP_ROM_PTR(&pin_PB05),
27+
}
28+
};
29+
30+
STATIC const mp_rom_map_elem_t matrix_common_table[] = {
31+
{ MP_OBJ_NEW_QSTR(MP_QSTR_rgb_pins),MP_ROM_PTR(&matrix_data_tuple) },
32+
{ MP_OBJ_NEW_QSTR(MP_QSTR_clock_pin),MP_ROM_PTR(&pin_PB06) },
33+
{ MP_OBJ_NEW_QSTR(MP_QSTR_latch_pin),MP_ROM_PTR(&pin_PB14) },
34+
{ MP_OBJ_NEW_QSTR(MP_QSTR_output_enable_pin),MP_ROM_PTR(&pin_PB12) },
35+
};
36+
MP_DEFINE_CONST_DICT(matrix_common_dict, matrix_common_table);
37+
38+
339
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
440
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
541

@@ -30,6 +66,9 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
3066
{ MP_OBJ_NEW_QSTR(MP_QSTR_MOSI),MP_ROM_PTR(&pin_PA19) },
3167
{ MP_OBJ_NEW_QSTR(MP_QSTR_MISO),MP_ROM_PTR(&pin_PA17) },
3268

69+
{ MP_OBJ_NEW_QSTR(MP_QSTR_MTX_ADDRESS),MP_ROM_PTR(&matrix_addr_tuple) },
70+
{ MP_OBJ_NEW_QSTR(MP_QSTR_MTX_COMMON),MP_ROM_PTR(&matrix_common_dict) },
71+
3372
{ MP_OBJ_NEW_QSTR(MP_QSTR_MTX_R1),MP_ROM_PTR(&pin_PB00) },
3473
{ MP_OBJ_NEW_QSTR(MP_QSTR_MTX_G1),MP_ROM_PTR(&pin_PB01) },
3574
{ MP_OBJ_NEW_QSTR(MP_QSTR_MTX_B1),MP_ROM_PTR(&pin_PB02) },

shared-bindings/rgbmatrix/RGBMatrix.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_
159159
//| parameter is specified and is not 0, it is checked against the calculated
160160
//| height.
161161
//|
162-
//| Up to 30 RGB pins and 8 address pins are supported.
162+
//| Tiled matrices, those with more than one panel, must be laid out `in a specific order, as detailed in the guide
163+
//| <https://learn.adafruit.com/rgb-led-matrices-matrix-panels-with-circuitpython/advanced-multiple-panels>`_.
164+
//|
165+
//| At least 6 RGB pins and 5 address pins are supported, for common panels with up to 64 rows of pixels.
166+
//| Some microcontrollers may support more, up to a soft limit of 30 RGB pins and 8 address pins.
163167
//|
164168
//| The RGB pins must be within a single "port" and performance and memory
165169
//| usage are best when they are all within "close by" bits of the port.
@@ -188,12 +192,20 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_
188192
//| A RGBMatrix is often used in conjunction with a
189193
//| `framebufferio.FramebufferDisplay`.
190194
//|
195+
//| On boards designed for use with RGBMatrix panels, ``board.MTX_ADDRESS`` is a tuple of all the address pins, and ``board.MTX_COMMON`` is a dictionary with ``rgb_pins``, ``clock_pin``, ``latch_pin``, and ``output_enable_pin``.
196+
//| For panels that use fewer than the maximum number of address pins, "slice" ``MTX_ADDRESS`` to get the correct number of address pins.
197+
//| Using these board properties makes calling the constructor simpler and more portable:
198+
//|
199+
//| .. code-block:: python
200+
//|
201+
//| matrix = rgbmatrix.RGBMatrix(..., addr_pins=board.MTX_ADDRESS[:4], **board.MTX_COMMON)
202+
//|
191203
//| :param int width: The overall width of the whole matrix in pixels. For a matrix with multiple panels in row, this is the width of a single panel times the number of panels across.
192204
//| :param int tile: In a multi-row matrix, the number of rows of panels
193205
//| :param int bit_depth: The color depth of the matrix. A value of 1 gives 8 colors, a value of 2 gives 64 colors, and so on. Increasing bit depth increases the CPU and RAM usage of the RGBMatrix, and may lower the panel refresh rate. The framebuffer is always in RGB565 format regardless of the bit depth setting
194206
//| :param bool serpentine: In a multi-row matrix, True when alternate rows of panels are rotated 180°, which can reduce wiring length
195-
//| :param Sequence[digitalio.DigitalInOut] rgb_pins: The matrix's RGB pins
196-
//| :param Sequence[digitalio.DigitalInOut] addr_pins: The matrix's address pins
207+
//| :param Sequence[digitalio.DigitalInOut] rgb_pins: The matrix's RGB pins in the order ``(R1,G1,B1,R2,G2,B2...)``
208+
//| :param Sequence[digitalio.DigitalInOut] addr_pins: The matrix's address pins in the order ``(A,B,C,D...)``
197209
//| :param digitalio.DigitalInOut clock_pin: The matrix's clock pin
198210
//| :param digitalio.DigitalInOut latch_pin: The matrix's latch pin
199211
//| :param digitalio.DigitalInOut output_enable_pin: The matrix's output enable pin

0 commit comments

Comments
 (0)