From d01b9ce933048c69c7611cd4f512baa040f2f101 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 7 Oct 2020 22:15:05 +0530 Subject: [PATCH] Disable auto-reload in safe mode --- main.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index dbd367a596..1f7352b0e9 100755 --- a/main.c +++ b/main.c @@ -249,10 +249,7 @@ bool run_code_py(safe_mode_t safe_mode) { serial_write("\n"); if (autoreload_is_enabled()) { serial_write_compressed(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); - } else if (safe_mode != NO_SAFE_MODE) { - serial_write_compressed(translate("Running in safe mode! ")); - serial_write_compressed(translate("Auto-reload is off.\n")); - } else if (!autoreload_is_enabled()) { + } else { serial_write_compressed(translate("Auto-reload is off.\n")); } } @@ -322,16 +319,16 @@ bool run_code_py(safe_mode_t safe_mode) { } if (!serial_connected_before_animation && serial_connected()) { - if (serial_connected_at_start) { - serial_write("\n\n"); - } - if (!serial_connected_at_start) { if (autoreload_is_enabled()) { serial_write_compressed(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); } else { serial_write_compressed(translate("Auto-reload is off.\n")); } + if (safe_mode != NO_SAFE_MODE) { + serial_write_compressed(translate("Running in safe mode! ")); + serial_write_compressed(translate("Not running saved code.\n")); + } } print_safe_mode_message(safe_mode); serial_write("\n"); @@ -486,8 +483,10 @@ int __attribute__((used)) main(void) { reset_devices(); reset_board(); - // Turn on autoreload by default but before boot.py in case it wants to change it. - autoreload_enable(); + // 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(); + } // By default our internal flash is readonly to local python code and // writable over USB. Set it here so that boot.py can change it.