From d3317b002e416b14aedde52026ff56cd615d33ce Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 9 Oct 2021 12:11:07 -0500 Subject: [PATCH] check for None spi when initializing FourWire --- locale/circuitpython.pot | 4 ++++ shared-bindings/displayio/FourWire.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 00f72241fc..e3e5cd1f9b 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -2062,6 +2062,10 @@ msgstr "" msgid "SPI Re-initialization error" msgstr "" +#: shared-bindings/displayio/FourWire.c +msgid "SPI cannot be None" +msgstr "" + #: ports/espressif/common-hal/busio/SPI.c msgid "SPI configuration failed" msgstr "" diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c index c065fee551..e0ae91c46b 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/displayio/FourWire.c @@ -79,6 +79,9 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_ mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj); mp_obj_t spi = args[ARG_spi_bus].u_obj; + if (spi == mp_const_none) { + mp_raise_ValueError(translate("SPI cannot be None")); + } displayio_fourwire_obj_t *self = &allocate_display_bus_or_raise()->fourwire_bus; self->base.type = &displayio_fourwire_type;