创建3个LED示例
static void lv_example_led_1(void)
{
/*Create a LED and switch it OFF*/
lv_obj_t* led1 = lv_led_create(lv_scr_act()); //创建LED对象
lv_obj_align(led1, LV_ALIGN_CENTER, -80, 0); //LV_ALIGN_CENTER方式对齐-80,0
lv_led_off(led1); // LED OFF
/*Copy the previous LED and set a brightness*/
lv_obj_t* led2 = lv_led_create(lv_scr_act()); //创建LED对象
lv_obj_align(led2, LV_ALIGN_CENTER, 0, 0); //LV_ALIGN_CENTER方式对齐0,0
lv_led_set_brightness(led2, 150); //设置LED亮度
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_scr_act()); //创建LED对象
lv_obj_align(led3, LV_ALIGN_CENTER, 80, 0); //LV_ALIGN_CENTER方式对齐80,0
lv_led_on(led3); // LED ON
}
运行效果
- 将第2个LED点亮
lv_led_on(led2);
- 运行效果