summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@adafruit.com>2020-11-11 20:26:25 -0500
committerGitHub <noreply@github.com>2020-11-11 20:26:25 -0500
commit105ec12144b432493ee7f9bd90e4265ff29bf410 (patch)
tree746b61a142a1b5fd45ea024ec5fb7d8fde0a89a6
parent40b8bc0c846af102b76f08afc3373f3123b84490 (diff)
parent9817672df7905a63ac168afd1792a46196864209 (diff)
Merge pull request #3661 from jepler/protomatter-error-checking-6x6.0.0-rc.2
RGBMatrix: Detect invalid bit_depth selection
-rw-r--r--locale/circuitpython.pot7
-rw-r--r--shared-bindings/rgbmatrix/RGBMatrix.c7
2 files changed, 12 insertions, 2 deletions
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index a5581e7fa..931ae6a42 100644
--- a/locale/circuitpython.pot
+++ b/locale/circuitpython.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-10-15 16:06+0530\n"
+"POT-Creation-Date: 2020-11-11 14:06-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -416,6 +416,11 @@ msgstr ""
msgid "Bit clock and word select must share a clock unit"
msgstr ""
+#: shared-bindings/rgbmatrix/RGBMatrix.c
+#, c-format
+msgid "Bit depth must be from 1 to 6 inclusive, not %d"
+msgstr ""
+
#: shared-bindings/audiobusio/PDMIn.c
msgid "Bit depth must be multiple of 8."
msgstr ""
diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c
index 753c1c920..5f5ea4fae 100644
--- a/shared-bindings/rgbmatrix/RGBMatrix.c
+++ b/shared-bindings/rgbmatrix/RGBMatrix.c
@@ -197,6 +197,11 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n
uint8_t clock_pin = validate_pin(args[ARG_clock_pin].u_obj);
uint8_t latch_pin = validate_pin(args[ARG_latch_pin].u_obj);
uint8_t output_enable_pin = validate_pin(args[ARG_output_enable_pin].u_obj);
+ int bit_depth = args[ARG_bit_depth].u_int;
+
+ if (bit_depth <= 0 || bit_depth > 6) {
+ mp_raise_ValueError_varg(translate("Bit depth must be from 1 to 6 inclusive, not %d"), bit_depth);
+ }
validate_pins(MP_QSTR_rgb_pins, rgb_pins, MP_ARRAY_SIZE(self->rgb_pins), args[ARG_rgb_list].u_obj, &rgb_count);
validate_pins(MP_QSTR_addr_pins, addr_pins, MP_ARRAY_SIZE(self->addr_pins), args[ARG_addr_list].u_obj, &addr_count);
@@ -229,7 +234,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n
common_hal_rgbmatrix_rgbmatrix_construct(self,
args[ARG_width].u_int,
- args[ARG_bit_depth].u_int,
+ bit_depth,
rgb_count, rgb_pins,
addr_count, addr_pins,
clock_pin, latch_pin, output_enable_pin,