The PyCamera Arduino library brings in a considerable number of dependencies and takes a looong time to compile using Arduino IDE.
If you're working on an advanced MEMENTO project that requires additional dependencies, such as a component from the ESP-IDF component registry, you'll want to compile the PyCamera Arduino project using PlatformIO rather than Arduino IDE.
How fast is it? Very! Using PlatformIO compiles the PyCamera Library Test example in ~4.10 seconds.
Installation
Follow this page's instructions to install PlatformIO and Visual Studio Code (the IDE of choice for using PlatformIO).
The ZIP file below includes a pre-configured workspace for using PlatformIO. Download and unzip this file. Then, save it somewhere safe, like your desktop.
Open Visual Studio Code (VSCode). To ensure you have installed the PlatformIO extension properly, look for the alien symbol in your VSCode sidebar.
Underneath Start, click Open...
Navigate to the folder created when you unzipped the zip file. Then, Click Open to open the workspace.
A large amount of configuration files and directories will appear in your VSCode instance.
To compile this code, we are only going to discuss the following files and directories:
-
platformio.ini
- This is the project configuration file used to build the demo code. More documentation about this file is located here. -
lib
directory - This directory is intended for project-specific (private) libraries. PlatformIO will compile them to static libraries and link them into executable files.- For our project, the specific library within this directory is the Adafruit_PyCamera library.
src
directory - The directory where the source code of the project is located,main.cpp
. When code in PlatformIO is built or uploaded, files from this directory are used.
PyCamera Library Test
Before the code is compiled, you'll need to make two changes to the platformio.ini file:
- Change
upload_port
to reflect the MEMENTO's upload port. -
The
monitor_port
is different from theupload_port
, and will only appear on your computer when you've uploaded the test code. For now, leave this alone.- After uploading the test code, change
monitor_port
to reflect the MEMENTO's monitor/serial port.
- After uploading the test code, change
Navigate to src/main.cpp
to open the example code.
With this file open, click the Alien symbol on the VSCode sidebar to open the PlatformIO Project Explorer.
Underneath PlatformIO's Project Tasks, click Build.
Once the build task is completed, the terminal will show SUCCESS
along with the time it took to compile the project.
Before uploading this project to the board, put the board into ROM Bootloader Mode.
From the PlatformIO Project Tasks menu, click Upload.
Once the upload completes, the terminal should look like the following screenshot and show SUCCESS
.
Press the RST (Reset) button on the MEMENTO to run the uploaded code.
After the board resets, you'll see a preview of what the camera module is seeing on the MEMENTO display. You'll be able to change the resolution and filter for the camera. If you insert a microSD card, you'll be able to take pictures using the BOOT button.
Text editor powered by tinymce.