RGBMatrix: Detect invalid bit_depth selection

Closes: #3650
This commit is contained in:
Jeff Epler 2020-11-09 08:27:20 -06:00
parent 9765b2c237
commit 0ff20cdd85

View File

@ -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,