# LRemote Control Classes

These control classes are provided to create UI controls to the canvas created by **LRemote**:

* **LRemoteLabel**: a static text label
* **LRemoteButton**: a rectangular button with a text label
* **LRemoteCircleButton**: a round, circular button with a text label
* **LRemoteSlider**: a slider with adjustable range and initial value
* **LRemoteSwitch**: a on/off switch
* **LRemoteJoystick:** an analog joystick control

To use these classes, declare them in the **global context**:

```
#include <LRemote.h>

LRemoteLabel label;
LRemoteButton button;
LRemoteSlider slider;
LRemoteSwitch switchButton;
LRemoteCircleButton bigButton;

void setup() {
}
```

And adjust the text label, position and size in **setup()** function, and then call **LRemote.addControl()** to add the control to the remote UI canvas.

```
void setup() {
  LRemote.setGrid(3, 5);
  
  // Add a push button
  button.setText("Press Me");
  button.setPos(1, 1);
  button.setSize(2, 1);
  button.setColor(RC_PINK);
  LRemote.addControl(button);
  
  LRemote.begin();
}
```

### Methods for All Controls <a href="#lremotecontrolclasses-methodsforallcontrols" id="lremotecontrolclasses-methodsforallcontrols"></a>

setText()

setColor()

setPos()

setSize()



{% tabs %}
{% tab title="setText()" %}
Set the text label of the control

**Syntax**

text: a String representing the text label of the control

**Returns**

none
{% endtab %}

{% tab title="setColor()" %}
Set the color of the control

**Syntax**

color: The color of the control, must be one of the following enumerations:

* `RC_ORANGE`
* `RC_BLUE`
* `RC_GREEN`
* `RC_PINK`
* `RC_GREY`
* `RC_YELLOW`

Returns

none
{% endtab %}

{% tab title=" setPos()" %}
Position of the control. The coordinate is the canvas grid determined by LRemote.setGrid() API.

**Syntax**

**Parameters**

x: position on the x-axis, ranging from 0 to (canvas grid column - 1)

y: position on the y-axis, ranging from 0 to (canvas grid row - 1)

**Returns**

none
{% endtab %}

{% tab title="setSize()" %}
Size of the control. The unit is a single row/column in the canvas grid determined by LRemote.setGrid() API.

**Syntax**

**Parameters**

w: width of the control. The unit is canvas grid cell

h: height of the control. The unit is canvas grid cell

**Returns**

none
{% endtab %}
{% endtabs %}

### &#x20;Methods for All Controls except LRemoteLabel <a href="#lremotecontrolclasses-methodsforallcontrolsexceptlremotelabel" id="lremotecontrolclasses-methodsforallcontrolsexceptlremotelabel"></a>

&#x20;isValueChanged()

&#x20;getValue()

{% tabs %}
{% tab title="isValueChanged()" %}
Check if the LinkIt Remote app has made a change to the UI control

**Syntax**

none

**Returns**

**true** if the LinkIt Remote has made changes to this control.

**false** if the LinkIt Remote hasn't made any changes to this control since last call to **LRemote.process**().
{% endtab %}

{% tab title="getValue()" %}
The the current value of the control

**Syntax**

none

**Returns**

<table><thead><tr><th width="387.5">Control Type</th><th>Value</th></tr></thead><tbody><tr><td>LRemoteSlider</td><td>Current slider value</td></tr><tr><td><p>LRemoteButton</p><p>LRemoteCircleButton</p></td><td><p>1: Pressed</p><p>0: Not pressed</p></td></tr><tr><td>LRemoteSwitch</td><td><p>1: Switch on</p><p>0: Switch off</p></td></tr><tr><td>LRemoteJoystick</td><td><p>LRemoteDirection</p><p>You can use .x and .y to access the value in X-axis and Y-axis.</p><p>The value ranges from -100 (leftmost/bottommost) to 100(topmost/rightmost).</p></td></tr></tbody></table>


{% endtab %}
{% endtabs %}

### Methods for LRemoteSlider Only <a href="#lremotecontrolclasses-methodsforlremoteslideronly" id="lremotecontrolclasses-methodsforlremoteslideronly"></a>

&#x20;setValueRange()

{% tabs %}
{% tab title=" setValueRange()" %}
Set the range of values for the slider control

**Syntax**

min\_value: The minimum allowed value for the slider. The limit is -32767.

max\_valu&#x65;**:** The maximum value allowed for the slider. The limit is 32767.

init\_value: The inital value of the slider.

**Returns**

none
{% endtab %}
{% endtabs %}

### Methods for LRemoteLabel Only <a href="#lremotecontrolclasses-methodsforlremotelabelonly" id="lremotecontrolclasses-methodsforlremotelabelonly"></a>

&#x20;updateText()

{% tabs %}
{% tab title="updateText()" %}
Change the label text. You can change the text after the user has connected.

**Syntax**

new\_text: The new text to be update to the label. The limitation is 15 bytes.

Returns

none
{% endtab %}
{% endtabs %}
