Factor out code.py status messages
This commit is contained in:
parent
d01b9ce933
commit
8487a51995
33
main.c
33
main.c
|
@ -242,16 +242,24 @@ void cleanup_after_vm(supervisor_allocation* heap) {
|
||||||
reset_status_led();
|
reset_status_led();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool run_code_py(safe_mode_t safe_mode) {
|
void print_code_py_status_message(safe_mode_t safe_mode) {
|
||||||
bool serial_connected_at_start = serial_connected();
|
|
||||||
#if CIRCUITPY_AUTORELOAD_DELAY_MS > 0
|
|
||||||
if (serial_connected_at_start) {
|
|
||||||
serial_write("\n");
|
|
||||||
if (autoreload_is_enabled()) {
|
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"));
|
serial_write_compressed(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n"));
|
||||||
} else {
|
} else {
|
||||||
serial_write_compressed(translate("Auto-reload is off.\n"));
|
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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool run_code_py(safe_mode_t safe_mode) {
|
||||||
|
bool serial_connected_at_start = serial_connected();
|
||||||
|
#if CIRCUITPY_AUTORELOAD_DELAY_MS > 0
|
||||||
|
if (serial_connected_at_start) {
|
||||||
|
serial_write("\n");
|
||||||
|
print_code_py_status_message(safe_mode);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -263,10 +271,7 @@ bool run_code_py(safe_mode_t safe_mode) {
|
||||||
|
|
||||||
bool found_main = false;
|
bool found_main = false;
|
||||||
|
|
||||||
if (safe_mode != NO_SAFE_MODE) {
|
if (safe_mode == NO_SAFE_MODE) {
|
||||||
serial_write_compressed(translate("Running in safe mode! "));
|
|
||||||
serial_write_compressed(translate("Not running saved code.\n"));
|
|
||||||
} else {
|
|
||||||
new_status_color(MAIN_RUNNING);
|
new_status_color(MAIN_RUNNING);
|
||||||
|
|
||||||
static const char * const supported_filenames[] = STRING_LIST("code.txt", "code.py", "main.py", "main.txt");
|
static const char * const supported_filenames[] = STRING_LIST("code.txt", "code.py", "main.py", "main.txt");
|
||||||
|
@ -320,15 +325,7 @@ bool run_code_py(safe_mode_t safe_mode) {
|
||||||
|
|
||||||
if (!serial_connected_before_animation && serial_connected()) {
|
if (!serial_connected_before_animation && serial_connected()) {
|
||||||
if (!serial_connected_at_start) {
|
if (!serial_connected_at_start) {
|
||||||
if (autoreload_is_enabled()) {
|
print_code_py_status_message(safe_mode);
|
||||||
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);
|
print_safe_mode_message(safe_mode);
|
||||||
serial_write("\n");
|
serial_write("\n");
|
||||||
|
|
Loading…
Reference in New Issue