Hi could you offer a brief explanation of what PlatformIO is and how I can go about using it? A tutorial or something would be nice.
Sure thing. Platformio is a system that automates the build environment for embedded applications. It runs on Mac/Windows/Linux and supports hundreds of hardware boards (like Teensy), twenty or so frameworks (like Arduino, mbed, etc...) and hundreds of libraries. It takes care of downloading and installing all the support code and tools and builds binaries fast. It works from the command line or you can use it with Atom or VSCode IDEs (and others). It has continuous integration facilities, test, debugging and much more.
The Teensy integration is excellent. They track the latest releases of the Teensy software quickly and automatically update as you use it, so you don't have to reinstall new versions by hand.
Here's a quick tutorial for the command line use of Platformio.
First go here to get it installed:
https://platformio.org/install/cli
This will lead you to platform specific installation instructions. On my Mac with Homebrew, it was just
It's a little more complicated on other platforms.
The website has a bunch of tutorials and demos, but here's what you do to build and upload a minimal "blink" project.
First create a project directory:
Then drop down into it:
Then have platformio create a project for you:
Code:
platformio init --board teensy31
(This is for both Teensy 3.1 and 3.2) Then put a blink.cpp file in the "src" directory, here's the example that they provide:
Code:
/*
* Blink
* Turns on an LED on for one second,
* then off for one second, repeatedly.
*/
#include "Arduino.h"
// Set LED_BUILTIN if it is not defined by Arduino framework
// #define LED_BUILTIN 13
void setup()
{
// initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// wait for a second
delay(1000);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// wait for a second
delay(1000);
}
Then cd back to the original blink folder and do
Code:
platformio run --target upload
This will build and upload your blink project. That's it!
You can customize the platformio.ini file in that directory to do all sorts of things like create build targets formultiple hardware platforms, change compiler directives, specify libraries if platformio doesn't find what you need automatically, etc.