Merge pull request #8344 from jepler/repl-py

add support for "repl.py"
This commit is contained in:
Scott Shawcroft 2023-08-29 11:20:13 -07:00 committed by GitHub
commit b81c0e2924
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -133,6 +133,8 @@ Behavior
``code.py`` **in the REPL anymore, as the REPL is a fresh vm.** CircuitPython's goal for this ``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. 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. - 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. - 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 - Adds a safe mode that does not run user code after a hard crash or brown out. This makes it
@ -155,7 +157,7 @@ Behavior
- Re-runs ``code.py`` or other main file after file system writes by a workflow. (Disable with - Re-runs ``code.py`` or other main file after file system writes by a workflow. (Disable with
``supervisor.disable_autoreload()``) ``supervisor.disable_autoreload()``)
- Autoreload is disabled while the REPL is active. - 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``. - ``boot.py`` may also be named ``boot.txt``.
- ``safemode.py`` may also be named ``safemode.txt``. - ``safemode.py`` may also be named ``safemode.txt``.

5
main.c
View File

@ -934,6 +934,11 @@ STATIC int run_repl(safe_mode_t safe_mode) {
autoreload_suspend(AUTORELOAD_SUSPEND_REPL); 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 // 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 // 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 // won't. This simplifies pin sharing because they won't be in use when