33
33
#include "shared-bindings/supervisor/RunReason.h"
34
34
#include "shared-bindings/supervisor/Runtime.h"
35
35
36
+ #include "supervisor/shared/reload.h"
37
+
36
38
#if (CIRCUITPY_USB )
37
39
#include "tusb.h"
38
40
#endif
@@ -105,7 +107,7 @@ void supervisor_set_run_reason(supervisor_run_reason_t run_reason) {
105
107
}
106
108
107
109
//| run_reason: RunReason
108
- //| """Returns why CircuitPython started running this particular time."""
110
+ //| """Why CircuitPython started running this particular time."""
109
111
//|
110
112
STATIC mp_obj_t supervisor_runtime_get_run_reason (mp_obj_t self ) {
111
113
return cp_enum_find (& supervisor_run_reason_type , _run_reason );
@@ -115,11 +117,34 @@ MP_DEFINE_CONST_FUN_OBJ_1(supervisor_runtime_get_run_reason_obj, supervisor_runt
115
117
MP_PROPERTY_GETTER (supervisor_runtime_run_reason_obj ,
116
118
(mp_obj_t )& supervisor_runtime_get_run_reason_obj );
117
119
120
+ //| autoreload: bool
121
+ //| """Whether CircuitPython may autoreload based on workflow writes to the filesystem."""
122
+ //|
123
+ STATIC mp_obj_t supervisor_runtime_get_autoreload (mp_obj_t self ) {
124
+ return mp_obj_new_bool (autoreload_is_enabled ());
125
+ }
126
+ MP_DEFINE_CONST_FUN_OBJ_1 (supervisor_runtime_get_autoreload_obj , supervisor_runtime_get_autoreload );
127
+
128
+ STATIC mp_obj_t supervisor_runtime_set_autoreload (mp_obj_t self , mp_obj_t state_in ) {
129
+ if (mp_obj_is_true (state_in )) {
130
+ autoreload_enable ();
131
+ } else {
132
+ autoreload_disable ();
133
+ }
134
+ return mp_const_none ;
135
+ }
136
+ MP_DEFINE_CONST_FUN_OBJ_2 (supervisor_runtime_set_autoreload_obj , supervisor_runtime_set_autoreload );
137
+
138
+ MP_PROPERTY_GETSET (supervisor_runtime_autoreload_obj ,
139
+ (mp_obj_t )& supervisor_runtime_get_autoreload_obj ,
140
+ (mp_obj_t )& supervisor_runtime_set_autoreload_obj );
141
+
118
142
STATIC const mp_rom_map_elem_t supervisor_runtime_locals_dict_table [] = {
119
143
{ MP_ROM_QSTR (MP_QSTR_usb_connected ), MP_ROM_PTR (& supervisor_runtime_usb_connected_obj ) },
120
144
{ MP_ROM_QSTR (MP_QSTR_serial_connected ), MP_ROM_PTR (& supervisor_runtime_serial_connected_obj ) },
121
145
{ MP_ROM_QSTR (MP_QSTR_serial_bytes_available ), MP_ROM_PTR (& supervisor_runtime_serial_bytes_available_obj ) },
122
146
{ MP_ROM_QSTR (MP_QSTR_run_reason ), MP_ROM_PTR (& supervisor_runtime_run_reason_obj ) },
147
+ { MP_ROM_QSTR (MP_QSTR_autoreload ), MP_ROM_PTR (& supervisor_runtime_autoreload_obj ) },
123
148
};
124
149
125
150
STATIC MP_DEFINE_CONST_DICT (supervisor_runtime_locals_dict , supervisor_runtime_locals_dict_table );
0 commit comments