Many interface panel control properties can be updated by sending commands from your Arduino sketch using
InterfacePanel variables. Changing control properties from your Arduino sketch creates a dynamic user interface. Check out our getting started building an Arduino interface guide for an introduction to building interface panels with MegunoLink.
An interface panel hosts a custom user interface that you build by dragging and dropping controls on a design surface.
The content and appearance of controls are also set in the designer, but many can properties be updated from your Arduino sketch as well, including:
- the number in a numeric up/down control,
- the text in a text box,
- the progress value and text in a progress bar,
- a control’s foreground and background color,
- a control’s visibility.
Updating controls from your Arduino sketch can be used to:
- show device configuration in controls for the user to change and update,
- update a progress bar to show passage of a time-consuming task,
- hide/show picture controls to reflect changes in device status, and many more.
Sending Data & Commands from an Arduino
InterfacePanel variable in our Arduino library to send data and commands to an interface panel from your Arduino sketch. After you install the library:
#include "MegunoLink.h"to the top of your Arduino sketch to include the library.
- Create an
- Call the
InterfacePanel‘s methods to send data and commands to the interface panel.
You can see the methods available for sending data and commands to a control on your interface panel in three places:
Use the name of the control on the interface panel to identify the control. For example,
MyPanel.SetText(F("Status"), "Ready"); will change the text in a text-box control named
You’ll find the control name by selecting the control then searching for
(name) in the property window.
The example code below shows sending data to a gauge named
Voltage, a numeric up/down control named
Counter and hiding a picture box named
void SendData(float Voltage, int Counter, bool ShowStatus)
Multiple Interface Panels and Message Channels
Use message channels and a
MLPUIMessageProcessor component when your project includes more than one interface panel visualizer and you wish to make sure that data and commands send from your Arduino sketch are processed by the right interface panel. This is most important if more than one interface panel contains controls with the same name and you want to send different commands to those controls.
void SendData(float Voltage)
To process commands on a single message channel in your interface panel:
- add a MLPUIMessageProcessor component to your interface panel design,
- set the
ChannelNameproperty of the
MLPUIMessageProcessorcomponent to the name of the channel,
- use the same channel name in your Arduino sketch when creating an