1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00
lvgl/src/lv_objx/lv_lmeter.h

195 lines
4.8 KiB
C
Raw Normal View History

2017-04-21 17:11:47 +02:00
/**
* @file lv_lmeter.h
2018-06-19 09:49:58 +02:00
*
2017-04-21 17:11:47 +02:00
*/
#ifndef LV_LMETER_H
#define LV_LMETER_H
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
extern "C" {
#endif
2017-04-21 17:11:47 +02:00
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
2019-03-17 08:33:03 +01:00
#include "../../../lv_conf.h"
#endif
#if LV_USE_LMETER != 0
2017-04-21 17:11:47 +02:00
2017-11-30 11:35:33 +01:00
#include "../lv_core/lv_obj.h"
2017-04-21 17:11:47 +02:00
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of line meter*/
typedef struct
{
2019-04-04 07:15:40 +02:00
/*No inherited ext.*/ /*Ext. of ancestor*/
2017-04-21 17:11:47 +02:00
/*New data for this type */
2019-04-04 07:15:40 +02:00
uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/
uint16_t angle_ofs;
2019-12-02 12:20:01 +01:00
uint16_t line_cnt; /*Count of lines */
int16_t cur_value;
int16_t min_value;
int16_t max_value;
2020-02-28 15:36:19 +01:00
uint8_t mirrored;
2018-06-19 09:49:58 +02:00
} lv_lmeter_ext_t;
2017-04-21 17:11:47 +02:00
/*Styles*/
enum {
LV_LMETER_STYLE_MAIN,
};
typedef uint8_t lv_lmeter_style_t;
2017-04-21 17:11:47 +02:00
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a line meter objects
* @param par pointer to an object, it will be the parent of the new line meter
2019-04-04 07:15:40 +02:00
* @param copy pointer to a line meter object, if not NULL then the new object will be copied from
* it
2017-04-21 17:11:47 +02:00
* @return pointer to the created line meter
*/
lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy);
2017-04-21 17:11:47 +02:00
2017-11-11 14:23:05 +01:00
/*=====================
* Setter functions
*====================*/
2017-04-21 17:11:47 +02:00
/**
* Set a new value on the line meter
* @param lmeter pointer to a line meter object
* @param value new value
*/
2019-04-04 07:15:40 +02:00
void lv_lmeter_set_value(lv_obj_t * lmeter, int16_t value);
/**
* Set minimum and the maximum values of a line meter
* @param lmeter pointer to he line meter object
* @param min minimum value
* @param max maximum value
*/
2019-04-04 07:15:40 +02:00
void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max);
2017-04-21 17:11:47 +02:00
/**
* Set the scale settings of a line meter
* @param lmeter pointer to a line meter object
* @param angle angle of the scale (0..360)
2017-11-11 14:23:05 +01:00
* @param line_cnt number of lines
2017-04-21 17:11:47 +02:00
*/
2019-12-02 12:20:01 +01:00
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint16_t line_cnt);
2017-11-11 14:23:05 +01:00
2019-11-12 13:07:26 +01:00
/**
* Set the set an offset for the line meter's angles to rotate it.
2019-11-12 13:07:26 +01:00
* @param lmeter pointer to a line meter object
* @param angle angle offset (0..360), rotates clockwise
2019-11-12 13:07:26 +01:00
*/
void lv_lmeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle);
2019-11-12 13:07:26 +01:00
2020-02-28 15:36:19 +01:00
/**
* Set the orientation of the meter growth, clockwise or counterclockwise (mirrored)
* @param lmeter pointer to a line meter object
* @param mirror mirror setting
*/
void lv_lmeter_set_mirror(lv_obj_t *lmeter, uint8_t mirror);
2017-11-11 14:23:05 +01:00
/**
* Set the styles of a line meter
* @param lmeter pointer to a line meter object
* @param type which style should be set (can be only `LV_LMETER_STYLE_MAIN`)
* @param style set the style of the line meter
2018-04-05 22:21:44 +02:00
*/
static inline void lv_lmeter_set_style(lv_obj_t * lmeter, lv_lmeter_style_t type, lv_style_t * style)
2017-11-11 14:23:05 +01:00
{
2019-06-27 07:16:15 +02:00
(void)type; /*Unused*/
lv_obj_set_style(lmeter, style);
2017-11-11 14:23:05 +01:00
}
/*=====================
* Getter functions
*====================*/
2017-04-21 17:11:47 +02:00
/**
* Get the value of a line meter
* @param lmeter pointer to a line meter object
* @return the value of the line meter
*/
2019-04-04 07:15:40 +02:00
int16_t lv_lmeter_get_value(const lv_obj_t * lmeter);
/**
* Get the minimum value of a line meter
* @param lmeter pointer to a line meter object
* @return the minimum value of the line meter
*/
int16_t lv_lmeter_get_min_value(const lv_obj_t * lmeter);
/**
* Get the maximum value of a line meter
* @param lmeter pointer to a line meter object
* @return the maximum value of the line meter
*/
int16_t lv_lmeter_get_max_value(const lv_obj_t * lmeter);
2017-04-21 17:11:47 +02:00
/**
* Get the scale number of a line meter
* @param lmeter pointer to a line meter object
* @return number of the scale units
*/
2019-12-05 06:44:11 +01:00
uint16_t lv_lmeter_get_line_count(const lv_obj_t * lmeter);
2017-04-21 17:11:47 +02:00
/**
* Get the scale angle of a line meter
* @param lmeter pointer to a line meter object
* @return angle of the scale
*/
uint16_t lv_lmeter_get_scale_angle(const lv_obj_t * lmeter);
/**
* get the set an offset for the line meter.
* @param lmeter pointer to a line meter object
* @return angle offset (0..360)
*/
uint16_t lv_lmeter_get_angle_offset(lv_obj_t * lmeter);
2020-02-28 15:36:19 +01:00
/**
* get the mirror setting for the line meter
* @param lmeter pointer to a line meter object
* @return mirror (0 or 1)
*/
uint16_t lv_lmeter_get_mirror(lv_obj_t * lmeter);
/**
* Get the style of a line meter
* @param lmeter pointer to a line meter object
* @param type which style should be get (can be only `LV_LMETER_STYLE_MAIN`)
* @return pointer to the line meter's style
*/
static inline const lv_style_t * lv_lmeter_get_style(const lv_obj_t * lmeter, lv_lmeter_style_t type)
{
2019-06-27 07:16:15 +02:00
(void)type; /*Unused*/
return lv_obj_get_style(lmeter);
}
2017-04-21 17:11:47 +02:00
/**********************
* MACROS
**********************/
2019-04-04 07:15:40 +02:00
#endif /*LV_USE_LMETER*/
2017-04-21 17:11:47 +02:00
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
} /* extern "C" */
2017-04-21 17:11:47 +02:00
#endif
2017-07-09 15:32:49 +02:00
2019-04-04 07:15:40 +02:00
#endif /*LV_LMETER_H*/