diff options
| author | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-02-22 20:10:10 +0100 |
|---|---|---|
| committer | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-02-22 20:10:10 +0100 |
| commit | 4c05086661bd486490442318934a57b93304aa0e (patch) | |
| tree | 1986e043ecc710e377b76fcf39cfb53fcb198300 /shared-bindings/neopixel_write | |
| parent | fc718d943794d294a5f80d1a041f13f1522a81ab (diff) | |
Check that neopixel write is actually given a DigitalInOut.
Diffstat (limited to 'shared-bindings/neopixel_write')
| -rw-r--r-- | shared-bindings/neopixel_write/__init__.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/shared-bindings/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c index 8a75e7419..703534b3f 100644 --- a/shared-bindings/neopixel_write/__init__.c +++ b/shared-bindings/neopixel_write/__init__.c @@ -30,6 +30,7 @@ #include "common-hal/nativeio/types.h" +#include "shared-bindings/nativeio/DigitalInOut.h" #include "shared-bindings/neopixel_write/__init__.h" //| :mod:`neopixel_write` --- Low-level neopixel implementation @@ -50,6 +51,9 @@ //| :param bytearray buf: The bytes to clock out. No assumption is made about color order //| STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj_t buf) { + if (!MP_OBJ_IS_TYPE(digitalinout_obj, &nativeio_digitalinout_type)) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "Expected a %q", nativeio_digitalinout_type.name)); + } // Convert parameters into expected types. const nativeio_digitalinout_obj_t *digitalinout = MP_OBJ_TO_PTR(digitalinout_obj); mp_buffer_info_t bufinfo; |
