Your Arduino sketch can request control values and properties from a MegunoLink interface panel by either:

  1. requesting the property value directly, or
  2. creating a message library with messages containing the information you want, and invoking the message in the library.

The first approach requires less work, but you can request only one property at a time. Using a message library takes a little more work to setup, but the response can be fully customized and include several property values.

The first approach is described on this page. See “using the message library to format responses” for the second approach.

It is generally easier to send configuration data from controls on an interface panel when the user clicks a button or a connection is opened.

You can also store configuration in the eeprom so it is available when the device starts.

Use the GetValue method on an InterfacePanel variable in your Arduino sketch to request a property value from a control on an interface panel. MegunoLink will respond with the requested property value. Implement a message handler to decode the response. You can use the command handler from our Arduino library to process the response.

The GetValue method takes two parameters, the:

  1. name of the control with the property to request, and
  2. name of the property to request.

Any properties with read or read/write access listed in the control documentation can be requested. Design-only properties cannot be requested.

The picture below shows the flow of serial messages between your Arduino sketch and the MegunoLink interface panel.

Request interface panel property

Many control property values can be requested from your Arduino sketch.

Example

Use an InterfacePanel variable to request a property value on an interface panel visualizer from your Arduino sketch with the GetValue method.

You’ll also need to handle the response from MegunoLink. Using the CommandHandler from our Arduino library is one solution. Here the Cmd_SetOnTime and Cmd_SetOffTime functions handle the response from the on and off time requests, respectively. Both functions update corresponding variables in the Arduino sketch with values received from MegunoLink.

Our guide to getting started processing serial commands with an Arduino provides a comprehensive introduction to the command handler.

Leave a Comment

Start typing and press Enter to search