lv_led
相关API在lv_led.h
,亮度0~255
样式
/*Parts of LED*/
enum {
LV_LED_PART_MAIN = LV_OBJ_PART_MAIN,
};
typedef uint8_t lv_led_part_t;
例子
void lv_ex_led_1(void)
{
/*Create a LED and switch it OFF*/
static lv_style_t led1_style;
lv_style_init(&led1_style);
lv_style_set_bg_color(&led1_style, LV_STATE_DEFAULT, LV_COLOR_RED);
lv_obj_t * led1 = lv_led_create(lv_scr_act(), NULL);
lv_obj_add_style(led1, LV_LED_PART_MAIN, &led1_style);
lv_obj_align(led1, NULL, LV_ALIGN_CENTER, -80, 0);
lv_led_off(led1);
static lv_style_t led2_style;
lv_style_init(&led2_style);
lv_style_set_bg_color(&led2_style, LV_STATE_DEFAULT, LV_COLOR_GREEN);
/*Copy the previous LED and set a brightness*/
lv_obj_t * led2 = lv_led_create(lv_scr_act(), led1);
lv_obj_add_style(led2, LV_LED_PART_MAIN, &led2_style);
lv_obj_align(led2, NULL, LV_ALIGN_CENTER, 0, 0);
lv_led_set_bright(led2, 190);
static lv_style_t led3_style;
lv_style_init(&led3_style);
lv_style_set_bg_color(&led3_style, LV_STATE_DEFAULT, LV_COLOR_BLUE);
/*Copy the previous LED and switch it ON*/
lv_obj_t * led3 = lv_led_create(lv_scr_act(), led1);
lv_obj_add_style(led3, LV_LED_PART_MAIN, &led3_style);
lv_obj_align(led3, NULL, LV_ALIGN_CENTER, 80, 0);
lv_led_on(led3);
}