The CircuitPython code on your board detects when the files are changed or written and will automatically re-start your code. This makes coding very fast because you save, and it re-runs.
However, you must wait until the file is done being saved before unplugging or resetting your board! On Windows using some editors this can sometimes take up to 90 seconds, on Linux it can take 30 seconds to complete because the text editor does not save the file completely. Mac OS does not seem to have this delay, which is nice!
This is really important to be aware of. If you unplug or reset the board before your computer finishes writing the file to your board, you can corrupt the drive. If this happens, you may lose the code you've written, so it's important to backup your code to your computer regularly.
To avoid the likelihood of filesystem corruption, use an editor that writes out the file completely when you save it. Check out the list of recommended editors below.
Recommended editors
- mu is an editor that safely writes all changes (it's also our recommended editor!)
- emacs is also an editor that will fulIy write files on save
- Sublime Text safely writes all changes
- Visual Studio Code appears to safely write all changes
- gedit on Linux appears to safely write all changes
- IDLE, in Python 3.8.1 or later, was fixed to write all changes immediately
- Thonny fully writes files on save
- Notepad++ flushes files after writes, as of several years ago. In addition, you can change the path used for "Enable session snapshot and periodic backup" to write somewhere else than the CIRCUITPY drive. This will save space on CIRCUITPY and reduce writes to the drive.
Recommended only with particular settings or add-ons
-
vim / vi safely writes all changes. But set up vim to not write swapfiles (.swp files: temporary records of your edits) to CIRCUITPY. Run vim with
vim -n
, set theno swapfile
option, or set thedirectory
option to write swapfiles elsewhere. Otherwise the swapfile writes trigger restarts of your program. - The PyCharm IDE is safe if "Safe Write" is turned on in Settings->System Settings->Synchronization (true by default).
- If you are using Atom, install the fsync-on-save package or the language-circuitpython package so that it will always write out all changes to files on CIRCUITPY.
- SlickEdit works only if you add a macro to flush the disk.
Editors that are NOT recommended
- notepad (the default Windows editor) can be slow to write, so the editors above are recommended! If you are using notepad, be sure to eject the drive.
- IDLE in Python 3.8.0 or earlier does not force out changes immediately.
- nano (on Linux) does not force out changes.
- geany (on Linux) does not force out changes.
- Anything else - Other editors have not been tested so please use a recommended one!
Text editor powered by tinymce.