15.1.2. Scripts, examples, and the documents folder¶
15.1.2.1. New files¶
Creating a new file opens an untitled_N.py buffer
preloaded with a minimal capture loop – reset the
sensor, configure the pixel format and frame size, then
snapshot and print the frame rate forever. The starter
script is adapted to the connected board, so it runs as
created. The buffer lives in memory only: it can be
edited and run repeatedly without ever being saved,
which makes new files the cheapest way to test an idea.
Saving it to disk turns it into an ordinary script.
15.1.2.3. The documents folder¶
For personal scripts, the IDE watches an OpenMV
directory inside the platform’s documents folder
(Documents/OpenMV). Everything stored there appears
under File → Documents Folder, including
subdirectories, so a private script collection is one
menu away. The menu is built from the directory live –
files added outside the IDE show up the next time the
menu opens.
The IDE runs as a single instance: opening a .py
file from the platform’s file manager, or dropping one
onto the IDE window, opens it in the running window
rather than launching a second copy.
15.1.2.4. Cross-compiling a script¶
Tools → MicroPython Tools → Copy/Convert Python File
copies a .py file to a destination – the camera’s
drive, when one is connected – with a choice of what
happens on the way: copy it unchanged, strip
whitespace and/or comments to shrink it, or compile it
to a .mpy bytecode file with the mpy-cross
compiler matched to the target board. A .mpy file
imports exactly like the .py it came from, loads
faster, and does not ship its source – the form to
use when distributing a library module to the camera’s
filesystem. With a camera connected the target board
is taken from it automatically; otherwise the dialog
asks.
See also
MicroPython tools for mpy-cross and
mpremote as standalone command-line tools, and
MicroPython .mpy files for the .mpy file
format itself.