Check map to display size
This commit is contained in:
parent
16c52b76d6
commit
5243a33584
@ -1458,6 +1458,10 @@ msgstr ""
|
||||
msgid "Key must be 16, 24, or 32 bytes long"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/is31fl3741/is31fl3741.c
|
||||
msgid "LED mappings must match display size"
|
||||
msgstr ""
|
||||
|
||||
#: py/compile.c
|
||||
msgid "LHS of keyword arg must be an id"
|
||||
msgstr ""
|
||||
|
@ -88,6 +88,9 @@ STATIC mp_obj_t is31fl3741_is31fl3741_make_new(const mp_obj_type_t *type, size_t
|
||||
|
||||
self->scale_width = args[ARG_width].u_int / 3;
|
||||
self->scale_height = args[ARG_height].u_int / 3;
|
||||
} else {
|
||||
self->scale_width = args[ARG_width].u_int;
|
||||
self->scale_height = args[ARG_height].u_int;
|
||||
}
|
||||
|
||||
self->auto_gamma = args[ARG_gamma].u_bool;
|
||||
|
@ -59,11 +59,14 @@ void common_hal_is31fl3741_is31fl3741_construct(is31fl3741_is31fl3741_obj_t *sel
|
||||
// of the heap as well.
|
||||
gc_never_free(self->i2c);
|
||||
|
||||
// TODO mapping should be equal to height * width * 3
|
||||
mp_obj_t *items;
|
||||
size_t len;
|
||||
mp_obj_list_get(mapping, &len, &items);
|
||||
|
||||
if (len != (size_t)(self->scale_width * self->scale_height * 3)) {
|
||||
mp_raise_ValueError(translate("LED mappings must match display size"));
|
||||
}
|
||||
|
||||
self->mapping = common_hal_is31fl3741_allocator_impl(sizeof(uint16_t) * len);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
mp_int_t value = mp_obj_get_int(items[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user