LittlevGL  3.20.00.19
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
10 extern "C" {
11 #endif
12 
13 /*********************
14  * INCLUDES
15  *********************/
16 #ifdef LV_CONF_INCLUDE_SIMPLE
17 #include "lv_conf.h"
18 #else
19 #include "../../../lv_conf.h"
20 #endif
21 
22 #if LV_USE_CHART != 0
23 
24 #include "../lv_core/lv_obj.h"
25 #include "lv_line.h"
26 
27 /*********************
28  * DEFINES
29  *********************/
30 
32 #define LV_CHART_POINT_DEF (LV_COORD_MIN)
33 
35 #define LV_CHART_TICK_LENGTH_AUTO 255
36 
37 /**********************
38  * TYPEDEFS
39  **********************/
40 
42 enum {
43  LV_CHART_TYPE_NONE = 0x00,
44  LV_CHART_TYPE_LINE = 0x01,
45  LV_CHART_TYPE_COLUMN = 0x02,
46  LV_CHART_TYPE_POINT = 0x04,
47  LV_CHART_TYPE_VERTICAL_LINE = 0x08,
48  LV_CHART_TYPE_AREA = 0x10,
49 };
50 typedef uint8_t lv_chart_type_t;
51 
53 enum {
54  LV_CHART_UPDATE_MODE_SHIFT,
55  LV_CHART_UPDATE_MODE_CIRCULAR,
56 };
57 typedef uint8_t lv_chart_update_mode_t;
58 
59 typedef struct
60 {
61  lv_coord_t * points;
62  lv_color_t color;
63  uint16_t start_point;
64 } lv_chart_series_t;
65 
67 enum {
68  LV_CHART_AXIS_SKIP_LAST_TICK = 0x00,
69  LV_CHART_AXIS_DRAW_LAST_TICK = 0x01
70 };
71 typedef uint8_t lv_chart_axis_options_t;
72 
73 typedef struct
74 {
75  const char * list_of_values;
76  lv_chart_axis_options_t options;
77  uint8_t num_tick_marks;
78  uint8_t major_tick_len;
79  uint8_t minor_tick_len;
80 } lv_chart_axis_cfg_t;
81 
82 /*Data of chart */
83 typedef struct
84 {
85  /*No inherited ext*/ /*Ext. of ancestor*/
86  /*New data for this type */
87  lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_dl_t)*/
88  lv_coord_t ymin; /*y min value (used to scale the data)*/
89  lv_coord_t ymax; /*y max value (used to scale the data)*/
90  uint8_t hdiv_cnt; /*Number of horizontal division lines*/
91  uint8_t vdiv_cnt; /*Number of vertical division lines*/
92  uint16_t point_cnt; /*Point number in a data line*/
93  lv_chart_type_t type; /*Line, column or point chart (from 'lv_chart_type_t')*/
94  lv_chart_axis_cfg_t y_axis;
95  lv_chart_axis_cfg_t x_axis;
96  uint16_t margin;
97  uint8_t update_mode : 1;
98  struct
99  {
100  lv_coord_t width; /*Line width or point radius*/
101  uint8_t num; /*Number of data lines in dl_ll*/
102  lv_opa_t opa; /*Opacity of data lines*/
103  lv_opa_t dark; /*Dark level of the point/column bottoms*/
104  } series;
105 } lv_chart_ext_t;
106 
107 enum {
108  LV_CHART_STYLE_MAIN,
109 };
110 typedef uint8_t lv_chart_style_t;
111 
112 /**********************
113  * GLOBAL PROTOTYPES
114  **********************/
115 
123 lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy);
124 
125 /*======================
126  * Add/remove functions
127  *=====================*/
128 
135 lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color);
136 
142 void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie);
143 
144 /*=====================
145  * Setter functions
146  *====================*/
147 
154 void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv);
155 
162 void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax);
163 
169 void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type);
170 
176 void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt);
177 
183 void lv_chart_set_series_opa(lv_obj_t * chart, lv_opa_t opa);
184 
190 void lv_chart_set_series_width(lv_obj_t * chart, lv_coord_t width);
191 
197 void lv_chart_set_series_darking(lv_obj_t * chart, lv_opa_t dark_eff);
198 
205 void lv_chart_init_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y);
206 
213 void lv_chart_set_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y_array[]);
214 
221 void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y);
222 
228 void lv_chart_set_update_mode(lv_obj_t * chart, lv_chart_update_mode_t update_mode);
229 
236 static inline void lv_chart_set_style(lv_obj_t * chart, lv_chart_style_t type, const lv_style_t * style)
237 {
238  (void)type; /*Unused*/
239  lv_obj_set_style(chart, style);
240 }
241 
250 void lv_chart_set_x_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len);
251 
260 void lv_chart_set_y_tick_length(lv_obj_t * chart, uint8_t major_tick_len, uint8_t minor_tick_len);
261 
270 void lv_chart_set_x_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
271  lv_chart_axis_options_t options);
272 
281 void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
282  lv_chart_axis_options_t options);
283 
289 void lv_chart_set_margin(lv_obj_t * chart, uint16_t margin);
290 
291 /*=====================
292  * Getter functions
293  *====================*/
294 
300 lv_chart_type_t lv_chart_get_type(const lv_obj_t * chart);
301 
307 uint16_t lv_chart_get_point_cnt(const lv_obj_t * chart);
308 
314 lv_opa_t lv_chart_get_series_opa(const lv_obj_t * chart);
315 
321 lv_coord_t lv_chart_get_series_width(const lv_obj_t * chart);
322 
328 lv_opa_t lv_chart_get_series_darking(const lv_obj_t * chart);
329 
336 static inline const lv_style_t * lv_chart_get_style(const lv_obj_t * chart, lv_chart_style_t type)
337 {
338  (void)type; /*Unused*/
339  return lv_obj_get_style(chart);
340 }
341 
347 uint16_t lv_chart_get_margin(lv_obj_t * chart);
348 
349 /*=====================
350  * Other functions
351  *====================*/
352 
357 void lv_chart_refresh(lv_obj_t * chart);
358 
359 /**********************
360  * MACROS
361  **********************/
362 
363 #endif /*LV_USE_CHART*/
364 
365 #ifdef __cplusplus
366 } /* extern "C" */
367 #endif
368 
369 #endif /*LV_CHART_H*/
Definition: lv_obj.h:184
const lv_style_t * lv_obj_get_style(const lv_obj_t *obj)
struct _lv_obj_t * par
Definition: lv_obj.h:186
uint8_t lv_opa_t
Definition: lv_color.h:162
void lv_obj_set_style(lv_obj_t *obj, const lv_style_t *style)
Definition: lv_style.h:57
Definition: lv_ll.h:33
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale