summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2020-09-28 19:03:04 -0500
committerJeff Epler <jepler@gmail.com>2020-09-29 19:55:31 -0500
commite4b9c168912799d126894dbdf44f6af5c5d4878d (patch)
tree6df7c980ee233eca8504c39c272a978943424c64 /shared-bindings
parent176b3376113180ab38fe1c43e2947d358ff041fe (diff)
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.
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/rgbmatrix/RGBMatrix.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c
index 6a99e1f3d..7ddbd36fb 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;