To use the Table visualizer functions in our Arduino Library:
- Install the MegunoLink Arduino Library
- Add
#include "MegunoLink.h"
to the top of your Arduino sketch - Create a
Table
variable - Call methods on the
Table
variable
The following methods are implemented by the Table
:
Table()
: constructs a Table variable that will send data to the default channel.Table(ChannelName)
: constructs a Table variable that will send data to the channel supplied.Table(Destination)
: constructs a Table variable that sends data to the default channel using a the serial port supplied.SendData(Name, Value)
set the value of the named row to the value supplied. If the row doesn’t exist, it is created.SendData(Name, Value, Description)
set the value and description of the named row to the values supplied. If the row doesn’t exist, it is created.SendFloatData(Name, Value, DecimalPlaces, Description)
set the value and description of the named row to the value supplied, using the number of decimal places supplied. The row is created if it doesn’t already exist.SetDescription(Name, Description)
set the description of the named row to the value supplied. The row is created if it doesn’t already exist.ClearRow(Name)
removes the named row.ClearAllRows()
clears all rows from the table.ShowCurrentTime(Name)
shows the current time in the row named.
Example
This program periodically sends a few simple messages to a table visualizer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include "MegunoLink.h" void setup() { Serial.begin(9600); } void loop() { Table t; t.SendData("Battery voltage", 3500, "mV"); t.SendData("Charging", "No"); t.SendData("Power connected", "Yes"); delay(400); } |
Methods
Table(Channel — optional, Destination — optional)
Constructs a variable that can be used to send data to and control a MegunoLink table.
Data will be sent to the default table-channel if the optional channel argument is missing. Channels let you use several tables with one serial connection and show different information in each. See sending data to MegunoLink using a visualizer class for more information on channels.
By default, table commands are sent to the Serial
channel destination.
1 2 3 4 |
Table MyTable; Table PowerTable("Power"); Table TemperatureTable(F("Temp")); Table TemperatureTable(F("Temp"), Serial1); |
SendData(Name, Value, Description — optional)
Sends a named value to a table. Optionally include a description. The description can be used for a unit or additional information about the named value.
1 2 |
MyTable.SendData("Battery voltage", 3500, "mV"); MyTable.SendData(F("Set-point"), 15); |
SendFloatData(Name, Value, DecimalPlaces, Description — optional)
Sends a named floating point value to a table. Optionally include a description. The description can be used for a unit or additional information about the named value.
1 2 |
MyTable.SendFloatData("Battery voltage", 3.523, 3, "mV"); MyTable.SendFloatData(F("Set-point"), 1.45,2); |
SetDescription(Name, Description)
Sets the value of the description column for a named row. The description can be used for a unit or additional information about the named value.
1 2 |
MyTable.SetDescription("Battery voltage", "mV"); MyTable.SetDescription(F("Set-point"), "degrees Celsius"); |
ClearRow(Name)
Removes the named row from the table.
1 2 |
MyTable.ClearRow("Battery voltage"); MyTable.ClearRow(F("Battery voltage")); |
ClearAllRows()
Removes all rows from the table.
1 |
MyTable.ClearAllRows(); |
ShowCurrentTime(Name)
Instructs MegunoLink to display the current time on a row with the label Name
. Often used at the start of a sketch so you can see when it starts/ is restarted by a watchdog timer.
1 |
MyTable.ShowCurrentTime(F("Start Time")); |