Remove overwrite of run_reason in main

When `reload_requested` is detected, the run reason will no longer be
automatically overwritten as an AUTO_RELOAD, making SUPERVISOR_RELOAD a
detectable reload reason. Autoreload now sets the reload reason itself.
This commit is contained in:
Lucian Copeland 2021-05-04 17:04:24 -04:00 committed by Dan Halbert
parent 47dbf9ef3e
commit 8f9122af50
2 changed files with 4 additions and 1 deletions

1
main.c
View File

@ -338,7 +338,6 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
board_init();
}
#endif
supervisor_set_run_reason(RUN_REASON_AUTO_RELOAD);
reload_requested = false;
return true;
}

View File

@ -30,6 +30,8 @@
#include "py/reload.h"
#include "supervisor/shared/tick.h"
#include "shared-bindings/supervisor/Runtime.h"
static volatile uint32_t autoreload_delay_ms = 0;
static bool autoreload_enabled = false;
static bool autoreload_suspended = false;
@ -44,6 +46,7 @@ inline void autoreload_tick() {
!autoreload_suspended && !reload_requested) {
mp_raise_reload_exception();
reload_requested = true;
supervisor_set_run_reason(RUN_REASON_AUTO_RELOAD);
supervisor_disable_tick();
}
autoreload_delay_ms--;
@ -91,4 +94,5 @@ void autoreload_now() {
}
mp_raise_reload_exception();
reload_requested = true;
supervisor_set_run_reason(RUN_REASON_AUTO_RELOAD);
}