2016-08-04 11:33:35 +02:00
|
|
|
/**
|
|
|
|
* @file lv_pb.h
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LV_PB_H
|
|
|
|
#define LV_PB_H
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
|
|
|
#include "lv_conf.h"
|
|
|
|
#if USE_LV_PB != 0
|
|
|
|
|
2017-01-02 10:48:21 +01:00
|
|
|
/*Testing of dependencies*/
|
|
|
|
#if USE_LV_RECT == 0
|
|
|
|
#error "lv_pb: lv_rect is required. Enable it in lv_conf.h (USE_LV_RECT 1) "
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_LV_LABEL == 0
|
|
|
|
#error "lv_pb: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
|
|
|
|
#endif
|
|
|
|
|
2016-08-04 11:33:35 +02:00
|
|
|
#include "../lv_obj/lv_obj.h"
|
|
|
|
#include "lv_rect.h"
|
2017-02-03 12:48:22 +01:00
|
|
|
#include "lv_btn.h"
|
2016-08-04 11:33:35 +02:00
|
|
|
#include "lv_label.h"
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
2017-01-14 23:54:16 +01:00
|
|
|
/*Data of progress bar*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
lv_rect_ext_t rect_ext; /*Ext. of ancestor*/
|
|
|
|
/*New data for this type */
|
2017-02-03 12:48:22 +01:00
|
|
|
lv_obj_t * label; /*Pointer to the label on the progress bar*/
|
|
|
|
int16_t act_value; /*Current value of the progress bar*/
|
|
|
|
int16_t tmp_value; /*Value when settings from a display input*/
|
|
|
|
int16_t min_value; /*Minimum value of the progress bar*/
|
|
|
|
int16_t max_value; /*Maximum value of the progress bar*/
|
|
|
|
char * format_str; /*Format string of the label. E.g. "Progress: %d"*/
|
2017-01-14 23:54:16 +01:00
|
|
|
}lv_pb_ext_t;
|
|
|
|
|
2016-08-04 11:33:35 +02:00
|
|
|
/*Style of progress bar*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2017-01-14 23:54:16 +01:00
|
|
|
lv_rects_t bg; /*Style of the background (inherited)*/
|
|
|
|
lv_rects_t bar; /*Style of the bar*/
|
2017-02-11 20:27:18 +01:00
|
|
|
lv_labels_t label; /*Style of the label*/
|
2017-02-03 12:48:22 +01:00
|
|
|
lv_rects_t btn; /*Style of the button (it is rectangle but acts as a button)*/
|
2017-02-11 20:27:18 +01:00
|
|
|
cord_t btn_size; /*Width or height of the button (depending on the orientation of the pb)*/
|
|
|
|
|
2016-08-04 11:33:35 +02:00
|
|
|
}lv_pbs_t;
|
|
|
|
|
|
|
|
/*Built-in styles of progress bar*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
LV_PBS_DEF,
|
2017-02-03 12:48:22 +01:00
|
|
|
LV_PBS_SLIDER,
|
2016-08-04 11:33:35 +02:00
|
|
|
}lv_pbs_builtin_t;
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a progress bar objects
|
|
|
|
* @param par pointer to an object, it will be the parent of the new progress bar
|
|
|
|
* @param copy pointer to a progress bar object, if not NULL then the new object will be copied from it
|
|
|
|
* @return pointer to the created progress bar
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * lv_pb_create(lv_obj_t * par, lv_obj_t * copy);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Signal function of the progress bar
|
|
|
|
* @param pb pointer to a progress bar object
|
|
|
|
* @param sign a signal type from lv_signal_t enum
|
|
|
|
* @param param pointer to a signal specific variable
|
|
|
|
*/
|
|
|
|
bool lv_pb_signal(lv_obj_t * pb, lv_signal_t sign, void * param);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a new value on the progress bar
|
|
|
|
* @param pb pointer to a progress bar object
|
|
|
|
* @param value new value
|
|
|
|
*/
|
2017-02-03 12:48:22 +01:00
|
|
|
void lv_pb_set_value(lv_obj_t * pb, int16_t value);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set minimum and the maximum values of a progress bar
|
|
|
|
* @param pb pointer to he progress bar object
|
|
|
|
* @param min minimum value
|
|
|
|
* @param max maximum value
|
|
|
|
*/
|
2017-02-03 12:48:22 +01:00
|
|
|
void lv_pb_set_min_max_value(lv_obj_t * pb, int16_t min, int16_t max);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set format string for the label of the progress bar
|
|
|
|
* @param pb pointer to progress bar object
|
|
|
|
* @param format a printf-like format string with one number (e.g. "Loading (%d)")
|
|
|
|
*/
|
|
|
|
void lv_pb_set_format_str(lv_obj_t * pb, const char * format);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the value of a progress bar
|
|
|
|
* @param pb pointer to a progress bar object
|
|
|
|
* @return the value of the progress bar
|
|
|
|
*/
|
2017-02-03 12:48:22 +01:00
|
|
|
int16_t lv_pb_get_value(lv_obj_t * pb);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return with a pointer to a built-in style and/or copy it to a variable
|
|
|
|
* @param style a style name from lv_pbs_builtin_t enum
|
|
|
|
* @param copy copy the style to this variable. (NULL if unused)
|
|
|
|
* @return pointer to an lv_pbs_t style
|
|
|
|
*/
|
|
|
|
lv_pbs_t * lv_pbs_get(lv_pbs_builtin_t style, lv_pbs_t * copy);
|
2016-08-04 11:33:35 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|