LRemote 控制元件 API

此頁面介紹各種控制元件的類別,可供開發者加入 LRemote 所創建的控制畫面之中:

  • LRemoteLabel: 靜態的單行文字標籤

  • LRemoteButton: 帶有文字標籤的簡單按鈕

  • LRemoteCircleButton: 帶有文字標籤的圓形按鈕

  • LRemoteSlider: 可設定初始值與數值範圍的滾動軸

  • LRemoteSwitch: 可切換開與關的按鈕

  • LRemoteJoystick: 類比搖桿

要使用這些類別之前,請確保將它們宣告為全域變數:

#include <LRemote.h>

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

void setup() {
}

接著可以設定控制元件的文字、大小、位置、顏色等等資訊,然後透過 LRemote.addControl() 將其加入控制畫面中。

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();
}

所有類別均可使用的方法

setText()

setColor()

setPos()

setSize()

設定控制元件的文字標籤

Syntax

text: 文字標籤

Returns

none

除了 LRemoteLabel 之外的類別均可使用的方法

isValueChanged(

getValue()

檢查遠端的 LinkIt Remote 手機程式是否已經修改 UI control

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

Syntax

isValueChanged()

Parameters

none

Returns

true 表示 LinkIt Remote 曾經傳送過指令給 LInkIt 7699。

false 表示,在上一次呼叫 LRemote.process() 之後,都沒有來自 LinkIt Remote 手機程式的指令。

僅供 LRemoteSlider 使用的方法

setValueRange()

設定滾動軸允許的最小、最大值

Syntax

min_value: 滾動軸最左端代表的值。最小不能小於 -32767

max_value: 滾動值最右端代表的值。此值不能夠大於 32767

init_value: 滾動軸的初始值

Returns

none

僅供 LRemoteLabel 使用的方法

updateText()

改變文字標籤。即便 LinkIt Remote 程式已經連接了,還是可以用此方法更新文字標籤的內容。

Syntax

new_text: 要更新的文字標籤,長度不能夠超過 15 bytes。

Returns

none

Last updated