Artemis Teensy Flight Software
The software on the Teensy in the Artemis cubesat.
Development Environment Setup Guide

This is a guide on how to set up your Development Environment (DE) to compile, run, and debug the Teensy Flight Software (FSW).

Step 1: Install VSCode

The FSW is written and compiled using Visual Studio Code (VSCode). Download and install this editor.

Once installed, click the Extensions tab on the left navigation menu.

The Extensions tab is the fifth tab down on the left.

Search for the C/C++ extension and install it if not already installed.

Searching for the C/C++ extension made by Microsoft.

Step 2: Install PlatformIO

The PlatformIO IDE is used for programming the Teensy. It is installed as an extension to VSCode. Search for the PlatformIO IDE extension and install it.

Searching for the PlatformIO IDE extension made by PlatformIO.

You should then see the shell install the IDE. If you do not see this, restart VSCode.

The shell installing PlatformIO IDE.

After installation is complete, RESTART VSCode. Pressing "Reload Now" is not sufficient.

PlatformIO IDE installation is complete.

Verify PlatformIO IDE is installed. You should see a new icon in the left navigation menu.

PlatformIO IDE icon in the left navigation menu.

Step 3: Build a test project

You can now verify that the PlatformIO IDE has been installed correctly by creating a test project. Begin by pressing the home button on the bottom navigation bar.

The home button on the bottom navigation bar.

Click on "New Project". If this page does not appear, restart VSCode. If the page still doesn't appear, retry the installation process.

The New Project button on the PIO Home page.

Fill out the Project Wizard as shown and click Finish. Wait for the IDE to create the project.

  • The Name is agent_artemis
  • The Board is Teensy 4.1
  • The Framework is Arduino
  • The Location is set to Use default location

The Project Wizard dialog.

If VSCode prompts you to trust the authors, click Yes.

The trust authors dialog.

You should now see the project open in your workspace.

The agent_artemis project open in the VSCode workspace.

The main code is located in src/main.cpp. Add the following code to this file:

/**
* 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);
Serial.println("Hello World");
// 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);
}

Before building the project, ensure the environment is set to Teensy 4.1. If the environment (as shown in the bottom navigation bar) says "Default", change it.

Click on Default (agent_artemis).

The Default Environment.

On the top of VSCode, a dropdown should have appeared. Click on env:teensy41

The Environment Selection dropdown.

Verify your environment has changed.

The teensy41 Environment.

Click the checkmark on the bottom navigation bar to build.

The build button on the bottom navigation bar.

Connect a Teensy 4.1 to your computer over USB. Click the right arrow icon on the bottom navigation bar to upload the project to your Teensy.

The upload button on the bottom navigation bar.

After a successful upload, you can monitor the Serial output by clicking the plug icon on the bottom navigation bar.

The monitor button on the bottom navigation bar.

Step 4: Clone the FSW

Now that you've uploaded a test program, you are ready to work with the FSW. The easiest way to do so is with GitHub Desktop.

Install it and log in using your GitHub credentials. Go to the FSW repo. If you do not have access to this repo, verify that you have been added to the VIP Aerospace Technologies organization. If you are not, ask team leadership to be added to the organization.

Once you have access to the repo, press the green "Code" button, then press the "Open with GitHub Desktop" button.

The clone menu on the vip-aerospace/Artemis-Teensy-Flight-Software repo.

GitHub Desktop will open with the Clone a repository dialog. You can choose where you want to save the repository here. It is usually a good idea to save the repo close to your root directory. Choose a local path and press "Clone".

The clone a repository dialog in GitHub Desktop.

Open the repo's directory in the Command Prompt/Terminal, and enter the following:

$ git submodule update --init --recursive

This initializes the micro-cosmos submodule, which the FSW relies on.

$ git submodule update --remote --merge

This ensures you have the most recent version of the submodule.

Step 5: Run the FSW

With the FSW repo cloned to your local machine, you are now ready to use it. Press the "Open in Visual Studio Code" in GitHub Desktop to open the FSW.

Alternatively, you can open VSCode, Press File then Open Folder... Navigate to the directory where you have the repo cloned (named Artemis-Teensy-Flight-Software). Select it, and press "Select Folder".

VSCode will now load the FSW. PlatformIO will also load.

To build and upload the code to the Teensy, you can use the individual buttons as described earlier in this guide. Alternatively, press the PlatformIO tab on the left navigation menu. The PlatformIO palette will open on the right, with your current environment selected.

Under teensy41 > General, you have multiple options. To build, upload, and monitor the FSW all at once, press the "Upload and Monitor" option.

The Upload and Monitor option in the PlatformIO palette.

The FSW will be compiled, uploaded, and sent to the Teensy. A Serial Monitor will be started in the Terminal window at the bottom.

Step 6: Apply formatting settings

In VSCode, enter the settings menu by clicking File > Preferences > Settings.

From there, type "format" in the search bar, and enable the option labelled "Format on save". This automatically applies uniform C++ formatting to the code you write whenever you save the file.

<img src="https://raw.githubusercontent.com/hsfl/artemis-cosmos-teensy-fsw/main/documentation/step21.png" alt="The "Format on Save" option in VSCode's settings menu."/>

Next, type "ruler" in the search bar, and press the "Edit in settings.json" option under Editor: Rulers. This opens up the settings.json file, and creates an entry called "editor.rulers". Within this entry, type in "80," like so:

{
...
"editor.rulers": [
80,
]
}

Save the file, and you should now see a white vertical line at the 80th column of your editor. This marks an absolute width for your file, upon which the editor will try to automatically create a new line.