File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
shared-bindings/neopixel_write Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 29
29
#include "py/mphal.h"
30
30
#include "py/runtime.h"
31
31
#include "shared-bindings/digitalio/DigitalInOut.h"
32
+ #include "shared-bindings/util.h"
32
33
#include "supervisor/shared/translate.h"
33
34
35
+ STATIC void check_for_deinit (digitalio_digitalinout_obj_t * self ) {
36
+ if (common_hal_digitalio_digitalinout_deinited (self )) {
37
+ raise_deinited_error ();
38
+ }
39
+ }
40
+
34
41
//| """Low-level neopixel implementation
35
42
//|
36
43
//| The `neopixel_write` module contains a helper method to write out bytes in
@@ -60,8 +67,13 @@ STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj
60
67
if (!mp_obj_is_type (digitalinout_obj , & digitalio_digitalinout_type )) {
61
68
mp_raise_TypeError_varg (translate ("Expected a %q" ), digitalio_digitalinout_type .name );
62
69
}
70
+
63
71
// Convert parameters into expected types.
64
72
const digitalio_digitalinout_obj_t * digitalinout = MP_OBJ_TO_PTR (digitalinout_obj );
73
+
74
+ // Check to see if the NeoPixel has been deinited before writing to it.
75
+ check_for_deinit (digitalinout_obj );
76
+
65
77
mp_buffer_info_t bufinfo ;
66
78
mp_get_buffer_raise (buf , & bufinfo , MP_BUFFER_READ );
67
79
// Call platform's neopixel write function with provided buffer and options.
You can’t perform that action at this time.
0 commit comments