mikroSDK Reference Manual
lv_chart.h
Go to the documentation of this file.
1
6#ifndef LV_CHART_H
7#define LV_CHART_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../../../lvgl.h"
17
18#if LV_USE_CHART != 0
19
20/*********************
21 * DEFINES
22 *********************/
23
25#if LV_USE_LARGE_COORD
26#define LV_CHART_POINT_NONE (INT32_MAX)
27#else
28#define LV_CHART_POINT_NONE (INT16_MAX)
29#endif
30LV_EXPORT_CONST_INT(LV_CHART_POINT_NONE);
31
32/**********************
33 * TYPEDEFS
34 **********************/
35
39enum {
40 LV_CHART_TYPE_NONE,
41 LV_CHART_TYPE_LINE,
42 LV_CHART_TYPE_BAR,
43 LV_CHART_TYPE_SCATTER,
44};
45typedef uint8_t lv_chart_type_t;
46
50enum {
51 LV_CHART_UPDATE_MODE_SHIFT,
52 LV_CHART_UPDATE_MODE_CIRCULAR,
53};
54typedef uint8_t lv_chart_update_mode_t;
55
59enum {
60 LV_CHART_AXIS_PRIMARY_Y = 0x00,
61 LV_CHART_AXIS_SECONDARY_Y = 0x01,
62 LV_CHART_AXIS_PRIMARY_X = 0x02,
63 LV_CHART_AXIS_SECONDARY_X = 0x04,
64 _LV_CHART_AXIS_LAST
65};
66typedef uint8_t lv_chart_axis_t;
67
71typedef struct {
72 lv_coord_t * x_points;
73 lv_coord_t * y_points;
74 lv_color_t color;
75 uint16_t start_point;
76 uint8_t hidden : 1;
77 uint8_t x_ext_buf_assigned : 1;
78 uint8_t y_ext_buf_assigned : 1;
79 uint8_t x_axis_sec : 1;
80 uint8_t y_axis_sec : 1;
81} lv_chart_series_t;
82
83typedef struct {
84 lv_point_t pos;
85 lv_coord_t point_id;
86 lv_color_t color;
87 lv_chart_series_t * ser;
88 lv_dir_t dir;
89 uint8_t pos_set: 1; /*1: pos is set; 0: point_id is set*/
90} lv_chart_cursor_t;
91
92typedef struct {
93 lv_coord_t major_len;
94 lv_coord_t minor_len;
95 lv_coord_t draw_size;
96 uint32_t minor_cnt : 15;
97 uint32_t major_cnt : 15;
98 uint32_t label_en : 1;
99} lv_chart_tick_dsc_t;
100
101
102typedef struct {
103 lv_obj_t obj;
104 lv_ll_t series_ll;
105 lv_ll_t cursor_ll;
106 lv_chart_tick_dsc_t tick[4];
107 lv_coord_t ymin[2];
108 lv_coord_t ymax[2];
109 lv_coord_t xmin[2];
110 lv_coord_t xmax[2];
111 lv_coord_t pressed_point_id;
112 uint16_t hdiv_cnt;
113 uint16_t vdiv_cnt;
114 uint16_t point_cnt;
115 uint16_t zoom_x;
116 uint16_t zoom_y;
117 lv_chart_type_t type : 3;
118 lv_chart_update_mode_t update_mode : 1;
119} lv_chart_t;
120
121extern const lv_obj_class_t lv_chart_class;
122
127typedef enum {
128 LV_CHART_DRAW_PART_DIV_LINE_INIT,
129 LV_CHART_DRAW_PART_DIV_LINE_HOR,
130 LV_CHART_DRAW_PART_DIV_LINE_VER,
131 LV_CHART_DRAW_PART_LINE_AND_POINT,
132 LV_CHART_DRAW_PART_BAR,
133 LV_CHART_DRAW_PART_CURSOR,
134 LV_CHART_DRAW_PART_TICK_LABEL,
135} lv_chart_draw_part_type_t;
136
137/**********************
138 * GLOBAL PROTOTYPES
139 **********************/
140
146lv_obj_t * lv_chart_create(lv_obj_t * parent);
147
153void lv_chart_set_type(lv_obj_t * obj, lv_chart_type_t type);
159void lv_chart_set_point_count(lv_obj_t * obj, uint16_t cnt);
160
168void lv_chart_set_range(lv_obj_t * obj, lv_chart_axis_t axis, lv_coord_t min, lv_coord_t max);
169
175void lv_chart_set_update_mode(lv_obj_t * obj, lv_chart_update_mode_t update_mode);
176
183void lv_chart_set_div_line_count(lv_obj_t * obj, uint8_t hdiv, uint8_t vdiv);
184
190void lv_chart_set_zoom_x(lv_obj_t * obj, uint16_t zoom_x);
191
197void lv_chart_set_zoom_y(lv_obj_t * obj, uint16_t zoom_y);
198
204uint16_t lv_chart_get_zoom_x(const lv_obj_t * obj);
205
211uint16_t lv_chart_get_zoom_y(const lv_obj_t * obj);
212
225void lv_chart_set_axis_tick(lv_obj_t * obj, lv_chart_axis_t axis, lv_coord_t major_len, lv_coord_t minor_len,
226 lv_coord_t major_cnt, lv_coord_t minor_cnt, bool label_en, lv_coord_t draw_size);
227
233lv_chart_type_t lv_chart_get_type(const lv_obj_t * obj);
234
240uint16_t lv_chart_get_point_count(const lv_obj_t * obj);
241
248uint16_t lv_chart_get_x_start_point(const lv_obj_t * obj, lv_chart_series_t * ser);
249
257void lv_chart_get_point_pos_by_id(lv_obj_t * obj, lv_chart_series_t * ser, uint16_t id, lv_point_t * p_out);
258
263void lv_chart_refresh(lv_obj_t * obj);
264
265/*======================
266 * Series
267 *=====================*/
268
276lv_chart_series_t * lv_chart_add_series(lv_obj_t * obj, lv_color_t color, lv_chart_axis_t axis);
277
283void lv_chart_remove_series(lv_obj_t * obj, lv_chart_series_t * series);
284
291void lv_chart_hide_series(lv_obj_t * chart, lv_chart_series_t * series, bool hide);
292
299void lv_chart_set_series_color(lv_obj_t * chart, lv_chart_series_t * series, lv_color_t color);
300
308void lv_chart_set_x_start_point(lv_obj_t * obj, lv_chart_series_t * ser, uint16_t id);
309
316lv_chart_series_t * lv_chart_get_series_next(const lv_obj_t * chart, const lv_chart_series_t * ser);
317
318
319
320/*=====================
321 * Cursor
322 *====================*/
323
331lv_chart_cursor_t * lv_chart_add_cursor(lv_obj_t * obj, lv_color_t color, lv_dir_t dir);
332
339void lv_chart_set_cursor_pos(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_point_t * pos);
340
348void lv_chart_set_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_chart_series_t * ser,
349 uint16_t point_id);
350
357lv_point_t lv_chart_get_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor);
358
359/*=====================
360 * Set/Get value(s)
361 *====================*/
362
369void lv_chart_set_all_value(lv_obj_t * obj, lv_chart_series_t * ser, lv_coord_t value);
370
377void lv_chart_set_next_value(lv_obj_t * obj, lv_chart_series_t * ser, lv_coord_t value);
378
386void lv_chart_set_next_value2(lv_obj_t * obj, lv_chart_series_t * ser, lv_coord_t x_value, lv_coord_t y_value);
387
395void lv_chart_set_value_by_id(lv_obj_t * obj, lv_chart_series_t * ser, uint16_t id, lv_coord_t value);
396
406void lv_chart_set_value_by_id2(lv_obj_t * obj, lv_chart_series_t * ser, uint16_t id, lv_coord_t x_value,
407 lv_coord_t y_value);
408
416void lv_chart_set_ext_y_array(lv_obj_t * obj, lv_chart_series_t * ser, lv_coord_t array[]);
417
425void lv_chart_set_ext_x_array(lv_obj_t * obj, lv_chart_series_t * ser, lv_coord_t array[]);
426
433lv_coord_t * lv_chart_get_y_array(const lv_obj_t * obj, lv_chart_series_t * ser);
434
441lv_coord_t * lv_chart_get_x_array(const lv_obj_t * obj, lv_chart_series_t * ser);
442
448uint32_t lv_chart_get_pressed_point(const lv_obj_t * obj);
449
450/**********************
451 * MACROS
452 **********************/
453
454#endif /*LV_USE_CHART*/
455
456#ifdef __cplusplus
457} /*extern "C"*/
458#endif
459
460#endif /*LV_CHART_H*/
Definition lv_obj_class.h:49
Definition lv_obj.h:174
Definition lv_ll.h:32
Definition lv_area.h:37