The Arduino library bundled with MegunoLink provides classes to send data and commands to our visualizers using MegunoLink’s brace protocol. There is one visualizer class for each visualizer, as shown in the table below.

By default, messages are sent through the Arduino’s Serial port, though this can be changed. Data and commands are generally received and processed by all visualizers. Use channels to direct commands and data to specific visualizers.

Visualizer Reference Pages

The methods available for sending data and commands to a visualizer are described in detail, with examples, on the following pages.

Visualizer Class Name Library Reference
Time Plot TimePlot Time Plot Library
XY Plot XYPlot X-Y Plot Library
Interface Panel InterfacePanel Interface panel Library
Message Monitor Message Message Monitor Library
Property Table Table Table Library
Record Table RecordTable Record Table Library
Map Map Map Library
Device Test Result TestReport Test monitor library

Using the Library

To use a visualizer class in your Arduino sketch:

  1. Install the MegunoLink library into your Arduino library folder
  2. #include "MegunoLink.h" — to make the library available to the sketch
  3. Create an instance of the visualizer class. This just means creating a variable such as TimePlot MyPlot;
  4. Call methods on the instance variable when you want to send data. For example: MyPlot.SendData("ADC Value", analogRead(0));

The visualizer class variable can be in the global scope (at the top of your sketch), or in the function right before you use it. Generally it is easier to place it in the global scope, especially if you are using channels.

Destination

Data sent using the visualizer classes is sent to the Arduino’s Serial port by default.

The destination can be changed when you create the visualizer class variable by using the two argument constructor: ClassName(ChannelName, Destination). Here, ClassName is one of the visualizer classes; ChannelName is the name of the channel that data will be sent to (see below) and Destination is the variable where the data will be sent. For example: TimePlot MyPlot("", Serial2); will create a variable to send data to the default plot channel using Serial2 on an Arduino Mega.

Any object based on the Print class can be used as a destination for MegunoLink data. This includes:

Channels

MegunoLink’s channels let you send data to different visualizers in your project. For example, if you had two graphs: one for temperature and one for battery voltage. You can use channels to send the temperature data to one graph and battery voltage to a different graph.

Visualizer classes send data to the default channel by default. To select a different channel, include it when you create the visualizer class variable. This example sends the data to a channel named SetPoints. Refer to Message Channels documentation for information on selecting and managing channels in MegunoLink.

Example

Here is a simple example that generates a cosine function and sends it to a time plot.

Start typing and press Enter to search