/**1* @file lv_gauge.h2*3*/45#ifndef LV_GAUGE_H6#define LV_GAUGE_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_GAUGE != 02223/*Testing of dependencies*/24#if USE_LV_LMETER == 025#error "lv_gauge: lv_lmeter is required. Enable it in lv_conf.h (USE_LV_LMETER 1) "26#endif2728#include "../lv_core/lv_obj.h"29#include "lv_lmeter.h"30#include "lv_label.h"31#include "lv_line.h"3233/*********************34* DEFINES35*********************/3637/**********************38* TYPEDEFS39**********************/4041/*Data of gauge*/42typedef struct43{44lv_lmeter_ext_t lmeter; /*Ext. of ancestor*/45/*New data for this type */46int16_t * values; /*Array of the set values (for needles) */47const lv_color_t * needle_colors; /*Color of the needles (lv_color_t my_colors[needle_num])*/48uint8_t needle_count; /*Number of needles*/49uint8_t label_count; /*Number of labels on the scale*/50} lv_gauge_ext_t;5152/**********************53* GLOBAL PROTOTYPES54**********************/5556/**57* Create a gauge objects58* @param par pointer to an object, it will be the parent of the new gauge59* @param copy pointer to a gauge object, if not NULL then the new object will be copied from it60* @return pointer to the created gauge61*/62lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy);6364/*=====================65* Setter functions66*====================*/6768/**69* Set the number of needles70* @param gauge pointer to gauge object71* @param needle_cnt new count of needles72* @param colors an array of colors for needles (with 'num' elements)73*/74void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_color_t * colors);7576/**77* Set the value of a needle78* @param gauge pointer to a gauge79* @param needle_id the id of the needle80* @param value the new value81*/82void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value);8384/**85* Set minimum and the maximum values of a gauge86* @param gauge pointer to he gauge object87* @param min minimum value88* @param max maximum value89*/90static inline void lv_gauge_set_range(lv_obj_t *gauge, int16_t min, int16_t max)91{92lv_lmeter_set_range(gauge, min, max);93}9495/**96* Set a critical value on the scale. After this value 'line.color' scale lines will be drawn97* @param gauge pointer to a gauge object98* @param value the critical value99*/100static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int16_t value)101{102lv_lmeter_set_value(gauge, value);103}104105/**106* Set the scale settings of a gauge107* @param gauge pointer to a gauge object108* @param angle angle of the scale (0..360)109* @param line_cnt count of scale lines.110* The get a given "subdivision" lines between label, `line_cnt` = (sub_div + 1) * (label_cnt - 1) + 1111* @param label_cnt count of scale labels.112*/113void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint8_t label_cnt);114115/**116* Set the styles of a gauge117* @param gauge pointer to a gauge object118* @param bg set the style of the gauge119* */120static inline void lv_gauge_set_style(lv_obj_t *gauge, lv_style_t *bg)121{122lv_obj_set_style(gauge, bg);123}124125/*=====================126* Getter functions127*====================*/128129/**130* Get the value of a needle131* @param gauge pointer to gauge object132* @param needle the id of the needle133* @return the value of the needle [min,max]134*/135int16_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle);136137/**138* Get the count of needles on a gauge139* @param gauge pointer to gauge140* @return count of needles141*/142uint8_t lv_gauge_get_needle_count(const lv_obj_t * gauge);143144/**145* Get the minimum value of a gauge146* @param gauge pointer to a gauge object147* @return the minimum value of the gauge148*/149static inline int16_t lv_gauge_get_min_value(const lv_obj_t * lmeter)150{151return lv_lmeter_get_min_value(lmeter);152}153154/**155* Get the maximum value of a gauge156* @param gauge pointer to a gauge object157* @return the maximum value of the gauge158*/159static inline int16_t lv_gauge_get_max_value(const lv_obj_t * lmeter)160{161return lv_lmeter_get_max_value(lmeter);162}163164/**165* Get a critical value on the scale.166* @param gauge pointer to a gauge object167* @return the critical value168*/169static inline int16_t lv_gauge_get_critical_value(const lv_obj_t * gauge)170{171return lv_lmeter_get_value(gauge);172}173174/**175* Set the number of labels (and the thicker lines too)176* @param gauge pointer to a gauge object177* @return count of labels178*/179uint8_t lv_gauge_get_label_count(const lv_obj_t * gauge);180181/**182* Get the scale number of a gauge183* @param gauge pointer to a gauge object184* @return number of the scale units185*/186static inline uint8_t lv_gauge_get_line_count(const lv_obj_t * gauge)187{188return lv_lmeter_get_line_count(gauge);189}190191/**192* Get the scale angle of a gauge193* @param gauge pointer to a gauge object194* @return angle of the scale195*/196static inline uint16_t lv_gauge_get_scale_angle(const lv_obj_t * gauge)197{198return lv_lmeter_get_scale_angle(gauge);199}200201/**202* Get the style of a gauge203* @param gauge pointer to a gauge object204* @return pointer to the gauge's style205*/206static inline lv_style_t * lv_gauge_get_style(const lv_obj_t *gauge)207{208return lv_obj_get_style(gauge);209}210211/**********************212* MACROS213**********************/214215#endif /*USE_LV_GAUGE*/216217#ifdef __cplusplus218} /* extern "C" */219#endif220221#endif /*LV_GAUGE_H*/222223224