2016-08-08 16:25:41 +02:00
|
|
|
/**
|
|
|
|
* @file lv_chart.h
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-04-24 16:16:36 +02:00
|
|
|
#ifndef LV_CHART_H
|
|
|
|
#define LV_CHART_H
|
2016-08-08 16:25:41 +02:00
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-08-08 16:25:41 +02:00
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
|
|
|
#include "lv_conf.h"
|
2016-12-29 23:48:01 +01:00
|
|
|
#if USE_LV_CHART != 0
|
2016-08-08 16:25:41 +02:00
|
|
|
|
|
|
|
#include "../lv_obj/lv_obj.h"
|
|
|
|
#include "lv_line.h"
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
2017-04-13 10:20:35 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
cord_t * points;
|
|
|
|
color_t color;
|
|
|
|
}lv_chart_dl_t;
|
|
|
|
|
2017-04-10 11:33:38 +02:00
|
|
|
/*Data of chart */
|
2017-01-14 23:54:16 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2017-04-13 15:57:02 +02:00
|
|
|
/*No inherited ext*/ /*Ext. of ancestor*/
|
2017-01-14 23:54:16 +01:00
|
|
|
/*New data for this type */
|
2017-04-21 09:15:39 +02:00
|
|
|
ll_dsc_t dl_ll; /*Linked list for the data line pointers (stores lv_chart_dl_t)*/
|
2017-04-10 11:33:38 +02:00
|
|
|
cord_t ymin; /*y min value (used to scale the data)*/
|
|
|
|
cord_t ymax; /*y max value (used to scale the data)*/
|
2017-01-14 23:54:16 +01:00
|
|
|
uint8_t hdiv_num; /*Number of horizontal division lines*/
|
|
|
|
uint8_t vdiv_num; /*Number of vertical division lines*/
|
|
|
|
uint16_t pnum; /*Point number in a data line*/
|
2017-04-21 09:15:39 +02:00
|
|
|
cord_t dl_width; /*Line width or point radius*/
|
2017-04-13 10:20:35 +02:00
|
|
|
uint8_t dl_num; /*Number of data lines in dl_ll*/
|
2017-04-21 09:15:39 +02:00
|
|
|
opa_t dl_opa; /*Opacity of data lines*/
|
|
|
|
opa_t dl_dark; /*Dark level of the point/column bottoms*/
|
|
|
|
uint8_t type :3; /*Line, column or point chart (from 'lv_chart_type_t')*/
|
2017-01-14 23:54:16 +01:00
|
|
|
}lv_chart_ext_t;
|
2016-08-08 16:25:41 +02:00
|
|
|
|
2017-01-14 23:54:16 +01:00
|
|
|
/*Chart types*/
|
2016-08-08 16:25:41 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
2017-04-13 10:20:35 +02:00
|
|
|
LV_CHART_NONE = 0,
|
2017-04-21 09:15:39 +02:00
|
|
|
LV_CHART_LINE = 0x01,
|
|
|
|
LV_CHART_COL = 0x02,
|
|
|
|
LV_CHART_POINT = 0x04,
|
2016-08-08 16:25:41 +02:00
|
|
|
}lv_chart_type_t;
|
|
|
|
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a chart background objects
|
|
|
|
* @param par pointer to an object, it will be the parent of the new chart background
|
|
|
|
* @param copy pointer to a chart background object, if not NULL then the new object will be copied from it
|
|
|
|
* @return pointer to the created chart background
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Signal function of the chart background
|
|
|
|
* @param chart pointer to a chart background object
|
|
|
|
* @param sign a signal type from lv_signal_t enum
|
|
|
|
* @param param pointer to a signal specific variable
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param);
|
2016-08-08 16:25:41 +02:00
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Allocate and add a data line to the chart
|
|
|
|
* @param chart pointer to a chart object
|
2017-04-21 09:15:39 +02:00
|
|
|
* @param color color of the data line
|
|
|
|
* @return pointer to the allocated data line (
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2017-04-28 16:12:35 +02:00
|
|
|
lv_chart_dl_t * lv_chart_add_data_line(lv_obj_t * chart, color_t color);
|
2016-08-08 16:25:41 +02:00
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Refresh a chart if its data line has changed
|
|
|
|
* @param chart pointer to chart object
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_chart_refr(lv_obj_t * chart);
|
2016-08-08 16:25:41 +02:00
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Set the number of horizontal and vertical division lines
|
|
|
|
* @param chart pointer to a graph background object
|
|
|
|
* @param hdiv number of horizontal division lines
|
|
|
|
* @param vdiv number of vertical division lines
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_chart_set_hvdiv(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the minimal and maximal x and y values
|
|
|
|
* @param chart pointer to a graph background object
|
|
|
|
* @param xmin x minimum value
|
|
|
|
* @param xmax x maximum value
|
|
|
|
* @param ymin y minimum value
|
|
|
|
* @param ymax y maximum value
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_chart_set_range(lv_obj_t * chart, cord_t ymin, cord_t ymax);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a new type for a chart
|
|
|
|
* @param chart pointer to a chart object
|
|
|
|
* @param type new type of the chart (from 'lv_chart_type_t' enum)
|
|
|
|
*/
|
|
|
|
void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the number of points on a data line on a chart
|
|
|
|
* @param chart pointer r to chart object
|
|
|
|
* @param pnum new number of points on the data lines
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
void lv_chart_set_pnum(lv_obj_t * chart, uint16_t pnum);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
2017-04-21 09:15:39 +02:00
|
|
|
/**
|
|
|
|
* Set the opacity of the data lines
|
|
|
|
* @param chart pointer to chart object
|
|
|
|
* @param opa opacity of the data lines
|
|
|
|
*/
|
|
|
|
void lv_chart_set_dl_opa(lv_obj_t * chart, opa_t opa);
|
2017-04-13 10:20:35 +02:00
|
|
|
|
2017-04-21 09:15:39 +02:00
|
|
|
/**
|
|
|
|
* Set the line width or point radius of the data lines
|
|
|
|
* @param chart pointer to chart object
|
|
|
|
* @param width the new width
|
|
|
|
*/
|
|
|
|
void lv_chart_set_dl_width(lv_obj_t * chart, cord_t width);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the dark effect on the bottom of the points or columns
|
|
|
|
* @param chart pointer to chart object
|
|
|
|
* @param dark_eff dark effect level (OPA_TRANSP to turn off)
|
|
|
|
*/
|
|
|
|
void lv_chart_set_dl_dark(lv_obj_t * chart, opa_t dark_eff);
|
2017-04-13 10:20:35 +02:00
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Shift all data right and set the most right data on a data line
|
|
|
|
* @param chart pointer to chart object
|
|
|
|
* @param dl pointer to a data line on 'chart'
|
|
|
|
* @param y the new value of the most right data
|
|
|
|
*/
|
2017-04-13 13:34:57 +02:00
|
|
|
void lv_chart_set_next(lv_obj_t * chart, lv_chart_dl_t * dl, cord_t y);
|
2016-08-08 16:25:41 +02:00
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Get the type of a chart
|
|
|
|
* @param chart pointer to chart object
|
|
|
|
* @return type of the chart (from 'lv_chart_t' enum)
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_chart_type_t lv_chart_get_type(lv_obj_t * chart);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the data point number per data line on chart
|
|
|
|
* @param chart pointer to chart object
|
|
|
|
* @return point number on each data line
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
uint16_t lv_chart_get_pnum(lv_obj_t * chart);
|
2016-08-11 15:00:46 +02:00
|
|
|
|
2017-04-21 09:15:39 +02:00
|
|
|
/**
|
|
|
|
* Get the opacity of the data lines
|
|
|
|
* @param chart pointer to chart object
|
|
|
|
* @return the opacity of the data lines
|
|
|
|
*/
|
|
|
|
opa_t lv_chart_get_dl_opa(lv_obj_t * chart);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the data line width
|
|
|
|
* @param chart pointer to chart object
|
|
|
|
* @return the width the data lines (lines or points)
|
|
|
|
*/
|
|
|
|
cord_t lv_chart_get_dl_width(lv_obj_t * chart);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the dark effect level on the bottom of the points or columns
|
|
|
|
* @param chart pointer to chart object
|
|
|
|
* @return dark effect level (OPA_TRANSP to turn off)
|
|
|
|
*/
|
|
|
|
opa_t lv_chart_get_dl_dark(lv_obj_t * chart, opa_t dark_eff);
|
|
|
|
|
2016-08-08 16:25:41 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#endif /*USE_LV_CHART*/
|
2016-08-08 16:25:41 +02:00
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
2016-08-08 16:25:41 +02:00
|
|
|
#endif
|
2017-07-09 15:32:49 +02:00
|
|
|
|
|
|
|
#endif /*LV_CHART_H*/
|