The InterfacePanel
class in the MegunoLink Pro Arduino Library provides a convenient set of methods for sending messages to MegunoLink’s Interface Panel to re-configure and request the property values of the objects shown. This library lets you send data and commands to controls on an interface panel to change property values.
Controls are identified by their Name
property.
Methods
InterfacePanel(ChannelName — optional, Destination — optional ) (constructor)
SetText(ControlName, Value)
SetText(ControlName, Value, DecimalPlaces)
SetProgress(ControlName, Value)
SetNumber(ControlName, Value)
SetNumber(ControlName, Value, DecimalPlaces)
SetListIndex(ControlName, Index)
SetListValue(ControlName, Value)
SetListName(ControlName, Name)
SetCheck(ControlName, Checked — optional)
ClearCheck(ControlName)
CallCommand(CommandName)
GetValue(ControlName, PropertyName)
HideControl(ControlName)
ShowControl(ControlName, Visible — optional)
EnableControl(ControlName, Enable — optional)
DisableControl(ControlName)
SetForeColor(ControlName,Color)
SetBackColor(ControlName,Color)
SetReadOnly(ControlName, True/False)
SetMinimum(ControlName, Value)
SetMaximum(ControlName, Value)
SetGaugeLabel(ControlName, LabelIndex, LabelText)
ClearListOptions(ControlName)
SetListOption(ControlName, Value, DisplayName)
StartProgram(ControlName, [ExtraArgument])
SetTab(ControlName, TabNumber)
SetIndicator(ControlName, On)
SetIndicatorColor(ControlName, Color)
Detailed Descriptions
InterfacePanel(ChannelName — optional, Destination — optional )
Constructs an InterfacePanel variable, with an optional ChannelName and destination.
1 2 3 4 5 6 |
#include "MegunoLink.h" InterfacePanel Panel; InterfacePanel MainPanel("Main"); InterfacePanel DiagnosticPanel(F("Diagnostics"); InterfacePanel MainPanel(F("Main"), Serial1); |
SetText(ControlName, Value)
Sets the text displayed in a control. Applies to: text box, dynamic label, button and progress bar.
1 2 3 |
Panel.SetText("MyTextBox", "New value"); Panel.SetText(F("MyTextBox"), "New value"); Panel.SetText(F("MyTextBox"), F("New value")); |
SetText(ControlName, Value, DecimalPlaces)
Sets the text displayed in a control. Applies to: text box, dynamic label, button and progress bar.
1 |
Panel.SetText(F("MyTextBox"), 5.6743256, 4); //4 decimal places |
SetProgress(ControlName, Value)
Sets the current value displayed by a progress bar control.
1 |
Panel.SetProgress("MyProgressBar", 50); |
SetNumber(ControlName, Value)
Sets the number displayed in a numeric up/down, track-bar, gauge or other compatible numeric control.
1 |
Panel.SetNumber("MyNumber", 20); |
SetNumber(ControlName, Value, DecimalPlaces)
Sets the number displayed in a numeric up/down, track-bar, gauge or other compatible numeric control.
1 |
Panel.SetNumber("MyNumber", 20.6574, 2); //2 decimal places |
SetListIndex(ControlName, Index)
Sets the index of the item selected in a value-list control. The first item in the list box is 0.
1 |
Panel.SetListIndex("MyListBox", 2); |
SetListValue(ControlName, Value)
Selects the item with the given value in a single-selection, value-list control. In a multi-selection value-list control, selects any items where a bitwise and between the item value and the new value is equal to the item value. This allows a list box to represent bit-flag variables.
1 |
Panel.SetListValue("MyListBox", 3); |
SetListName(ControlName, Name)
Selects the item with the given name in a single-selection, value-list control.
1 |
Panel.SetListValue("MyListBox", "Trigger"); |
SetCheck(ControlName, CheckState — optional)
Sets the check-state of a check box or radio button control. If the optional CheckState
parameter is missing, the control is checked. Otherwise, if CheckState
is:
true
(radio button or check-box) orInterfacePanel::Checked
(check-box only) then the control is checked;false
(radio button or check-box) orInterfacePanel::Unchecked
(check-box only) then the control is unchecked;InterfacePanel::Indeterminate
then the control is in the indeterminate state (check-box only).
1 2 3 4 |
Panel.SetCheck("MyCheckBox", true); Panel.SetCheck("MyCheckBox"); Panel.SetCheck("MyCheckBox", false); Panel.SetCheck(F("MyCheckBox"), InterfacePanel::Indeterminate); |
ClearCheck(ControlName)
Clears the check mark from a check box or radio button control.
1 |
Panel.ClearCheck("MyCheckBox"); |
CallCommand(CommandName)
Invokes a named command from the message library attached to the message processor. Typically the command returns a serial message.
1 |
Panel.CallCommand("GetTime"); |
GetValue(ControlName, PropertyName)
Returns the value of a serial message property for the named control. The format used for the message return is described in the Message Processor Reference.
1 |
Panel.GetValue(F("MyNumber"), F("Value")); |
ShowControl(ControlName, Visible — optional)
Makes a previously hidden control visible when Visible is missing or true. Visible controls are hidden when Visible is false. Applies to all controls supporting common control properties.
1 2 3 |
Panel.ShowControl("RedPictureBox"); // show control Panel.ShowControl("RedPictureBox", true); // show control Panel.ShowControl("RedPictureBox", false); // hide control |
HideControl(ControlName)
Hides a control so it is no longer visible. Applies to all controls supporting common control properties.
1 |
Panel.HideControl("RedPictureBox"); |
EnableControl(ControlName, Enable — optional)
Enables a control so it is accessible to the user when Enable
is missing or true
; disables the control when Enable
is false
. Applies to all controls supporting common control properties.
1 2 3 |
Panel.EnableControl("RedPictureBox"); // enable control Panel.EnableControl("RedPictureBox", true); // enable control Panel.EnableControl("RedPictureBox", false); // disable control |
DisableControl(ControlName)
Disables a control so it is grayed out and not accessible to the user. Applies to all controls supporting common control properties.
1 |
Panel.DisableControl("RedPictureBox"); |
SetForeColor(ControlName,Color)
Controls the foreground color of the interface element. Color may be specified by name or as a six digit hexadecimal value. Hexadecimal values are specified as RRGGBB
where RR
, GG
and BB
are each two digit hexadecimal values specifying the strengths of the red, green and blue components of the color respectively. Applies to all controls supporting common control properties.
1 2 |
Panel.SetForeColor("MyPictureBox", "Blue"); Panel.SetForeColor("MyPictureBox", "FF0000"); // sets color to red. |
SetBackColor(ControlName,Color)
Controls the background color of the interface element. Color may be specified by name or as a six digit hexadecimal value. Hexadecimal values are specified as RRGGBB
where RR
, GG
and BB
are each two digit hexadecimal values specifying the strengths of the red, green and blue components of the color respectively. Applies to all controls supporting common control properties.
1 2 |
Panel.SetBackColor("MyPictureBox", "FF0000"); // red https://docs.microsoft.com/en-us/dotnet/api/system.drawing.color?view=netframework-4.7.2Panel.SetBackColor("MyPictureBox", "Purple"); |
SetReadOnly(ControlName,True/False)
Set the read-only property of text box and numeric up/down controls.
1 |
Panel.SetReadOnly("MyTextBox",true); |
SetMinimum(ControlName,Value)
Set the minimum value allowed for numeric up/down, track-bar and progress bar controls.
1 |
Panel.SetMinimum("MyNumber",20); |
SetMaximum(ControlName,Value)
Set the maximum value allowed for numeric up/down, track-bar and progress bar controls.
1 |
Panel.SetMaximum("MyNumber",100); |
SetGaugeLabel(ControlName, LabelIndex, LabelText)
Allows you to adjust the text for one of the labels displayed on a gauge control. In the example below we are setting the 0th label in the collection for the panel called MyGauge to display the text “Max Speed Reached”.
1 |
Panel.SetGaugeLabel("MyGauge",0,"Max Speed Reached"); |
ClearListOptions(ControlName)
Removes all the options in a value list or value combo box control.
1 2 |
Panel.ClearListOptions("MyList"); Panel.ClearListOptions("MyCombo"); |
SetListOption(ControlName, Value, DisplayName)
Sets the display name associated with a value in a value list or value combo box control. A new item is added to the control if there isn’t an item with a matching value.
1 2 |
Panel.SetListOption("MyList", 6, "Millimeters"); Panel.ClearListOptions("MyCombo", 0, "Horizontal"); |
StartProgram(ComponentName), StartProgram(ComponentName, ExtraArgument)
Runs the program configured for a Start Program component. Optionally pass an additional argument to the program with the ExtraArgument
variable.
1 2 |
Panel.StartProgram("PrintLabel", "S-AB-1234"); Panel.StartProgram("FlashDevice"); |
SetIndicatorColor(ComponentName, Color)
Sets the color displayed when the indicator is on. Color may be specified by name or as a six digit hexadecimal value. Hexadecimal values are specified as RRGGBB
where RR
, GG
and BB
are each two digit hexadecimal values specifying the strengths of the red, green and blue components of the color respectively.
1 2 3 |
Panel.SetIndicatorColor("MyIndicatorControl", "Red"); Panel.SetIndicatorColor(F("MyIndicatorControl"), F("00ff00")); // green Panel.SetIndicatorColor("MyIndicatorControl", "0000ff")); // blue |