summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@adafruit.com>2020-10-01 14:24:10 -0700
committerGitHub <noreply@github.com>2020-10-01 14:24:10 -0700
commit92d15096d25362d20ba89c67631c1ef30a3f45ee (patch)
tree48f20029cdb92becce02a7f03c3b57ae346b0550
parentd62ac24493abb7aadcf68751997092a1b4141b01 (diff)
parentc27e3857b6d2a1d162f8ea977ca1e99cbfb6417b (diff)
Merge pull request #3485 from jepler/framebuffer-zero-size
Framebuffer zero size
-rw-r--r--locale/circuitpython.pot8
-rw-r--r--shared-bindings/rgbmatrix/RGBMatrix.c8
2 files changed, 16 insertions, 0 deletions
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index 1eb16a0e8..c4951f78f 100644
--- a/locale/circuitpython.pot
+++ b/locale/circuitpython.pot
@@ -1666,6 +1666,10 @@ msgid ""
"exit safe mode.\n"
msgstr ""
+#: shared-bindings/rgbmatrix/RGBMatrix.c
+msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid ""
"The microcontroller's power dipped. Make sure your power supply provides\n"
@@ -3520,6 +3524,10 @@ msgstr ""
msgid "watchdog timeout must be greater than 0"
msgstr ""
+#: shared-bindings/rgbmatrix/RGBMatrix.c
+msgid "width must be greater than zero"
+msgstr ""
+
#: shared-bindings/_bleio/Adapter.c
msgid "window must be <= interval"
msgstr ""
diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c
index e4683af92..753c1c920 100644
--- a/shared-bindings/rgbmatrix/RGBMatrix.c
+++ b/shared-bindings/rgbmatrix/RGBMatrix.c
@@ -73,6 +73,10 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_
uint32_t port = clock_pin / 32;
uint32_t bit_mask = 1 << (clock_pin % 32);
+ if (rgb_pin_count <= 0 || rgb_pin_count % 6 != 0 || rgb_pin_count > 30) {
+ mp_raise_ValueError_varg(translate("The length of rgb_pins must be 6, 12, 18, 24, or 30"));
+ }
+
for (uint8_t i = 0; i < rgb_pin_count; i++) {
uint32_t pin_port = rgb_pins[i] / 32;
@@ -210,6 +214,10 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n
}
}
+ if (args[ARG_width].u_int <= 0) {
+ mp_raise_ValueError(translate("width must be greater than zero"));
+ }
+
preflight_pins_or_throw(clock_pin, rgb_pins, rgb_count, true);
mp_obj_t framebuffer = args[ARG_framebuffer].u_obj;