您当前的位置: 首页 >  ar

LVGL 8.2 pie chart

发布时间:2022-07-10 17:29:30 ,浏览量:7

Create a pie chart
static void lv_example_meter_4(void) { lv_obj_t* meter = lv_meter_create(lv_scr_act()); /*Remove the background and the circle from the middle*/ lv_obj_remove_style(meter, NULL, LV_PART_MAIN); // 移除LV_PART_MAIN特性 lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR); // 移除LV_PART_INDICATOR特性 lv_obj_set_size(meter, 200, 200); // 设置大小 lv_obj_center(meter); // 居中显示 /*Add a scale first with no ticks.*/ lv_meter_scale_t* scale = lv_meter_add_scale(meter); lv_meter_set_scale_ticks(meter, scale, 0, 0, 0, lv_color_black()); //无刻度线 lv_meter_set_scale_range(meter, scale, 0, 100, 360, 0); // 0~100%,角度范围360,3点钟偏移角度0 /*Add a three arc indicator*/ lv_coord_t indic_w = 100; lv_meter_indicator_t* indic1 = lv_meter_add_arc(meter, scale, indic_w, lv_palette_main(LV_PALETTE_ORANGE), 0); // orange颜色饼块 lv_meter_set_indicator_start_value(meter, indic1, 0); lv_meter_set_indicator_end_value(meter, indic1, 40); lv_meter_indicator_t* indic2 = lv_meter_add_arc(meter, scale, indic_w, lv_palette_main(LV_PALETTE_YELLOW), 0); // yellow颜色饼块 lv_meter_set_indicator_start_value(meter, indic2, 40); /*Start from the previous*/ lv_meter_set_indicator_end_value(meter, indic2, 80); lv_meter_indicator_t* indic3 = lv_meter_add_arc(meter, scale, indic_w, lv_palette_main(LV_PALETTE_DEEP_ORANGE), 0); // deep orange颜色饼块 lv_meter_set_indicator_start_value(meter, indic3, 80); /*Start from the previous*/ lv_meter_set_indicator_end_value(meter, indic3, 100); } 
运行效果图

在这里插入图片描述

关注
打赏
1688896170
查看更多评论

暂无认证

  • 7浏览

    0关注

    115984博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0563s