summaryrefslogtreecommitdiff
path: root/shared-bindings/supervisor/Runtime.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott@adafruit.com>2020-12-02 12:51:43 -0800
committerGitHub <noreply@github.com>2020-12-02 12:51:43 -0800
commitd7ba641ff646b48e5ad38ff72a2dcfe17bb54624 (patch)
treea0c4f9fb561b2caa38636645ca27f0ddad59f087 /shared-bindings/supervisor/Runtime.c
parent5b3c930e384ef6440f0f7b5167bb54ea68a8be76 (diff)
parent72fa7d88b881d2ed9978c0bd65ce5f8d6eb51703 (diff)
Merge pull request #3767 from dhalbert/sleep
Initial alarm and sleep PR: time alarms with light and deep sleep; PinAlarms not yet implemented
Diffstat (limited to 'shared-bindings/supervisor/Runtime.c')
-rwxr-xr-xshared-bindings/supervisor/Runtime.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c
index bfca6e7b1..8e0259a3b 100755
--- a/shared-bindings/supervisor/Runtime.c
+++ b/shared-bindings/supervisor/Runtime.c
@@ -25,9 +25,16 @@
*/
#include <stdbool.h>
+#include "py/obj.h"
+#include "py/enum.h"
+#include "py/runtime.h"
#include "py/objproperty.h"
+
+#include "shared-bindings/supervisor/RunReason.h"
#include "shared-bindings/supervisor/Runtime.h"
+STATIC supervisor_run_reason_t _run_reason;
+
//TODO: add USB, REPL to description once they're operational
//| class Runtime:
//| """Current status of runtime objects.
@@ -90,9 +97,29 @@ const mp_obj_property_t supervisor_serial_bytes_available_obj = {
};
+//| run_reason: RunReason
+//| """Returns why CircuitPython started running this particular time."""
+//|
+STATIC mp_obj_t supervisor_get_run_reason(mp_obj_t self) {
+ return cp_enum_find(&supervisor_run_reason_type, _run_reason);
+}
+MP_DEFINE_CONST_FUN_OBJ_1(supervisor_get_run_reason_obj, supervisor_get_run_reason);
+
+const mp_obj_property_t supervisor_run_reason_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&supervisor_get_run_reason_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
+void supervisor_set_run_reason(supervisor_run_reason_t run_reason) {
+ _run_reason = run_reason;
+}
+
STATIC const mp_rom_map_elem_t supervisor_runtime_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_serial_connected), MP_ROM_PTR(&supervisor_serial_connected_obj) },
{ MP_ROM_QSTR(MP_QSTR_serial_bytes_available), MP_ROM_PTR(&supervisor_serial_bytes_available_obj) },
+ { MP_ROM_QSTR(MP_QSTR_run_reason), MP_ROM_PTR(&supervisor_run_reason_obj) },
};
STATIC MP_DEFINE_CONST_DICT(supervisor_runtime_locals_dict, supervisor_runtime_locals_dict_table);