Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/lvgl/lv_objx/lv_chart.h
1476 views
1
/**
2
* @file lv_chart.h
3
*
4
*/
5
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 USE_LV_CHART != 0
23
24
#include "../lv_core/lv_obj.h"
25
#include "lv_line.h"
26
27
/*********************
28
* DEFINES
29
*********************/
30
#define LV_CHART_POINT_DEF (LV_COORD_MIN)
31
32
/**********************
33
* TYPEDEFS
34
**********************/
35
typedef struct
36
{
37
lv_coord_t * points;
38
lv_color_t color;
39
uint16_t start_point;
40
} lv_chart_series_t;
41
42
/*Data of chart */
43
typedef struct
44
{
45
/*No inherited ext*/ /*Ext. of ancestor*/
46
/*New data for this type */
47
lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_dl_t)*/
48
lv_coord_t ymin; /*y min value (used to scale the data)*/
49
lv_coord_t ymax; /*y max value (used to scale the data)*/
50
uint8_t hdiv_cnt; /*Number of horizontal division lines*/
51
uint8_t vdiv_cnt; /*Number of vertical division lines*/
52
uint16_t point_cnt; /*Point number in a data line*/
53
uint8_t type :4; /*Line, column or point chart (from 'lv_chart_type_t')*/
54
struct {
55
lv_coord_t width; /*Line width or point radius*/
56
uint8_t num; /*Number of data lines in dl_ll*/
57
lv_opa_t opa; /*Opacity of data lines*/
58
lv_opa_t dark; /*Dark level of the point/column bottoms*/
59
} series;
60
} lv_chart_ext_t;
61
62
/*Chart types*/
63
enum
64
{
65
LV_CHART_TYPE_LINE = 0x01, /*Connect the points with lines*/
66
LV_CHART_TYPE_COLUMN = 0x02, /*Draw columns*/
67
LV_CHART_TYPE_POINT = 0x04, /*Draw circles on the points*/
68
LV_CHART_TYPE_VERTICAL_LINE = 0x08, /*Draw vertical lines on points (useful when chart width == point count)*/
69
};
70
typedef uint8_t lv_chart_type_t;
71
72
73
/**********************
74
* GLOBAL PROTOTYPES
75
**********************/
76
77
/**
78
* Create a chart background objects
79
* @param par pointer to an object, it will be the parent of the new chart background
80
* @param copy pointer to a chart background object, if not NULL then the new object will be copied from it
81
* @return pointer to the created chart background
82
*/
83
lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy);
84
85
/*======================
86
* Add/remove functions
87
*=====================*/
88
89
/**
90
* Allocate and add a data series to the chart
91
* @param chart pointer to a chart object
92
* @param color color of the data series
93
* @return pointer to the allocated data series
94
*/
95
lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color);
96
97
/**
98
* Clear the point of a serie
99
* @param chart pointer to a chart object
100
* @param serie pointer to the chart's serie to clear
101
*/
102
void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie);
103
104
/*=====================
105
* Setter functions
106
*====================*/
107
108
/**
109
* Set the number of horizontal and vertical division lines
110
* @param chart pointer to a graph background object
111
* @param hdiv number of horizontal division lines
112
* @param vdiv number of vertical division lines
113
*/
114
void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv);
115
116
/**
117
* Set the minimal and maximal y values
118
* @param chart pointer to a graph background object
119
* @param ymin y minimum value
120
* @param ymax y maximum value
121
*/
122
void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax);
123
124
/**
125
* Set a new type for a chart
126
* @param chart pointer to a chart object
127
* @param type new type of the chart (from 'lv_chart_type_t' enum)
128
*/
129
void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type);
130
131
/**
132
* Set the number of points on a data line on a chart
133
* @param chart pointer r to chart object
134
* @param point_cnt new number of points on the data lines
135
*/
136
void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt);
137
138
/**
139
* Set the opacity of the data series
140
* @param chart pointer to a chart object
141
* @param opa opacity of the data series
142
*/
143
void lv_chart_set_series_opa(lv_obj_t * chart, lv_opa_t opa);
144
145
/**
146
* Set the line width or point radius of the data series
147
* @param chart pointer to a chart object
148
* @param width the new width
149
*/
150
void lv_chart_set_series_width(lv_obj_t * chart, lv_coord_t width);
151
152
/**
153
* Set the dark effect on the bottom of the points or columns
154
* @param chart pointer to a chart object
155
* @param dark_eff dark effect level (LV_OPA_TRANSP to turn off)
156
*/
157
void lv_chart_set_series_darking(lv_obj_t * chart, lv_opa_t dark_eff);
158
159
/**
160
* Initialize all data points with a value
161
* @param chart pointer to chart object
162
* @param ser pointer to a data series on 'chart'
163
* @param y the new value for all points
164
*/
165
void lv_chart_init_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y);
166
167
/**
168
* Set the value s of points from an array
169
* @param chart pointer to chart object
170
* @param ser pointer to a data series on 'chart'
171
* @param y_array array of 'lv_coord_t' points (with 'points count' elements )
172
*/
173
void lv_chart_set_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t * y_array);
174
175
/**
176
* Shift all data right and set the most right data on a data line
177
* @param chart pointer to chart object
178
* @param ser pointer to a data series on 'chart'
179
* @param y the new value of the most right data
180
*/
181
void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y);
182
183
/**
184
* Set the style of a chart
185
* @param chart pointer to a chart object
186
* @param style pointer to a style
187
*/
188
static inline void lv_chart_set_style(lv_obj_t *chart, lv_style_t *style)
189
{
190
lv_obj_set_style(chart, style);
191
}
192
193
/*=====================
194
* Getter functions
195
*====================*/
196
197
/**
198
* Get the type of a chart
199
* @param chart pointer to chart object
200
* @return type of the chart (from 'lv_chart_t' enum)
201
*/
202
lv_chart_type_t lv_chart_get_type(const lv_obj_t * chart);
203
204
/**
205
* Get the data point number per data line on chart
206
* @param chart pointer to chart object
207
* @return point number on each data line
208
*/
209
uint16_t lv_chart_get_point_cnt(const lv_obj_t * chart);
210
211
/**
212
* Get the opacity of the data series
213
* @param chart pointer to chart object
214
* @return the opacity of the data series
215
*/
216
lv_opa_t lv_chart_get_series_opa(const lv_obj_t * chart);
217
218
/**
219
* Get the data series width
220
* @param chart pointer to chart object
221
* @return the width the data series (lines or points)
222
*/
223
lv_coord_t lv_chart_get_series_width(const lv_obj_t * chart);
224
225
/**
226
* Get the dark effect level on the bottom of the points or columns
227
* @param chart pointer to chart object
228
* @return dark effect level (LV_OPA_TRANSP to turn off)
229
*/
230
lv_opa_t lv_chart_get_series_darking(const lv_obj_t * chart);
231
232
/**
233
* Get the style of an chart object
234
* @param chart pointer to an chart object
235
* @return pointer to the chart's style
236
*/
237
static inline lv_style_t* lv_chart_get_style(const lv_obj_t *chart)
238
{
239
return lv_obj_get_style(chart);
240
}
241
242
/*=====================
243
* Other functions
244
*====================*/
245
246
/**
247
* Refresh a chart if its data line has changed
248
* @param chart pointer to chart object
249
*/
250
void lv_chart_refresh(lv_obj_t * chart);
251
252
/**********************
253
* MACROS
254
**********************/
255
256
#endif /*USE_LV_CHART*/
257
258
#ifdef __cplusplus
259
} /* extern "C" */
260
#endif
261
262
#endif /*LV_CHART_H*/
263
264