Skip to content

Copilot Control Editor

Overview

The Editor window integrates all Copilot Control interfaces into a single interface.

The browser-based Editor allows you to:

  • Define a Custom Message
  • Write and Run JavaScript (to send the Custom Message, and take Custom Actions)
  • Save all data persistently to Jetpack
  • Load previously saved data from Jetpack

There is one Editor window per-slot.

You must be connected to Jetpack in order to use the Editor.

When you connect, the Editor will retrieve the previously-saved Editor state from Jetpack, so you pick up where you left off.

Access

You can use the Editor window right from the Tracker GUI.

The Copilot Control Configuration button is available in the Flight Configuration section.

Flights configured by the GUI are automatically linked-to by the Tracking link on the Tracker GUI.

The Copilot Configuration is stored on the Tracker, but the Dashboard needs to be configured the same way.

This link takes you to a dashboard page pre-filled out with the same Message Definition configuration you save to the tracker.

Layout

The Editor has two major sections

  • Custom Message Definition
  • JavaScript

Custom Message

The top half of the Editor window is the Custom Message Definition section.

The panel on the upper-left is the input box for the Message Definition.

The panel on the upper-right is the real-time analysis of the Message Definition you have authored.

Custom Message Editor

The Custom Message editor lets you define the structure of a message you want to send.

Each row of the input is a Field with:

  • A Unit
  • The range of Values (and resolution) supported

The editor background color tells you about the state of the Message Definition

  • White background - Message Definition is valid and saved
  • Green background - Message Definition is valid and NOT saved
  • Red background - Message Definition is invalid (see Analysis)

Custom Message Analysis

The Analysis of the Message Definition is performed automatically and continuously.

Each change is assessed and the result displayed in this window. Errors, when present, are also displayed in this window.

JavaScript

The bottom half of the Editor window is the JavaScript section.

The panel on the lower-left is the input box for the JavaScript.

The panel on the lower-right is the real-time output of the JavaScript you have authored.

JavaScript Editor

The JavaScript editor lets you write code to send Custom Messages and take Custom Actions.

As described in the Scheduling Details page:

  • Setting fields via the Message API triggers a Custom Message send
  • Custom Actions are everything else JavaScript can do (see API pages)

The editor background color tells you about the state of the JavaScript

  • White background - JavaScript is valid and saved
  • Green background - JavaScript is valid and NOT saved
  • Red background - JavaScript is invalid (see Output)

JavaScript Auto-Completion

The JavaScript editor helps you write the right code correctly.

The editor knows the API that JavaScript has access to.

Because of that, the editor will give you hints about the right way to write your code, such as writing some of the functions for you when you type part of their name.

In this screenshot, the user is accessing the altitude from the GPS, and the option to select between Feet and Meters is presented.

This and many other API functions are provided for you to work with.

JavaScript Output

The JavaScript Output window automatically and continuously tells you about your code.

The JavaScript output window serves multiple purposes.

It will:

  • Continuously monitor the JavaScript you write to check if it is valid JavaScript (syntax)
    • Errors are reported with explanations
  • Report on program run details, such as:
    • Program output (logging)
    • Custom Message final values
    • Run statistics (duration, memory utilization)
    • Errors at runtime with explanations

JavaScript Output - Logging

JavaScript logging is presented after running

The JavaScript program can run the Log() function to print values to the screen, to aid in writing code.

Logged data is made visible to the user through the Output panel.

JavaScript Output - Custom Message Final Values

When a Message Definition is configured, each run of JavaScript automatically prints the field values.

Frequently, JavaScript will be used to fill out Custom Message field values.

During testing, it is useful to see that the final field values match user expectations.

Because of that, the user is shown the values of the message fields that would be transmitted each time the JavaScript is run.

Note - The default value of a message field is its lowValue. Unless this is overwritten, that will be the final value of that field.

JavaScript Run Statistics

When JavaScript is run, resource usage is reported.

Clicking the "Test Run" button (or Alt+R), the JavaScript is run and stats are reported.

Statistics include:

  • Run Duration in milliseconds (ms)
    • Limit of 1,000 ms (1 second)
  • Memory Utilization
    • Expressed as a percentage of available memory

These statistics are presented next to the "Test Run" button.

Buttons

There is a row of buttons that allow you use input.

Both the Custom Message and JavaScript editors have action buttons.

Button Description
Save To Tracker Store in flash memory
Restore Last Saved Show in the editor the last saved version
Show Example Load an example, to use as a starting place (does NOT save to Jetpack automatically)
From File Load a file from your computer hard drive (does NOT save to Jetpack automatically)
To File Save the contents to a file on your computer hard drive
Docs Load the documentation for this editor

The JavaScript Output view supports an additional button.

Button Description
Test Run Run JavaScript and display result

Editor Hotkeys

There are a number of useful hotkeys to make editing more convenient!

Both the Custom Message and JavaScript editors support hotkeys.

The keyboard cursor must be blinking inside the editor for the hotkeys to work.

Hotkey Action
Ctl+S Save
Ctl+/ Comment / Un-Comment
Ctl+Z Undo
Ctl+Y Re-Do
Ctl+Shift+K Delete current line
Alt+Up / Alt+Down Move a line up or down
Alt+Shift+Up / Alt+Shift+Down Duplicate a line up or down

The JavaScript editor supports an additional hotkey:

Hotkey Action
Alt+R Run JavaScript

Testing

Testing your code is the key to success!!

The Editor allows you to:

  • Write code
    • See any syntax errors
  • Run code
    • See any runtime errors
    • See program output
    • See final Custom Message values

It is a good and common process to repeatedly write code, run it, and evaluate the result.

Keep revising your code until it does what you want it to do!

Testing GPS

The GPS API allows your code to use data from the latest GPS lock to fill out fields of your Custom Message, or for any other purpose.

During testing, a real GPS lock is not required.

Instead, real pre-snapshotted GPS data is provided to your code through the GPS API.

The values of the real pre-snapshotted data are noted in the GPS API documentation.

This allows you to write code that works with real data to ensure you're processing as you expect for when Jetpack is operating in Flight Mode.

Testing Other Core API

All Core API functions beyond GPS work exactly the same in testing as in flight.

Making use of I2C, Pin, ADC, etc, all control the tracker immediately and directly in exactly the same way as it will during flight.

Testing Sensors

All Sensor API functions work exactly the same in testing as in flight.

The sensor API controls sensors immediately and directly in exactly the same way as it will during flight.

Saving

Save often!

Saving is fast and easy (especially using hotkeys - Ctl+S).

Saving to Jetpack frequently is a great idea.

Once your program is working the way you want, consider saving that Message Definition and JavaScript to your computer hard drive, or even bulk saving all slot configuration simultaneously.

All Slots Configuration

Every slot has its own Editor.

They are grouped together in a single dialog box.

The dialog is revealed when you click the Copilot Control Configuration button on the Tracker GUI.

The group of Editors, by slot (collapsed view):

The group of Editors, by slot, first slot opened (click slot name to show/hide):

Buttons

There is a bulk import/export function for all slots

Button Description
From File (Bulk) Load a single file from your computer hard drive with all slot configurations
(DOES save to Jetpack automatically)
To File (Bulk) Save the contents of all slot configurations to a single file on your computer hard drive

How it Works

Saving

Jetpack saves the Message Definition and JavaScript in persistent flash memory.

Each time you save, Jetpack updates its persistent version of the file backing the editor.

Jetpack makes use of a flash wear-leveling algorithm to ensure you can save as many times as you want (and then some).

During flight, Jetpack reads from flash, making sure the data is available even after loss of power.

Checking

Jetpack reviews your code every time you change it.

Jetpack hosts a JavaScript engine that can both parse and run JavaScript.

Every time you change a single character of your JavaScript program, Jetpack will look over your whole program and make sure it is valid JavaScript.

The result of each check is sent back to the editor to give you feedback on what works and what doesn't (and why).

Running

Jetpack runs your code.

When you run JavaScript in the editor, Jetpack acts as though it is running it during flight.

Jetpack aims to ensure that when your code works during testing, it works during flight.