8000 Merge pull request #3661 from jepler/protomatter-error-checking-6x · ehershey/circuitpython@105ec12 · GitHub
[go: up one dir, main page]

Skip to content

Commit 105ec12

Browse files
authored
Merge pull request adafruit#3661 from jepler/protomatter-error-checking-6x
RGBMatrix: Detect invalid bit_depth selection
2 parents 40b8bc0 + 9817672 commit 105ec12

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

locale/circuitpython.pot

Lines changed: 6 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-10-15 16:06+0530\n"
11+
"POT-Creation-Date: 2020-11-11 14:06-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 <LL@li.org>\n"
@@ -416,6 +416,11 @@ msgstr ""
416416
msgid "Bit clock and word select must share a clock unit"
417417
msgstr ""
418418

419+
#: shared-bindings/rgbmatrix/RGBMatrix.c
420+
#, c-format
421+
msgid "Bit depth must be from 1 to 6 inclusive, not %d"
422+
msgstr ""
423+
419424
#: shared-bindings/audiobusio/PDMIn.c
420425
msgid "Bit depth must be multiple of 8."
421426
msgstr ""

shared-bindings/rgbmatrix/RGBMatrix.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n
197197
uint8_t clock_pin = validate_pin(args[ARG_clock_pin].u_obj);
198198
uint8_t latch_pin = validate_pin(args[ARG_latch_pin].u_obj);
199199
uint8_t output_enable_pin = validate_pin(args[ARG_output_enable_pin].u_obj);
200+
int bit_depth = args[ARG_bit_depth].u_int;
201+
202+
if (bit_depth <= 0 || bit_depth > 6) {
203+
mp_raise_ValueError_varg(translate("Bit depth must be from 1 to 6 inclusive, not %d"), bit_depth);
204+
}
200205

201206
validate_pins(MP_QSTR_rgb_pins, rgb_pins, MP_ARRAY_SIZE(self->rgb_pins), args[ARG_rgb_list].u_obj, &rgb_count);
202207
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
229234

230235
common_hal_rgbmatrix_rgbmatrix_construct(self,
231236
args[ARG_width].u_int,
232-
args[ARG_bit_depth].u_int,
237+
bit_depth,
233238
rgb_count, rgb_pins,
234239
addr_count, addr_pins,
235240
clock_pin, latch_pin, output_enable_pin,

0 commit comments

Comments
 (0)
0