[English]

LED(指示灯) (lv_led)

Overview(概述)

显示原文

The LEDs are rectangle-like (or circle) object whose brightness can be adjusted. With lower brightness the colors of the LED become darker.


LED(指示灯)是矩形(或圆形)对象。它的亮度可以调节。亮度降低时,LED的颜色会变暗。

Parts and Styles(部分和样式)

显示原文
  • LV_LED_PART_MAIN uses all the typical background style properties.


  • LV_LED_PART_MAIN 它使用所有典型的背景样式属性。

Usage(用法)

Color(颜色)

显示原文

You can set the color of the LED with lv_led_set_color(led, lv_color_hex(0xff0080)). This will be used as background color, border color, and shadow color.


可以使用函数 lv_led_set_color(led, lv_color_hex(0xff0080)) 设置 LED 的颜色。这将用作背景颜色、边框颜色和阴影颜色。

Brightness(亮度)

显示原文

You can set their brightness with lv_led_set_bright(led, bright). The brightness should be between 0 (darkest) and 255 (lightest).


可以使用函数 lv_led_set_bright(led, bright) 设置它们的亮度。亮度范围:0(最暗)- 255(最亮)。

Toggle(切换)

显示原文

Use lv_led_on(led) and lv_led_off(led) to set the brightness to a predefined ON or OFF value. The lv_led_toggle(led) toggles between the ON and OFF state.


使用函数 lv_led_on(led)lv_led_off(led) 将亮度设置为预定义的ON或OFF值。函数:cpp:expr:lv_led_toggle(led) 就像开关,会让led在ON和OFF状态之间切换。

Events(事件)

显示原文

See the events of the Base object too.

Learn more about Events(事件).


另请参阅 基础对象 的事件。

了解有关 Events(事件) 的更多内容。

Keys(按键)

显示原文

No Keys are processed by the object type.

Learn more about Keys(按键).


对象类型不处理任何 按键

了解有关 Keys(按键) 的更多内容。

Example

[English]

LED with custom style

#include "../../lv_examples.h"
#if LV_USE_LED && LV_BUILD_EXAMPLES

/**
 * Create LED's with different brightness and color
 */
void lv_example_led_1(void)
{
    /*Create a LED and switch it OFF*/
    lv_obj_t * led1  = lv_led_create(lv_screen_active());
    lv_obj_align(led1, LV_ALIGN_CENTER, -80, 0);
    lv_led_off(led1);

    /*Copy the previous LED and set a brightness*/
    lv_obj_t * led2  = lv_led_create(lv_screen_active());
    lv_obj_align(led2, LV_ALIGN_CENTER, 0, 0);
    lv_led_set_brightness(led2, 150);
    lv_led_set_color(led2, lv_palette_main(LV_PALETTE_RED));

    /*Copy the previous LED and switch it ON*/
    lv_obj_t * led3  = lv_led_create(lv_screen_active());
    lv_obj_align(led3, LV_ALIGN_CENTER, 80, 0);
    lv_led_on(led3);
}

#endif

API

lv_led.h

lv_types.h