summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2017-02-22 20:10:10 +0100
committerScott Shawcroft <scott.shawcroft@gmail.com>2017-02-22 20:10:10 +0100
commit4c05086661bd486490442318934a57b93304aa0e (patch)
tree1986e043ecc710e377b76fcf39cfb53fcb198300 /shared-bindings
parentfc718d943794d294a5f80d1a041f13f1522a81ab (diff)
Check that neopixel write is actually given a DigitalInOut.
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/microcontroller/Pin.c2
-rw-r--r--shared-bindings/neopixel_write/__init__.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c
index ca717fe23..fd5285192 100644
--- a/shared-bindings/microcontroller/Pin.c
+++ b/shared-bindings/microcontroller/Pin.c
@@ -74,7 +74,7 @@ const mp_obj_type_t mcu_pin_type = {
void assert_pin(mp_obj_t obj, bool none_ok) {
if ((obj != mp_const_none || !none_ok) && !MP_OBJ_IS_TYPE(obj, &mcu_pin_type)) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "Expected a Pin"));
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "Expected a %q", mcu_pin_type.name));
}
}
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;