13.1.2. Scripts, examples, and the documents folder¶
13.1.2.1. New files¶
Create a new file and the IDE 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: you can edit and run it repeatedly without ever saving it, which makes new files the cheapest way to test an idea. Save it to disk and it becomes an ordinary script.
13.1.2.3. The documents folder¶
For your own scripts, the IDE watches an OpenMV directory inside your documents folder (Documents/OpenMV). Everything you store there appears under File → Documents Folder, including subdirectories, so your script collection is one menu away. The menu reads the directory live – files you add outside the IDE show up the next time the menu opens.
The IDE runs as a single instance: open a .py file from your file manager, or drop one onto the IDE window, and it opens in the running window rather than launching a second copy.
13.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 – and lets you choose 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 IDE picks the target board automatically; otherwise the dialog asks which board to compile for. The board choice matters because it sets the processor architecture the compiler targets: a .mpy file is matched to the camera it will run on, and one compiled for a different board family is not guaranteed to load.
See also
MicroPython tools for mpy-cross and mpremote as standalone command-line tools, and MicroPython .mpy files for the .mpy file format itself.