From 51f054440516d21bd2e8d07a3e6f1f8e3acfbd55 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 09:19:44 -0600 Subject: [PATCH 1/6] protmatter: Update to version that supports tiling --- lib/protomatter | 2 +- shared-bindings/rgbmatrix/RGBMatrix.c | 27 ++++++++++++++++++--------- shared-bindings/rgbmatrix/RGBMatrix.h | 2 +- shared-module/rgbmatrix/RGBMatrix.c | 5 +++-- shared-module/rgbmatrix/RGBMatrix.h | 1 + 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/lib/protomatter b/lib/protomatter index 902c16f491..5e925cea7a 160000 --- a/lib/protomatter +++ b/lib/protomatter @@ -1 +1 @@ -Subproject commit 902c16f49197a8baf5e71ec924a812a86e733a74 +Subproject commit 5e925cea7a55273e375a6129761cb29b4e750d4f diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 5f5ea4fae7..ad693066cd 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -24,6 +24,8 @@ * THE SOFTWARE. */ +#include + #include "py/obj.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -132,11 +134,11 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ } } -//| def __init__(self, *, width: int, bit_depth: int, rgb_pins: Sequence[digitalio.DigitalInOut], addr_pins: Sequence[digitalio.DigitalInOut], clock_pin: digitalio.DigitalInOut, latch_pin: digitalio.DigitalInOut, output_enable_pin: digitalio.DigitalInOut, doublebuffer: bool = True, framebuffer: Optional[WriteableBuffer] = None, height: int = 0) -> None: +//| def __init__(self, *, width: int, bit_depth: int, rgb_pins: Sequence[digitalio.DigitalInOut], addr_pins: Sequence[digitalio.DigitalInOut], clock_pin: digitalio.DigitalInOut, latch_pin: digitalio.DigitalInOut, output_enable_pin: digitalio.DigitalInOut, doublebuffer: bool = True, framebuffer: Optional[WriteableBuffer] = None, height: int = 0, tile: int = 1, serpentine: bool = False) -> None: //| """Create a RGBMatrix object with the given attributes. The height of -//| the display is determined by the number of rgb and address pins: -//| len(rgb_pins) // 3 * 2 ** len(address_pins). With 6 RGB pins and 4 -//| address lines, the display will be 32 pixels tall. If the optional height +//| the display is determined by the number of rgb and address pins and the number of tiles: +//| ``len(rgb_pins) // 3 * 2 ** len(address_pins) * abs(tile)``. With 6 RGB pins, 4 +//| address lines, and a single matrix, the display will be 32 pixels tall. If the optional height //| parameter is specified and is not 0, it is checked against the calculated //| height. //| @@ -172,7 +174,7 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_width, ARG_bit_depth, ARG_rgb_list, ARG_addr_list, - ARG_clock_pin, ARG_latch_pin, ARG_output_enable_pin, ARG_doublebuffer, ARG_framebuffer, ARG_height }; + ARG_clock_pin, ARG_latch_pin, ARG_output_enable_pin, ARG_doublebuffer, ARG_framebuffer, ARG_height, ARG_tile, ARG_serpentine }; static const mp_arg_t allowed_args[] = { { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, { MP_QSTR_bit_depth, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, @@ -184,6 +186,8 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n { MP_QSTR_doublebuffer, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = true } }, { MP_QSTR_framebuffer, MP_ARG_OBJ | MP_ARG_KW_ONLY, { .u_obj = mp_const_none } }, { MP_QSTR_height, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0 } }, + { MP_QSTR_tile, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 1 } }, + { MP_QSTR_serpentine, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -210,15 +214,20 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n mp_raise_ValueError_varg(translate("Must use a multiple of 6 rgb pins, not %d"), rgb_count); } - // TODO(@jepler) Use fewer than all rows of pixels if height < computed_height + int tile = args[ARG_tile].u_int; + if (args[ARG_height].u_int != 0) { - int computed_height = (rgb_count / 3) << (addr_count); + int computed_height = (rgb_count / 3) << (addr_count) * abs(tile); if (computed_height != args[ARG_height].u_int) { mp_raise_ValueError_varg( - translate("%d address pins and %d rgb pins indicate a height of %d, not %d"), addr_count, rgb_count, computed_height, args[ARG_height].u_int); + translate("%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d"), addr_count, rgb_count, tile, computed_height, args[ARG_height].u_int); } } + if (args[ARG_serpentine].u_bool) { + tile = -tile; + } + if (args[ARG_width].u_int <= 0) { mp_raise_ValueError(translate("width must be greater than zero")); } @@ -239,7 +248,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n addr_count, addr_pins, clock_pin, latch_pin, output_enable_pin, args[ARG_doublebuffer].u_bool, - framebuffer, NULL); + framebuffer, tile, NULL); claim_and_never_reset_pins(args[ARG_rgb_list].u_obj); claim_and_never_reset_pins(args[ARG_addr_list].u_obj); diff --git a/shared-bindings/rgbmatrix/RGBMatrix.h b/shared-bindings/rgbmatrix/RGBMatrix.h index bfe37c3404..3e8a4db5f3 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.h +++ b/shared-bindings/rgbmatrix/RGBMatrix.h @@ -31,7 +31,7 @@ extern const mp_obj_type_t rgbmatrix_RGBMatrix_type; -void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t* self, int width, int bit_depth, uint8_t rgb_count, uint8_t* rgb_pins, uint8_t addr_count, uint8_t* addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, void* timer); +void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t* self, int width, int bit_depth, uint8_t rgb_count, uint8_t* rgb_pins, uint8_t addr_count, uint8_t* addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, void* timer); void common_hal_rgbmatrix_rgbmatrix_deinit(rgbmatrix_rgbmatrix_obj_t*); void rgbmatrix_rgbmatrix_collect_ptrs(rgbmatrix_rgbmatrix_obj_t*); void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, mp_obj_t framebuffer); diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index a09767b622..95a7eda75d 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -42,7 +42,7 @@ extern Protomatter_core *_PM_protoPtr; -void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, int width, int bit_depth, uint8_t rgb_count, uint8_t *rgb_pins, uint8_t addr_count, uint8_t *addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, void *timer) { +void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, int width, int bit_depth, uint8_t rgb_count, uint8_t *rgb_pins, uint8_t addr_count, uint8_t *addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, void *timer) { self->width = width; self->bit_depth = bit_depth; self->rgb_count = rgb_count; @@ -53,6 +53,7 @@ void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, i self->oe_pin = oe_pin; self->latch_pin = latch_pin; self->doublebuffer = doublebuffer; + self->tile = tile; self->timer = timer ? timer : common_hal_rgbmatrix_timer_allocate(); if (self->timer == NULL) { @@ -95,7 +96,7 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, self->rgb_count/6, self->rgb_pins, self->addr_count, self->addr_pins, self->clock_pin, self->latch_pin, self->oe_pin, - self->doublebuffer, self->timer); + self->doublebuffer, self->tile, self->timer); if (stat == PROTOMATTER_OK) { _PM_protoPtr = &self->protomatter; diff --git a/shared-module/rgbmatrix/RGBMatrix.h b/shared-module/rgbmatrix/RGBMatrix.h index 6dbc6fd41e..7fce73c8b1 100644 --- a/shared-module/rgbmatrix/RGBMatrix.h +++ b/shared-module/rgbmatrix/RGBMatrix.h @@ -44,4 +44,5 @@ typedef struct { bool core_is_initialized; bool paused; bool doublebuffer; + int8_t tile; } rgbmatrix_rgbmatrix_obj_t; From 345c2ae8a95f63834aea4f7ee5f1288fbc84e279 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 11:04:18 -0600 Subject: [PATCH 2/6] make translate --- locale/circuitpython.pot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 3ffc31cc6c..b896688b51 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -58,7 +58,8 @@ msgstr "" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -516,7 +517,6 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" From 368977fb906e6561bd67977a47dc0b415547cc33 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 14:33:48 -0600 Subject: [PATCH 3/6] RGBMatrix: Additional tile tweaks * Introduce explicit serpentine: bool argument instead of using negative numbers (thanks, ghost of @tannewt sitting on one shoulder) * Fix several calculations of height Testing performed (matrixportal): * set up a serpentine 64x64 virtual display with 2 64x32 tiles * tried all 4 rotations * looked at output of REPL --- shared-bindings/rgbmatrix/RGBMatrix.c | 17 ++++++++--------- shared-bindings/rgbmatrix/RGBMatrix.h | 2 +- shared-module/rgbmatrix/RGBMatrix.c | 10 ++++++---- shared-module/rgbmatrix/RGBMatrix.h | 1 + 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index ad693066cd..7218b2a9ea 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -24,8 +24,6 @@ * THE SOFTWARE. */ -#include - #include "py/obj.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -216,18 +214,19 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n int tile = args[ARG_tile].u_int; + if (tile < 0) { + mp_raise_ValueError_varg( + translate("tile must be greater than or equal to zero")); + } + if (args[ARG_height].u_int != 0) { - int computed_height = (rgb_count / 3) << (addr_count) * abs(tile); + int computed_height = (rgb_count / 3) * (1 << (addr_count)) * tile; if (computed_height != args[ARG_height].u_int) { mp_raise_ValueError_varg( translate("%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d"), addr_count, rgb_count, tile, computed_height, args[ARG_height].u_int); } } - if (args[ARG_serpentine].u_bool) { - tile = -tile; - } - if (args[ARG_width].u_int <= 0) { mp_raise_ValueError(translate("width must be greater than zero")); } @@ -237,7 +236,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n mp_obj_t framebuffer = args[ARG_framebuffer].u_obj; if (framebuffer == mp_const_none) { int width = args[ARG_width].u_int; - int bufsize = 2 * width * rgb_count / 3 * (1 << addr_count); + int bufsize = 2 * width * rgb_count / 3 * (1 << addr_count) * tile; framebuffer = mp_obj_new_bytearray_of_zeros(bufsize); } @@ -248,7 +247,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n addr_count, addr_pins, clock_pin, latch_pin, output_enable_pin, args[ARG_doublebuffer].u_bool, - framebuffer, tile, NULL); + framebuffer, tile, args[ARG_serpentine].u_bool, NULL); claim_and_never_reset_pins(args[ARG_rgb_list].u_obj); claim_and_never_reset_pins(args[ARG_addr_list].u_obj); diff --git a/shared-bindings/rgbmatrix/RGBMatrix.h b/shared-bindings/rgbmatrix/RGBMatrix.h index 3e8a4db5f3..4eb3c04b27 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.h +++ b/shared-bindings/rgbmatrix/RGBMatrix.h @@ -31,7 +31,7 @@ extern const mp_obj_type_t rgbmatrix_RGBMatrix_type; -void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t* self, int width, int bit_depth, uint8_t rgb_count, uint8_t* rgb_pins, uint8_t addr_count, uint8_t* addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, void* timer); +void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t* self, int width, int bit_depth, uint8_t rgb_count, uint8_t* rgb_pins, uint8_t addr_count, uint8_t* addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, bool serpentine, void* timer); void common_hal_rgbmatrix_rgbmatrix_deinit(rgbmatrix_rgbmatrix_obj_t*); void rgbmatrix_rgbmatrix_collect_ptrs(rgbmatrix_rgbmatrix_obj_t*); void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, mp_obj_t framebuffer); diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index 95a7eda75d..4318604c64 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -42,7 +42,7 @@ extern Protomatter_core *_PM_protoPtr; -void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, int width, int bit_depth, uint8_t rgb_count, uint8_t *rgb_pins, uint8_t addr_count, uint8_t *addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, void *timer) { +void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, int width, int bit_depth, uint8_t rgb_count, uint8_t *rgb_pins, uint8_t addr_count, uint8_t *addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, bool serpentine, void *timer) { self->width = width; self->bit_depth = bit_depth; self->rgb_count = rgb_count; @@ -54,6 +54,7 @@ void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, i self->latch_pin = latch_pin; self->doublebuffer = doublebuffer; self->tile = tile; + self->serpentine = serpentine; self->timer = timer ? timer : common_hal_rgbmatrix_timer_allocate(); if (self->timer == NULL) { @@ -61,7 +62,7 @@ void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, i } self->width = width; - self->bufsize = 2 * width * rgb_count / 3 * (1 << addr_count); + self->bufsize = 2 * width * rgb_count / 3 * (1 << addr_count) * tile; common_hal_rgbmatrix_rgbmatrix_reconstruct(self, framebuffer); } @@ -96,7 +97,8 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, self->rgb_count/6, self->rgb_pins, self->addr_count, self->addr_pins, self->clock_pin, self->latch_pin, self->oe_pin, - self->doublebuffer, self->tile, self->timer); + self->doublebuffer, self->serpentine ? -self->tile : self->tile, + self->timer); if (stat == PROTOMATTER_OK) { _PM_protoPtr = &self->protomatter; @@ -210,7 +212,7 @@ int common_hal_rgbmatrix_rgbmatrix_get_width(rgbmatrix_rgbmatrix_obj_t* self) { } int common_hal_rgbmatrix_rgbmatrix_get_height(rgbmatrix_rgbmatrix_obj_t* self) { - int computed_height = (self->rgb_count / 3) << (self->addr_count); + int computed_height = (self->rgb_count / 3) * (1 << (self->addr_count)) * self->tile; return computed_height; } diff --git a/shared-module/rgbmatrix/RGBMatrix.h b/shared-module/rgbmatrix/RGBMatrix.h index 7fce73c8b1..4a0e9235e7 100644 --- a/shared-module/rgbmatrix/RGBMatrix.h +++ b/shared-module/rgbmatrix/RGBMatrix.h @@ -44,5 +44,6 @@ typedef struct { bool core_is_initialized; bool paused; bool doublebuffer; + bool serpentine; int8_t tile; } rgbmatrix_rgbmatrix_obj_t; From 20c9f25a654df33e4fb719edfeaad8c4d4396f5e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 14:35:26 -0600 Subject: [PATCH 4/6] rgbmatrix: Eliminate some duplicated height-calculating code This was hard to write, so let's have it written in 2 places instead of 4. --- shared-bindings/rgbmatrix/RGBMatrix.c | 4 ++-- shared-module/rgbmatrix/RGBMatrix.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 7218b2a9ea..3b2039e4d1 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -219,8 +219,8 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n translate("tile must be greater than or equal to zero")); } + int computed_height = (rgb_count / 3) * (1 << (addr_count)) * tile; if (args[ARG_height].u_int != 0) { - int computed_height = (rgb_count / 3) * (1 << (addr_count)) * tile; if (computed_height != args[ARG_height].u_int) { mp_raise_ValueError_varg( translate("%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d"), addr_count, rgb_count, tile, computed_height, args[ARG_height].u_int); @@ -236,7 +236,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n mp_obj_t framebuffer = args[ARG_framebuffer].u_obj; if (framebuffer == mp_const_none) { int width = args[ARG_width].u_int; - int bufsize = 2 * width * rgb_count / 3 * (1 << addr_count) * tile; + int bufsize = 2 * width * computed_height; framebuffer = mp_obj_new_bytearray_of_zeros(bufsize); } diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index 4318604c64..b8db0d8939 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -62,7 +62,7 @@ void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, i } self->width = width; - self->bufsize = 2 * width * rgb_count / 3 * (1 << addr_count) * tile; + self->bufsize = 2 * width * common_hal_rgbmatrix_rgbmatrix_get_height(self); common_hal_rgbmatrix_rgbmatrix_reconstruct(self, framebuffer); } From 1c10ec99a774538e0e39414beb99ca3f0a0b5694 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 15:04:45 -0600 Subject: [PATCH 5/6] make translate --- locale/circuitpython.pot | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index b896688b51..4d8aceb85e 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -3710,6 +3710,10 @@ msgstr "" msgid "threshold must be in the range 0-65536" msgstr "" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than or equal to zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "" From 189ec2fc60f8dbfb5b054174f0062b9baeb27ca3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 15:05:24 -0600 Subject: [PATCH 6/6] Disallow tile=0 --- locale/circuitpython.pot | 2 +- shared-bindings/rgbmatrix/RGBMatrix.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 4d8aceb85e..81ee31e1ec 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -3711,7 +3711,7 @@ msgid "threshold must be in the range 0-65536" msgstr "" #: shared-bindings/rgbmatrix/RGBMatrix.c -msgid "tile must be greater than or equal to zero" +msgid "tile must be greater than zero" msgstr "" #: shared-bindings/time/__init__.c diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 3b2039e4d1..2a81bb53c2 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -214,9 +214,9 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n int tile = args[ARG_tile].u_int; - if (tile < 0) { + if (tile <= 0) { mp_raise_ValueError_varg( - translate("tile must be greater than or equal to zero")); + translate("tile must be greater than zero")); } int computed_height = (rgb_count / 3) * (1 << (addr_count)) * tile;