/**1* @file lv_chart.h2*3*/45#ifndef LV_CHART_H6#define LV_CHART_H78#ifdef __cplusplus9extern "C" {10#endif1112/*********************13* INCLUDES14*********************/15#ifdef LV_CONF_INCLUDE_SIMPLE16#include "lv_conf.h"17#else18#include "../../lv_conf.h"19#endif2021#if USE_LV_CHART != 02223#include "../lv_core/lv_obj.h"24#include "lv_line.h"2526/*********************27* DEFINES28*********************/29#define LV_CHART_POINT_DEF (LV_COORD_MIN)3031/**********************32* TYPEDEFS33**********************/34typedef struct35{36lv_coord_t * points;37lv_color_t color;38uint16_t start_point;39} lv_chart_series_t;4041/*Data of chart */42typedef struct43{44/*No inherited ext*/ /*Ext. of ancestor*/45/*New data for this type */46lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_dl_t)*/47lv_coord_t ymin; /*y min value (used to scale the data)*/48lv_coord_t ymax; /*y max value (used to scale the data)*/49uint8_t hdiv_cnt; /*Number of horizontal division lines*/50uint8_t vdiv_cnt; /*Number of vertical division lines*/51uint16_t point_cnt; /*Point number in a data line*/52uint8_t type :4; /*Line, column or point chart (from 'lv_chart_type_t')*/53struct {54lv_coord_t width; /*Line width or point radius*/55uint8_t num; /*Number of data lines in dl_ll*/56lv_opa_t opa; /*Opacity of data lines*/57lv_opa_t dark; /*Dark level of the point/column bottoms*/58} series;59} lv_chart_ext_t;6061/*Chart types*/62enum63{64LV_CHART_TYPE_LINE = 0x01, /*Connect the points with lines*/65LV_CHART_TYPE_COLUMN = 0x02, /*Draw columns*/66LV_CHART_TYPE_POINT = 0x04, /*Draw circles on the points*/67LV_CHART_TYPE_VERTICAL_LINE = 0x08, /*Draw vertical lines on points (useful when chart width == point count)*/68};69typedef uint8_t lv_chart_type_t;707172/**********************73* GLOBAL PROTOTYPES74**********************/7576/**77* Create a chart background objects78* @param par pointer to an object, it will be the parent of the new chart background79* @param copy pointer to a chart background object, if not NULL then the new object will be copied from it80* @return pointer to the created chart background81*/82lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy);8384/*======================85* Add/remove functions86*=====================*/8788/**89* Allocate and add a data series to the chart90* @param chart pointer to a chart object91* @param color color of the data series92* @return pointer to the allocated data series93*/94lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color);9596/**97* Clear the point of a serie98* @param chart pointer to a chart object99* @param serie pointer to the chart's serie to clear100*/101void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie);102103/*=====================104* Setter functions105*====================*/106107/**108* Set the number of horizontal and vertical division lines109* @param chart pointer to a graph background object110* @param hdiv number of horizontal division lines111* @param vdiv number of vertical division lines112*/113void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv);114115/**116* Set the minimal and maximal y values117* @param chart pointer to a graph background object118* @param ymin y minimum value119* @param ymax y maximum value120*/121void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax);122123/**124* Set a new type for a chart125* @param chart pointer to a chart object126* @param type new type of the chart (from 'lv_chart_type_t' enum)127*/128void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type);129130/**131* Set the number of points on a data line on a chart132* @param chart pointer r to chart object133* @param point_cnt new number of points on the data lines134*/135void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt);136137/**138* Set the opacity of the data series139* @param chart pointer to a chart object140* @param opa opacity of the data series141*/142void lv_chart_set_series_opa(lv_obj_t * chart, lv_opa_t opa);143144/**145* Set the line width or point radius of the data series146* @param chart pointer to a chart object147* @param width the new width148*/149void lv_chart_set_series_width(lv_obj_t * chart, lv_coord_t width);150151/**152* Set the dark effect on the bottom of the points or columns153* @param chart pointer to a chart object154* @param dark_eff dark effect level (LV_OPA_TRANSP to turn off)155*/156void lv_chart_set_series_darking(lv_obj_t * chart, lv_opa_t dark_eff);157158/**159* Initialize all data points with a value160* @param chart pointer to chart object161* @param ser pointer to a data series on 'chart'162* @param y the new value for all points163*/164void lv_chart_init_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y);165166/**167* Set the value s of points from an array168* @param chart pointer to chart object169* @param ser pointer to a data series on 'chart'170* @param y_array array of 'lv_coord_t' points (with 'points count' elements )171*/172void lv_chart_set_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t * y_array);173174/**175* Shift all data right and set the most right data on a data line176* @param chart pointer to chart object177* @param ser pointer to a data series on 'chart'178* @param y the new value of the most right data179*/180void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y);181182/**183* Set the style of a chart184* @param chart pointer to a chart object185* @param style pointer to a style186*/187static inline void lv_chart_set_style(lv_obj_t *chart, lv_style_t *style)188{189lv_obj_set_style(chart, style);190}191192/*=====================193* Getter functions194*====================*/195196/**197* Get the type of a chart198* @param chart pointer to chart object199* @return type of the chart (from 'lv_chart_t' enum)200*/201lv_chart_type_t lv_chart_get_type(const lv_obj_t * chart);202203/**204* Get the data point number per data line on chart205* @param chart pointer to chart object206* @return point number on each data line207*/208uint16_t lv_chart_get_point_cnt(const lv_obj_t * chart);209210/**211* Get the opacity of the data series212* @param chart pointer to chart object213* @return the opacity of the data series214*/215lv_opa_t lv_chart_get_series_opa(const lv_obj_t * chart);216217/**218* Get the data series width219* @param chart pointer to chart object220* @return the width the data series (lines or points)221*/222lv_coord_t lv_chart_get_series_width(const lv_obj_t * chart);223224/**225* Get the dark effect level on the bottom of the points or columns226* @param chart pointer to chart object227* @return dark effect level (LV_OPA_TRANSP to turn off)228*/229lv_opa_t lv_chart_get_series_darking(const lv_obj_t * chart);230231/**232* Get the style of an chart object233* @param chart pointer to an chart object234* @return pointer to the chart's style235*/236static inline lv_style_t* lv_chart_get_style(const lv_obj_t *chart)237{238return lv_obj_get_style(chart);239}240241/*=====================242* Other functions243*====================*/244245/**246* Refresh a chart if its data line has changed247* @param chart pointer to chart object248*/249void lv_chart_refresh(lv_obj_t * chart);250251/**********************252* MACROS253**********************/254255#endif /*USE_LV_CHART*/256257#ifdef __cplusplus258} /* extern "C" */259#endif260261#endif /*LV_CHART_H*/262263264