2021-09-13 11:11:10 +01:00
|
|
|
#include "../../lv_examples.h"
|
2023-10-16 23:43:27 +02:00
|
|
|
#if LV_USE_CHART && LV_DRAW_SW_COMPLEX && LV_BUILD_EXAMPLES
|
2021-09-13 11:11:10 +01:00
|
|
|
|
|
|
|
|
2023-10-16 23:43:27 +02:00
|
|
|
static void add_data(lv_timer_t * t)
|
2021-09-13 11:11:10 +01:00
|
|
|
{
|
2023-10-16 23:43:27 +02:00
|
|
|
lv_obj_t * chart = t->user_data;
|
|
|
|
lv_chart_series_t * ser = lv_chart_get_series_next(chart, NULL);
|
2021-09-13 11:11:10 +01:00
|
|
|
|
2023-10-16 23:43:27 +02:00
|
|
|
lv_chart_set_next_value(chart, ser, lv_rand(10, 90));
|
2021-09-13 11:11:10 +01:00
|
|
|
|
2023-10-16 23:43:27 +02:00
|
|
|
uint16_t p = lv_chart_get_point_count(chart);
|
|
|
|
uint16_t s = lv_chart_get_x_start_point(chart, ser);
|
|
|
|
lv_coord_t * a = lv_chart_get_y_array(chart, ser);
|
2021-09-13 11:11:10 +01:00
|
|
|
|
2023-10-16 23:43:27 +02:00
|
|
|
a[(s + 1) % p] = LV_CHART_POINT_NONE;
|
|
|
|
a[(s + 2) % p] = LV_CHART_POINT_NONE;
|
|
|
|
a[(s + 2) % p] = LV_CHART_POINT_NONE;
|
2021-09-13 11:11:10 +01:00
|
|
|
|
2023-10-16 23:43:27 +02:00
|
|
|
lv_chart_refresh(chart);
|
2021-09-13 11:11:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-10-16 23:43:27 +02:00
|
|
|
* Circular line chart with gap
|
2021-09-13 11:11:10 +01:00
|
|
|
*/
|
|
|
|
void lv_example_chart_8(void)
|
|
|
|
{
|
|
|
|
/*Create a stacked_area_chart.obj*/
|
2023-10-16 23:43:27 +02:00
|
|
|
lv_obj_t * chart = lv_chart_create(lv_screen_active());
|
|
|
|
lv_chart_set_update_mode(chart, LV_CHART_UPDATE_MODE_CIRCULAR);
|
|
|
|
lv_obj_set_style_size(chart, 0, 0, LV_PART_INDICATOR);
|
|
|
|
lv_obj_set_size(chart, 280, 150);
|
|
|
|
lv_obj_center(chart);
|
|
|
|
|
|
|
|
lv_chart_set_point_count(chart, 80);
|
|
|
|
lv_chart_series_t * ser = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);
|
|
|
|
/*Prefill with data*/
|
|
|
|
uint32_t i;
|
|
|
|
for(i = 0; i < 80; i++) {
|
|
|
|
lv_chart_set_next_value(chart, ser, lv_rand(10, 90));
|
2021-09-13 11:11:10 +01:00
|
|
|
}
|
|
|
|
|
2023-10-16 23:43:27 +02:00
|
|
|
lv_timer_create(add_data, 300, chart);
|
|
|
|
|
2021-09-13 11:11:10 +01:00
|
|
|
}
|
|
|
|
|
2021-10-25 12:44:44 -04:00
|
|
|
#endif
|