From adfd90f022e23ba6eb546b563c4eb824f6e8296e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 28 Aug 2023 13:57:44 -0500 Subject: [PATCH 1/2] add missing space --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index c07591ef3b..f9717dd691 100644 --- a/README.rst +++ b/README.rst @@ -155,7 +155,7 @@ Behavior - Re-runs ``code.py`` or other main file after file system writes by a workflow. (Disable with ``supervisor.disable_autoreload()``) - Autoreload is disabled while the REPL is active. -- ``code.py`` may also be named``code.txt``, ``main.py``, or ``main.txt``. +- ``code.py`` may also be named ``code.txt``, ``main.py``, or ``main.txt``. - ``boot.py`` may also be named ``boot.txt``. - ``safemode.py`` may also be named ``safemode.txt``. From d7cf11d3ef736ceb56b950279163d889bf83040d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 28 Aug 2023 13:59:34 -0500 Subject: [PATCH 2/2] Add repl.py support --- README.rst | 2 ++ main.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/README.rst b/README.rst index f9717dd691..fb0518bfbd 100644 --- a/README.rst +++ b/README.rst @@ -133,6 +133,8 @@ Behavior ``code.py`` **in the REPL anymore, as the REPL is a fresh vm.** CircuitPython's goal for this change includes reducing confusion about pins and memory being used. - After the main code is finished the REPL can be entered by pressing any key. + - If the file ``repl.py`` exists, it is executed before the REPL Prompt is shown + - In safe mode this functionality is disabled, to ensure the REPL Prompt can always be reached - Autoreload state will be maintained across reload. - Adds a safe mode that does not run user code after a hard crash or brown out. This makes it diff --git a/main.c b/main.c index 122f079129..af9f664672 100644 --- a/main.c +++ b/main.c @@ -929,6 +929,11 @@ STATIC int run_repl(safe_mode_t safe_mode) { autoreload_suspend(AUTORELOAD_SUSPEND_REPL); + if (get_safe_mode() == SAFE_MODE_NONE) { + const char *const filenames[] = { "repl.py" }; + (void)maybe_run_list(filenames, MP_ARRAY_SIZE(filenames)); + } + // Set the status LED to the REPL color before running the REPL. For // NeoPixels and DotStars this will be sticky but for PWM or single LED it // won't. This simplifies pin sharing because they won't be in use when