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.
- 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
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 the
no swapfileoption, or set the
directoryoption 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.
- notepad (the default Windows editor) and Notepad++ 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!