1 #include "../../lv_examples.h"
2 #if LV_USE_CHART && LV_DRAW_COMPLEX && LV_BUILD_EXAMPLES
3
add_data(lv_timer_t * t)4 static void add_data(lv_timer_t * t)
5 {
6 lv_obj_t * chart = t->user_data;
7 lv_chart_series_t * ser = lv_chart_get_series_next(chart, NULL);
8
9 lv_chart_set_next_value(chart, ser, lv_rand(10, 90));
10
11 uint16_t p = lv_chart_get_point_count(chart);
12 uint16_t s = lv_chart_get_x_start_point(chart, ser);
13 lv_coord_t * a = lv_chart_get_y_array(chart, ser);
14
15 a[(s + 1) % p] = LV_CHART_POINT_NONE;
16 a[(s + 2) % p] = LV_CHART_POINT_NONE;
17 a[(s + 2) % p] = LV_CHART_POINT_NONE;
18
19 lv_chart_refresh(chart);
20 }
21
22 /**
23 * Circular line chart with gap
24 */
lv_example_chart_9(void)25 void lv_example_chart_9(void)
26 {
27 /*Create a stacked_area_chart.obj*/
28 lv_obj_t * chart = lv_chart_create(lv_scr_act());
29 lv_chart_set_update_mode(chart, LV_CHART_UPDATE_MODE_CIRCULAR);
30 lv_obj_set_size(chart, 200, 150);
31 lv_obj_center(chart);
32
33 lv_chart_set_point_count(chart, 30);
34 lv_chart_series_t * ser = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);
35 /*Prefill with data*/
36 uint32_t i;
37 for(i = 0; i < 30; i++) {
38 lv_chart_set_next_value(chart, ser, lv_rand(10, 90));
39 }
40
41 lv_timer_create(add_data, 300, chart);
42
43 }
44
45 #endif
46