diff options
| author | Dan Halbert <halbert@halwitz.org> | 2020-11-22 19:10:09 -0500 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2020-11-22 19:10:09 -0500 |
| commit | a0f1ec3c4a3dd52b11752e10d0dd31202e9c705f (patch) | |
| tree | 333234f72abc302da7646f87a3c18740170b6bf7 /main.c | |
| parent | 75559f35ccc946dfd292e25671919e5d5b3bd7a6 (diff) | |
wip
Diffstat (limited to 'main.c')
| -rwxr-xr-x | main.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -61,6 +61,8 @@ #include "supervisor/usb.h" #include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/Processor.h" +#include "shared-bindings/supervisor/Runtime.h" #include "boards/board.h" @@ -327,24 +329,27 @@ bool run_code_py(safe_mode_t safe_mode) { #endif rgb_status_animation_t animation; bool ok = result.return_code != PYEXEC_EXCEPTION; - #if CIRCUITPY_ALARM // If USB isn't enumerated then deep sleep. if (ok && !supervisor_workflow_active() && supervisor_ticks_ms64() > CIRCUITPY_USB_ENUMERATION_DELAY * 1024) { - common_hal_alarm_restart_on_alarm(0, NULL); + common_hal_mcu_deep_sleep(); } - #endif // Show the animation every N seconds. prep_rgb_status_animation(&result, found_main, safe_mode, &animation); while (true) { RUN_BACKGROUND_TASKS; if (reload_requested) { + supervisor_set_run_reason(RUN_REASON_AUTO_RELOAD); reload_requested = false; return true; } if (serial_connected() && serial_bytes_available()) { // Skip REPL if reload was requested. - return (serial_read() == CHAR_CTRL_D); + bool ctrl_d = serial_read() == CHAR_CTRL_D; + if (ctrl_d) { + supervisor_set_run_reason(RUN_REASON_REPL_RELOAD); + } + return (ctrl_d); } if (!serial_connected_before_animation && serial_connected()) { @@ -521,6 +526,9 @@ int __attribute__((used)) main(void) { reset_devices(); reset_board(); + // This is first time we are running CircuitPython after a reset or power-up. + supervisor_set_run_reason(RUN_REASON_STARTUP); + // If not in safe mode turn on autoreload by default but before boot.py in case it wants to change it. if (safe_mode == NO_SAFE_MODE) { autoreload_enable(); |
