Skip to content

Commit e4b9c16

Browse files
committed
rgbmatrix: Check that the number of rgb pins is supported.
Having zero RGB pins may not have been caught, nor having a non-multiple-of-6 value. Generally, users will only have 6 RGB pins unless they are driving multiple matrices in parallel. No existing breakouts exist to do this, and there are probably not any efficient pinouts to be had anyway.
1 parent 176b337 commit e4b9c16

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

locale/circuitpython.pot

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-09-29 11:11+0530\n"
11+
"POT-Creation-Date: 2020-09-29 19:54-0500\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -1662,6 +1662,10 @@ msgid ""
16621662
"exit safe mode.\n"
16631663
msgstr ""
16641664

1665+
#: shared-bindings/rgbmatrix/RGBMatrix.c
1666+
msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30"
1667+
msgstr ""
1668+
16651669
#: supervisor/shared/safe_mode.c
16661670
msgid ""
16671671
"The microcontroller's power dipped. Make sure your power supply provides\n"
@@ -3516,6 +3520,10 @@ msgstr ""
35163520
msgid "watchdog timeout must be greater than 0"
35173521
msgstr ""
35183522

3523+
#: shared-bindings/rgbmatrix/RGBMatrix.c
3524+
msgid "width must be greater than zero"
3525+
msgstr ""
3526+
35193527
#: shared-bindings/_bleio/Adapter.c
35203528
msgid "window must be <= interval"
35213529
msgstr ""

shared-bindings/rgbmatrix/RGBMatrix.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_
7373
uint32_t port = clock_pin / 32;
7474
uint32_t bit_mask = 1 << (clock_pin % 32);
7575

76+
if (rgb_pin_count <= 0 || rgb_pin_count % 6 != 0 || rgb_pin_count > 30) {
77+
mp_raise_ValueError_varg(translate("The length of rgb_pins must be 6, 12, 18, 24, or 30"));
78+
}
79+
7680
for (uint8_t i = 0; i < rgb_pin_count; i++) {
7781
uint32_t pin_port = rgb_pins[i] / 32;
7882

0 commit comments

Comments
 (0)