Skip to content

Framebuffer zero size #3485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,10 @@ msgid ""
"exit safe mode.\n"
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
msgid ""
"The microcontroller's power dipped. Make sure your power supply provides\n"
Expand Down Expand Up @@ -3520,6 +3524,10 @@ msgstr ""
msgid "watchdog timeout must be greater than 0"
msgstr ""

#: shared-bindings/rgbmatrix/RGBMatrix.c
msgid "width must be greater than zero"
msgstr ""

#: shared-bindings/_bleio/Adapter.c
msgid "window must be <= interval"
msgstr ""
Expand Down
8 changes: 8 additions & 0 deletions shared-bindings/rgbmatrix/RGBMatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 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++) {
uint32_t pin_port = rgb_pins[i] / 32;

Expand Down Expand Up @@ -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);

mp_obj_t framebuffer = args[ARG_framebuffer].u_obj;
Expand Down