我想找...

搜尋

分享

目錄

86HMI::Slider

[Control widgets]

Object Functions

Slider object. It can control the slider movement and the event change and can be used to adjust the numerical change function element.

Slider-1

Slider Properties.

Slider-2

Identifier:

  • ID: Unique number that identifies the object.
  • Name: User-definable name for the object. It can be used with 86HMI API.

Content:

  • ShowValue: Displayed value position, with options as Disable, Top, Bottom, Left, Right, and Following.
  • Value: Initial value of the object.
  • MaxValue: Maximum value can be positive or negative but must not be less than the minimum value.
  • MinValue: Minimum value can be positive or negative but must not be bigger than the maximum value.
  • PrefixText: Prefix text in front of the value.
  • SuffixText: Suffix text after the value.

Geometry:

  • X: Object X coordinate.
  • Y: Object Y coordinate.
  • Width: Object width. It cannot be adjusted by default.
  • Height: Object height. It cannot be adjusted by default.

Options:

  • Type: Slider type, Horizontal or Vertical.
  • TextColor: Text color can be chosen through the color palette or by directly inputting the color code.
  • TextFont: Choose from 6 default font styles. For font configuration instructions, please refer to Theme Management.
  • ObjColor: Choose from 4 themed colors. For font configuration instructions, please refer to Theme Management.
  • Enable: Select the default state of the object, enable or disable.
  • Order: Object order. It can adjust the object order by up/down, which can be viewed on the Object List.

API Functions

setSliderValue()

描述

Set Slider value.

語法

void setSliderValue(lv_obj_t* id, int value);
void setSliderValue(char* name, int value);

參數

  • [in] id
    Object ID.
  • [in] name
    Object Name.
  • [in] value
    Set Slider value.

Return

範例

#include "myhmi.h"

void setup() {
  Hmi.begin();
  // put your setup code here, to run once:
  Hmi.setSliderValue(p1sl1, 50);
}

void loop() {
  // ..
}

getSliderValue()

描述

Get Slider value.

語法

int getSliderValue(lv_obj_t* id);
int getSliderValue(char* name);

參數

  • [in] id
    Object ID.
  • [in] name
    Object Name.

Return

Slider value.

範例

#include "myhmi.h"

void setup() {
  Serial.begin(115200);
  while (!Serial);
  
  Hmi.begin();
}

void loop() {
  Serial.println(Hmi.getSliderValue(p1sl1));
  delay(1000);
}

sliderDragging()

The following Event Functions are written between BEGIN_HMI_EVENT_PROC 以及 END_HMI_EVENT_PROC.

描述

Determine Slider is dragging.

語法

bool sliderDragging(lv_obj_t* id);
bool sliderDragging(char* name);

參數

  • [in] id
    Object ID.
  • [in] name
    Object Name.

Return

Bool. Determine Slider is dragging.

範例

#include "myhmi.h"

void setup() {
  Hmi.begin();
}

void loop() {
  BEGIN_HMI_EVENT_PROC
  {
    if (Hmi.sliderDragging(p1sl1))
    {
      // do something.
    }
  }
  END_HMI_EVENT_PROC
}

sliderDropped()

The following Event Functions are written between BEGIN_HMI_EVENT_PROC 以及 END_HMI_EVENT_PROC.

描述

Determine Slider is dropped.

語法

bool sliderDropped(lv_obj_t* id);
bool sliderDropped(char* name);

參數

  • [in] id
    Object ID.
  • [in] name
    Object Name.

Return

Bool. Determine Slider is dropped.

範例

#include "myhmi.h"

void setup() {
  Hmi.begin();
}

void loop() {
  BEGIN_HMI_EVENT_PROC
  {
    if (Hmi.sliderDropped(p1sl1))
    {
      // do something.
    }
  }
  END_HMI_EVENT_PROC
}

Please see the 86HMI 編輯器使用手冊 for more instructions on 86HMI widgets and API usage.

返回頂端