Merge pull request #3485 from jepler/framebuffer-zero-size

Framebuffer zero size
This commit is contained in:
Scott Shawcroft 2020-10-01 14:24:10 -07:00 committed by GitHub
commit 92d15096d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -1666,6 +1666,10 @@ msgid ""
"exit safe mode.\n" "exit safe mode.\n"
msgstr "" msgstr ""
#: shared-bindings/rgbmatrix/RGBMatrix.c
msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30"
msgstr ""
#: supervisor/shared/safe_mode.c #: supervisor/shared/safe_mode.c
msgid "" msgid ""
"The microcontroller's power dipped. Make sure your power supply provides\n" "The microcontroller's power dipped. Make sure your power supply provides\n"
@ -3520,6 +3524,10 @@ msgstr ""
msgid "watchdog timeout must be greater than 0" msgid "watchdog timeout must be greater than 0"
msgstr "" msgstr ""
#: shared-bindings/rgbmatrix/RGBMatrix.c
msgid "width must be greater than zero"
msgstr ""
#: shared-bindings/_bleio/Adapter.c #: shared-bindings/_bleio/Adapter.c
msgid "window must be <= interval" msgid "window must be <= interval"
msgstr "" msgstr ""

View File

@ -73,6 +73,10 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_
uint32_t port = clock_pin / 32; uint32_t port = clock_pin / 32;
uint32_t bit_mask = 1 << (clock_pin % 32); uint32_t bit_mask = 1 << (clock_pin % 32);
if (rgb_pin_count <= 0 || rgb_pin_count % 6 != 0 || rgb_pin_count > 30) {
mp_raise_ValueError_varg(translate("The length of rgb_pins must be 6, 12, 18, 24, or 30"));
}
for (uint8_t i = 0; i < rgb_pin_count; i++) { for (uint8_t i = 0; i < rgb_pin_count; i++) {
uint32_t pin_port = rgb_pins[i] / 32; uint32_t pin_port = rgb_pins[i] / 32;
@ -210,6 +214,10 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n
} }
} }
if (args[ARG_width].u_int <= 0) {
mp_raise_ValueError(translate("width must be greater than zero"));
}
preflight_pins_or_throw(clock_pin, rgb_pins, rgb_count, true); preflight_pins_or_throw(clock_pin, rgb_pins, rgb_count, true);
mp_obj_t framebuffer = args[ARG_framebuffer].u_obj; mp_obj_t framebuffer = args[ARG_framebuffer].u_obj;