Skip to content

Commit 5243a33

Browse files
committed
Check map to display size
1 parent 16c52b7 commit 5243a33

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

locale/circuitpython.pot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,10 @@ msgstr ""
14581458
msgid "Key must be 16, 24, or 32 bytes long"
14591459
msgstr ""
14601460

1461+
#: shared-module/is31fl3741/is31fl3741.c
1462+
msgid "LED mappings must match display size"
1463+
msgstr ""
1464+
14611465
#: py/compile.c
14621466
msgid "LHS of keyword arg must be an id"
14631467
msgstr ""

shared-bindings/is31fl3741/is31fl3741.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ STATIC mp_obj_t is31fl3741_is31fl3741_make_new(const mp_obj_type_t *type, size_t
8888

8989
self->scale_width = args[ARG_width].u_int / 3;
9090
self->scale_height = args[ARG_height].u_int / 3;
91+
} else {
92+
self->scale_width = args[ARG_width].u_int;
93+
self->scale_height = args[ARG_height].u_int;
9194
}
9295

9396
self->auto_gamma = args[ARG_gamma].u_bool;

shared-module/is31fl3741/is31fl3741.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ void common_hal_is31fl3741_is31fl3741_construct(is31fl3741_is31fl3741_obj_t *sel
5959
// of the heap as well.
6060
gc_never_free(self->i2c);
6161

62-
// TODO mapping should be equal to height * width * 3
6362
mp_obj_t *items;
6463
size_t len;
6564
mp_obj_list_get(mapping, &len, &items);
6665

66+
if (len != (size_t)(self->scale_width * self->scale_height * 3)) {
67+
mp_raise_ValueError(translate("LED mappings must match display size"));
68+
}
69+
6770
self->mapping = common_hal_is31fl3741_allocator_impl(sizeof(uint16_t) * len);
6871
for (size_t i = 0; i < len; i++) {
6972
mp_int_t value = mp_obj_get_int(items[i]);

0 commit comments

Comments
 (0)