Merge pull request #5450 from FoamyGuy/none_check_fourwire

Fix `FourWire` and `I2CDisplay` argument validation
This commit is contained in:
Jeff Epler 2021-10-10 05:35:26 -05:00 committed by GitHub
commit 797f0a1ed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -32,6 +32,7 @@
#include "py/binary.h" #include "py/binary.h"
#include "py/objproperty.h" #include "py/objproperty.h"
#include "py/runtime.h" #include "py/runtime.h"
#include "shared-bindings/busio/SPI.h"
#include "shared-bindings/displayio/Group.h" #include "shared-bindings/displayio/Group.h"
#include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/util.h" #include "shared-bindings/util.h"
@ -78,7 +79,8 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_
mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj); mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj);
mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj); 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; mp_obj_t spi = mp_arg_validate_type(args[ARG_spi_bus].u_obj, &busio_spi_type, MP_QSTR_spi_bus);
displayio_fourwire_obj_t *self = &allocate_display_bus_or_raise()->fourwire_bus; displayio_fourwire_obj_t *self = &allocate_display_bus_or_raise()->fourwire_bus;
self->base.type = &displayio_fourwire_type; self->base.type = &displayio_fourwire_type;

View File

@ -34,6 +34,7 @@
#include "py/objproperty.h" #include "py/objproperty.h"
#include "py/runtime.h" #include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/busio/I2C.h"
#include "shared-bindings/util.h" #include "shared-bindings/util.h"
#include "shared-module/displayio/__init__.h" #include "shared-module/displayio/__init__.h"
#include "supervisor/shared/translate.h" #include "supervisor/shared/translate.h"
@ -67,7 +68,7 @@ STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t
mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj); mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj);
mp_obj_t i2c = args[ARG_i2c_bus].u_obj; mp_obj_t i2c = mp_arg_validate_type(args[ARG_i2c_bus].u_obj, &busio_i2c_type, MP_QSTR_i2c_bus);
displayio_i2cdisplay_obj_t *self = &allocate_display_bus_or_raise()->i2cdisplay_bus; displayio_i2cdisplay_obj_t *self = &allocate_display_bus_or_raise()->i2cdisplay_bus;
self->base.type = &displayio_i2cdisplay_type; self->base.type = &displayio_i2cdisplay_type;