Contents

Structure of Graphical Interface Variables



The RemoteXY structure provides access to the graphical interface elements such as buttons, sliders, input fields, etc. The RemoteXY variable structure is automatically generated by the graphical interface editor along with the source code. The structure's fields exactly correspond to the interface elements and contain all variables related to the graphical user interface controls. The variable names are assigned in the graphical interface editor for each control element. For some interface elements, the type of variable can be specified, while for others, the type of the variable is implicitly determined by the element. These names and types are transferred into the fields of the RemoteXY structure.

struct { // input variables uint8_t switch_01; float setTemperature; // output variables float temperature; uint8_t led_01; } RemoteXY;

The RemoteXY structure provides variables in a specific order. Input variables come first, followed by output variables. This order must be maintained for proper data exchange with the mobile application. Do not change the order of fields in the RemoteXY structure, as it will lead to the malfunctioning of the graphical interface.

Attention. Do not modify the RemoteXY structure. Do not add or remove fields from the RemoteXY structure. Also, do not change the order of fields in the structure. Any changes will lead to interface failures.

Interaction with the Graphical Interface

To retrieve data from the graphical interface, you need to read the values of the fields of the RemoteXY structure. To change the displayed data of the interface elements, modify the values of these structure fields.

void loop() { RemoteXY_Handler (); RemoteXY.temperature = getTemp (); if (RemoteXY.switch_01 == 1) { handleMyProcess (); } }

Where is the GUI data actually stored?

The RemoteXY remote control system does not use any servers to store the state of your graphical interface. This means that your data is not sent anywhere else. It is transmitted only between the controller and the mobile application.

The current state of the graphical interface elements is entirely stored in the RemoteXY structure in the controller's memory. Each field of this structure holds the state of one of the interface elements, its position, value, or other data.

When the mobile application connects to the controller, it first reads the data from the RemoteXY structure. Then, the mobile app displays the graphical interface in the state in which the data was stored in the structure fields. When the user interacts with the graphical interface, the new data will be saved back into the structure fields. When the graphical interface is closed, the data about its state remains in the controller within the structure. If the controller is then connected to another phone, the mobile application on the new phone will also read the data from the RemoteXY structure and display the graphical interface exactly as it was before.

Data Transmission Direction

All variables in the structure are divided into input and output. This division depends on the type of control element the variable is associated with. If a control element only displays data transmitted from the controller, the variable associated with it will have the output direction. If a control element can interact with the user and the user can change its state, then data from the graphical interface will be transmitted to the controller, and the variable associated with it will have the input direction. However, input variables can also be transmitted in the reverse direction.

  • input – data is primarily transferred from the graphical interface to the controller, but can also be transmitted in the opposite direction. You can read the values of these variables to get the current state of the control element as the user interacts with it. There are some limitations on writing values to these variables.
  • output – data is always transferred from the controller to the graphical interface. You can freely modify the values of these variables in the controller. When reading the data, you will get the previously written value.

Changing an input variable from the controller

The state of an input variable can be modified from the controller. This allows you to set a control element to the desired state, for example, you can turn on a switch even without user interaction. To the user, it will appear as if the switch toggled automatically. You should also understand that the user may change the state of the control element at the same time in the graphical interface.

To change the state of a control element, simply write the new state value to the associated variable. This will trigger the process of sending the updated information. While the state of that control element is being transmitted through the communication channel to the mobile application, the controller will not receive new data about the state of this element, even if the user changes it from the graphical interface.

This new value should only be written to the variable once, and only when necessary. If you continuously update the input variable in each controller cycle, the user will never be able to change the state of the control element from the graphical interface.

*Note:* Only modify the input variable on the controller side when necessary, and do so once.

Initial State of Control Elements

When the controller starts, is reset, or experiences an unexpected reboot, all variables in the RemoteXY structure are set to their initial state. All variables are assigned a value of 0. When you open the graphical interface after the controller reset, all control elements will also be in their initial state.

If you need to set an initial value for a control element, you can assign this value to the corresponding field in the RemoteXY structure. This should be done in the Setup() function.

For more information on how to initialize control elements.

What Happens When the Controller is Reset

A random or intentional reset of the controller also results in the loss of data in the fields of the RemoteXY structure. If you want to preserve the state of certain control elements, you must ensure the restoration of data in the corresponding structure fields. This needs to be handled manually, for example, by saving the data to non-volatile memory.

For more information on how to save and restore the state of control elements when the controller is reset.