LRemote

LRemote is a singleton object that allows user to design a remote control UI. It's main purpose is to hold the UI control settings and convert them to LBLE GATT attributes. 

LRemote initializes and uses LBLE library implicitly. Therefore, we suggest preventing mixing calls to LRemote and LBLE library.

To use it, 

  • #include <LRemote.h> in your LinkIt 7697 Arduino sketch.
  • Call setName(), setGrid() and setOrientation() to configure the device and remote UI canvas grid first.
  • Add control objects with addControls() API.
  • Call begin() to initiate the device and start advertisement to LinkIt Remote mobile app.
  • Use connected() to check if the mobile app has connected.
  • Call process() periodically to update control status and value.

Methods

 setName()

Set the device name. Note that BLE advertisement have length limitation, so this name may be truncated when being advertised.

Syntax

LRemote.setName( name )

Parameters

name: a String representing the name of the device.

Returns

none

 setGrid()

Set the canvas grid as a referencing coordinate for control position and size.

Syntax

LRemote.setGrid( column, row )

Parameters

column: number of columns in the grid

row: number of rows in the grid

Returns

none

 setOrientation()

Set desired UI orientation for the remote UI.

Syntax

LRemote.setOrientation( orientation )

Parameters

orientation: can be RC_PORTRAIT or RC_LANDSCAPE. The default value for orientation is portrait.

Returns

none

 addControl()

Add a UI control element to the canvas

Syntax

LRemote.addControl( control )

Parameters

control: an instance of the UI control classes, including:

  • LRemoteButton
  • LRemoteSlider
  • LRemoteLabel
  • LRemoteSwitch
  • LRemoteCircleButton

Note that the control instance must have the same life span as LRemote - so these instances should be defined in global scope


Don't define UI control objects such as LRemoteButton in the local scope, e.g. inside the function body of setup() and loop()


Returns

none

 begin()

Initialize the underlying BLE device and start advertisement. This API implicitly calls LBLE.begin()

Syntax

LRemote.begin()

Parameters

none

Returns

none


 connected()
Check if the LinkIt Remote app has connected.

Syntax

LRemote.connected()

Parameters

none

Returns

true if the LinkIt Remote app has connected to this device. false otherwise.


 process()

Processes incoming commands from the LinkIt Remote mobile app. Call this API periodically in the loop() function.

 Syntax

LRemote.process()

Parameters

none

Returns

none

Failing to call this API will cause incorrect state and value of the UI controls.