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

  setText()

Set the text label of the control

Syntax

setText( text )

Parameters

text: a String representing the text label of the control

Returns

none

  setColor()

Set the color of the control

Syntax

setColor (color)

Parameters

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

  setPos()

Position of the control. The coordinate is the canvas grid determined by LRemote.setGrid() API.

Syntax

setPos( x, y )

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


  setSize()

Size of the control. The unit is a single row/column in the canvas grid determined by LRemote.setGrid() API.

Syntax

setSize( w, h )

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


Methods for All Controls except LRemoteLabel

  isValueChanged()

Check if the LinkIt Remote app has made a change to the UI control

Syntax

isValueChanged()

Parameters

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().


  getValue()

The the current value of the control

Syntax

getValue()

Parameters

none

Returns

Control Type Value
LRemoteSlider Current slider value

LRemoteButton

LRemoteCircleButton

1: Pressed

0: Not pressed

LRemoteSwitch

1: Switch on

0: Switch off

LRemoteJoystick

LRemoteDirection

You can use .x and .y to access the value in X-axis and Y-axis.

The value ranges from -100 (leftmost/bottommost) to 100(topmost/rightmost).


Methods for LRemoteSlider Only

  setValueRange()

Set the range of values for the slider control

Syntax

setValueRange(min_value, max_value, init_value)

Parameters

min_value: The minimum allowed value for the slider. The limit is -32767.

max_value: The maximum value allowed for the slider. The limit is 32767.

init_value: The inital value of the slider.

Returns

none

Methods for LRemoteLabel Only

  updateText()

Change the label text. You can change the text after the user has connected.

Syntax

updateText(new_text)

Parameters

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

Returns

none