I want to find...

Search

Shares

Table of Content

86HMI::ToggleButton

[Control widgets]

Object Functions

Toggle button object. Each of the two states has a corresponding state and event.

toggleButton-1

ToggleButton Properties.

toggleButton-2

Identifier:

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

Content:

  • PrefixSymbol: Select the built-in button icon as an embellishment icon and scroll the mouse to drop down the options.
  • Text (Checked): ToggleButton object’s text in the Checked state.
  • Text (Unchecked): ToggleButton object’s text in the Unchecked state.
  • Checked: Default ToggleButton state.

Geometry:

  • X: Object X coordinate.
  • Y: Object Y coordinate.
  • Width: Object width.
  • Height: Object height.

Options:

  • 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.

ToggleButton Events.

toggleButton-3

ToggleButton object event conditions: Checked, Unchecked.

toggleButton-4

The following instructions can be added: Page Change, Set Language, Play Sound, and Custom Instruction.
For instructions on how to use the commands for an event, see Events Instruction Functions.

toggleButton-5

Note:
Custom Instruction allows the user to edit the events to be executed by the object or page using the editing code. This option is a professional advanced option, and the user should be familiar with the 86Duino program before editing.


API Functions

setToggleButtonState()

Description

Set ToggleButton state.

Syntax

void setToggleButtonState(lv_obj_t* id, bool checked);
void setToggleButtonState(char* name, bool checked);

Parameters

  • [in] id
    Object ID.
  • [in] name
    Object Name.
  • [in] checked
    Bool, ToggleButton state, Checked or Unchecked.

Return

None.

Example

#include "myhmi.h"

void setup() {
  Hmi.begin();
  Hmi.setToggleButtonState(p1tb1, true);
}

void loop() {
  // ...
}

getToggleButtonState()

Description

Get ToggleButton state.

Syntax

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

Parameters

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

Return

ToggleButton state.

Example

#include "myhmi.h"

void setup() {  
  Hmi.begin();
  
  if (Hmi.getToggleButtonState(p1tb1))
  {
    Hmi.setToggleButtonState(p1tb1, false);
  }
}

void loop() {
  // ...
}

toggleButtonChecked()

The following Event Functions are written between BEGIN_HMI_EVENT_PROC and END_HMI_EVENT_PROC.

Description

Determine ToggleButton is checked.

Syntax

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

Parameters

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

Return

Bool. Determine ToggleButton is checked.

Example

#include "myhmi.h"

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

void loop() {
  BEGIN_HMI_EVENT_PROC
  {
    if (Hmi.toggleButtonChecked(p1tb1))
    {
      // do something.
    }
  }
  END_HMI_EVENT_PROC
}

toggleButtonUnchecked()

The following Event Functions are written between BEGIN_HMI_EVENT_PROC and END_HMI_EVENT_PROC.

Description

Determine ToggleButton is unchecked.

Syntax

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

Parameters

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

Return

Bool. Determine ToggleButton is unchecked.

Example

#include "myhmi.h"

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

void loop() {
  BEGIN_HMI_EVENT_PROC
  {
    if (Hmi.toggleButtonUnchecked(p1tb1))
    {
      // do something.
    }
  }
  END_HMI_EVENT_PROC
}

Please see the 86HMI Editor User Manual for more instructions on 86HMI widgets and API usage.

Scroll to Top