2021-02-08 09:53:03 +01:00
|
|
|
#include "../../../lvgl.h"
|
2021-02-14 14:56:34 +01:00
|
|
|
#if LV_USE_METER && LV_BUILD_EXAMPLES
|
2021-02-08 09:53:03 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a pie chart
|
|
|
|
*/
|
|
|
|
void lv_example_meter_4(void)
|
|
|
|
{
|
2021-03-25 13:36:50 +01:00
|
|
|
lv_obj_t * meter = lv_meter_create(lv_scr_act());
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_center(meter);
|
2021-02-08 09:53:03 +01:00
|
|
|
|
|
|
|
/*Remove the background and the circle from the middle*/
|
2021-03-31 19:57:14 +02:00
|
|
|
lv_obj_remove_style(meter, NULL, LV_PART_MAIN);
|
|
|
|
lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR);
|
2021-02-08 09:53:03 +01:00
|
|
|
|
|
|
|
/*Add a scale first with no ticks.*/
|
|
|
|
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
|
2021-02-23 15:03:06 +01:00
|
|
|
lv_meter_set_scale_ticks(meter, scale, 0, 0, 0, lv_color_black());
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_meter_set_scale_range(meter, scale, 0, 100, 360, 0);
|
|
|
|
|
2021-03-15 02:03:27 +08:00
|
|
|
/*Add a three arc indicator*/
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_coord_t indic_w = lv_obj_get_width(meter) / 2;
|
2021-02-23 15:03:06 +01:00
|
|
|
lv_meter_indicator_t * indic1 = lv_meter_add_arc(meter, scale, indic_w, lv_color_orange(), 0);
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_meter_set_indicator_start_value(meter, indic1, 0);
|
|
|
|
lv_meter_set_indicator_end_value(meter, indic1, 40);
|
|
|
|
|
2021-02-24 05:10:48 +01:00
|
|
|
lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, scale, indic_w, lv_color_yellow(), 0);
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_meter_set_indicator_start_value(meter, indic2, 40); /*Start from the previous*/
|
|
|
|
lv_meter_set_indicator_end_value(meter, indic2, 80);
|
|
|
|
|
2021-02-24 05:10:48 +01:00
|
|
|
lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, scale, indic_w, lv_color_deep_orange(), 0);
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_meter_set_indicator_start_value(meter, indic3, 80); /*Start from the previous*/
|
|
|
|
lv_meter_set_indicator_end_value(meter, indic3, 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|