2018-06-09 08:47:09 +02:00
|
|
|
/**
|
2020-06-08 18:12:21 -05:00
|
|
|
* @file lv_spinner.h
|
2018-06-19 09:49:58 +02:00
|
|
|
*
|
2018-06-09 08:47:09 +02:00
|
|
|
*/
|
|
|
|
|
2020-02-14 12:36:44 +01:00
|
|
|
#ifndef LV_SPINNER_H
|
|
|
|
#define LV_SPINNER_H
|
2018-06-09 08:47:09 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2019-12-26 02:49:30 +01:00
|
|
|
#include "../lv_conf_internal.h"
|
2018-07-08 01:12:20 +02:00
|
|
|
|
2020-02-14 12:36:44 +01:00
|
|
|
#if LV_USE_SPINNER != 0
|
2018-06-09 08:47:09 +02:00
|
|
|
|
2018-07-08 01:12:20 +02:00
|
|
|
/*Testing of dependencies*/
|
2019-03-07 00:05:16 +01:00
|
|
|
#if LV_USE_ARC == 0
|
2020-06-08 18:12:21 -05:00
|
|
|
#error "lv_spinner: lv_arc is required. Enable it in lv_conf.h (LV_USE_ARC 1) "
|
2018-07-08 01:12:20 +02:00
|
|
|
#endif
|
|
|
|
|
2019-03-07 00:05:16 +01:00
|
|
|
#if LV_USE_ANIMATION == 0
|
2020-06-08 18:12:21 -05:00
|
|
|
#error "lv_spinner: animations are required. Enable it in lv_conf.h (LV_USE_ANIMATION 1) "
|
2018-07-08 01:12:20 +02:00
|
|
|
#endif
|
|
|
|
|
2018-06-09 08:47:09 +02:00
|
|
|
#include "../lv_core/lv_obj.h"
|
2019-05-20 09:22:09 -07:00
|
|
|
#include "../lv_misc/lv_anim.h"
|
2018-06-09 08:47:09 +02:00
|
|
|
#include "lv_arc.h"
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
2019-06-27 18:07:26 -04:00
|
|
|
/**
|
2020-02-14 12:36:44 +01:00
|
|
|
* Type of spinner.
|
2019-06-27 18:07:26 -04:00
|
|
|
*/
|
2018-09-18 13:59:40 +02:00
|
|
|
enum {
|
2020-02-14 12:36:44 +01:00
|
|
|
LV_SPINNER_TYPE_SPINNING_ARC,
|
|
|
|
LV_SPINNER_TYPE_FILLSPIN_ARC,
|
|
|
|
LV_SPINNER_TYPE_CONSTANT_ARC,
|
2018-09-18 13:59:40 +02:00
|
|
|
};
|
2020-02-14 12:36:44 +01:00
|
|
|
typedef uint8_t lv_spinner_type_t;
|
2018-06-09 08:47:09 +02:00
|
|
|
|
2019-06-27 18:07:26 -04:00
|
|
|
/**
|
2020-02-14 12:36:44 +01:00
|
|
|
* Direction the spinner should spin.
|
2019-06-27 18:07:26 -04:00
|
|
|
*/
|
2019-04-11 09:26:11 -07:00
|
|
|
enum {
|
2020-02-14 12:36:44 +01:00
|
|
|
LV_SPINNER_DIR_FORWARD,
|
|
|
|
LV_SPINNER_DIR_BACKWARD,
|
2019-04-11 09:26:11 -07:00
|
|
|
};
|
2020-02-14 12:36:44 +01:00
|
|
|
typedef uint8_t lv_spinner_dir_t;
|
2019-04-11 09:26:11 -07:00
|
|
|
|
2020-06-08 18:12:21 -05:00
|
|
|
/*Data of spinner*/
|
2020-02-26 19:48:27 +01:00
|
|
|
typedef struct {
|
2018-06-09 08:47:09 +02:00
|
|
|
lv_arc_ext_t arc; /*Ext. of ancestor*/
|
|
|
|
/*New data for this type */
|
2019-06-06 06:05:40 +02:00
|
|
|
lv_anim_value_t arc_length; /*Length of the spinning indicator in degree*/
|
|
|
|
uint16_t time; /*Time of one round*/
|
2020-02-14 12:36:44 +01:00
|
|
|
lv_spinner_type_t anim_type : 2; /*Type of the arc animation*/
|
|
|
|
lv_spinner_dir_t anim_dir : 1; /*Animation Direction*/
|
|
|
|
} lv_spinner_ext_t;
|
2018-06-09 08:47:09 +02:00
|
|
|
|
2020-02-14 12:36:44 +01:00
|
|
|
/*Parts of the spinner*/
|
2018-09-18 13:59:40 +02:00
|
|
|
enum {
|
2020-02-14 12:36:44 +01:00
|
|
|
LV_SPINNER_PART_BG = LV_ARC_PART_BG,
|
2020-03-09 15:19:23 +01:00
|
|
|
LV_SPINNER_PART_INDIC = LV_ARC_PART_INDIC,
|
2020-02-14 12:36:44 +01:00
|
|
|
_LV_SPINNER_PART_VIRTUAL_LAST,
|
2020-02-03 16:18:53 +01:00
|
|
|
|
2020-02-14 12:36:44 +01:00
|
|
|
_LV_SPINNER_PART_REAL_LAST = _LV_ARC_PART_REAL_LAST,
|
2018-09-18 13:59:40 +02:00
|
|
|
};
|
2020-02-14 12:36:44 +01:00
|
|
|
typedef uint8_t lv_spinner_style_t;
|
2018-06-09 08:47:09 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
2020-06-08 18:12:21 -05:00
|
|
|
* Create a spinner object
|
|
|
|
* @param par pointer to an object, it will be the parent of the new spinner
|
|
|
|
* @param copy pointer to a spinner object, if not NULL then the new object will be copied from
|
2019-04-04 07:15:40 +02:00
|
|
|
* it
|
2020-06-08 18:12:21 -05:00
|
|
|
* @return pointer to the created spinner
|
2018-06-09 08:47:09 +02:00
|
|
|
*/
|
2020-02-14 12:36:44 +01:00
|
|
|
lv_obj_t * lv_spinner_create(lv_obj_t * par, const lv_obj_t * copy);
|
2018-06-09 08:47:09 +02:00
|
|
|
|
|
|
|
/*======================
|
|
|
|
* Add/remove functions
|
|
|
|
*=====================*/
|
|
|
|
|
2018-06-11 10:36:36 +02:00
|
|
|
/**
|
|
|
|
* Set the length of the spinning arc in degrees
|
2020-06-08 18:12:21 -05:00
|
|
|
* @param spinner pointer to a spinner object
|
2018-06-11 10:36:36 +02:00
|
|
|
* @param deg length of the arc
|
|
|
|
*/
|
2020-06-08 18:12:21 -05:00
|
|
|
void lv_spinner_set_arc_length(lv_obj_t * spinner, lv_anim_value_t deg);
|
2018-06-11 10:36:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the spin time of the arc
|
2020-06-08 18:12:21 -05:00
|
|
|
* @param spinner pointer to a spinner object
|
2018-06-11 10:36:36 +02:00
|
|
|
* @param time time of one round in milliseconds
|
|
|
|
*/
|
2020-06-08 18:12:21 -05:00
|
|
|
void lv_spinner_set_spin_time(lv_obj_t * spinner, uint16_t time);
|
2018-06-09 08:47:09 +02:00
|
|
|
|
|
|
|
/*=====================
|
|
|
|
* Setter functions
|
|
|
|
*====================*/
|
|
|
|
|
2018-11-15 11:37:00 +01:00
|
|
|
/**
|
2020-02-14 12:36:44 +01:00
|
|
|
* Set the animation type of a spinner.
|
2020-06-08 18:12:21 -05:00
|
|
|
* @param spinner pointer to spinner object
|
|
|
|
* @param type animation type of the spinner
|
2018-11-15 11:37:00 +01:00
|
|
|
* */
|
2020-06-08 18:12:21 -05:00
|
|
|
void lv_spinner_set_type(lv_obj_t * spinner, lv_spinner_type_t type);
|
2018-11-15 11:37:00 +01:00
|
|
|
|
2019-04-11 09:26:11 -07:00
|
|
|
/**
|
2020-02-14 12:36:44 +01:00
|
|
|
* Set the animation direction of a spinner
|
2020-06-08 18:12:21 -05:00
|
|
|
* @param spinner pointer to spinner object
|
|
|
|
* @param direction animation direction of the spinner
|
2019-04-11 09:26:11 -07:00
|
|
|
*/
|
2020-06-08 18:12:21 -05:00
|
|
|
void lv_spinner_set_dir(lv_obj_t * spinner, lv_spinner_dir_t dir);
|
2019-04-11 09:26:11 -07:00
|
|
|
|
2018-06-09 08:47:09 +02:00
|
|
|
/*=====================
|
|
|
|
* Getter functions
|
|
|
|
*====================*/
|
|
|
|
|
2018-06-11 10:36:36 +02:00
|
|
|
/**
|
2020-06-08 18:12:21 -05:00
|
|
|
* Get the arc length [degree] of the a spinner
|
|
|
|
* @param spinner pointer to a spinner object
|
2018-06-11 10:36:36 +02:00
|
|
|
*/
|
2020-06-08 18:12:21 -05:00
|
|
|
lv_anim_value_t lv_spinner_get_arc_length(const lv_obj_t * spinner);
|
2018-06-11 10:36:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the spin time of the arc
|
2020-06-08 18:12:21 -05:00
|
|
|
* @param spinner pointer to a spinner object [milliseconds]
|
2018-06-11 10:36:36 +02:00
|
|
|
*/
|
2020-06-08 18:12:21 -05:00
|
|
|
uint16_t lv_spinner_get_spin_time(const lv_obj_t * spinner);
|
2018-06-11 10:36:36 +02:00
|
|
|
|
2018-11-15 11:37:00 +01:00
|
|
|
/**
|
2020-02-14 12:36:44 +01:00
|
|
|
* Get the animation type of a spinner.
|
2020-06-08 18:12:21 -05:00
|
|
|
* @param spinner pointer to spinner object
|
2018-11-15 11:37:00 +01:00
|
|
|
* @return animation type
|
|
|
|
* */
|
2020-06-08 18:12:21 -05:00
|
|
|
lv_spinner_type_t lv_spinner_get_type(lv_obj_t * spinner);
|
2018-11-15 11:37:00 +01:00
|
|
|
|
2019-04-11 09:26:11 -07:00
|
|
|
/**
|
2020-02-14 12:36:44 +01:00
|
|
|
* Get the animation direction of a spinner
|
2020-06-08 18:12:21 -05:00
|
|
|
* @param spinner pointer to spinner object
|
2019-04-11 09:26:11 -07:00
|
|
|
* @return animation direction
|
|
|
|
*/
|
2020-06-08 18:12:21 -05:00
|
|
|
lv_spinner_dir_t lv_spinner_get_dir(lv_obj_t * spinner);
|
2019-04-11 09:26:11 -07:00
|
|
|
|
2018-06-09 08:47:09 +02:00
|
|
|
/*=====================
|
|
|
|
* Other functions
|
|
|
|
*====================*/
|
2018-07-30 06:52:29 +02:00
|
|
|
|
|
|
|
/**
|
2019-06-20 06:20:23 +02:00
|
|
|
* Animator function (exec_cb) to rotate the arc of spinner.
|
2020-02-14 12:36:44 +01:00
|
|
|
* @param ptr pointer to spinner
|
2019-06-20 06:20:23 +02:00
|
|
|
* @param val the current desired value [0..360]
|
|
|
|
*/
|
2020-02-25 10:47:49 +01:00
|
|
|
void lv_spinner_anim_cb(void * ptr, lv_anim_value_t val);
|
2018-06-09 08:47:09 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2020-02-14 12:36:44 +01:00
|
|
|
#endif /*LV_USE_SPINNER*/
|
2018-06-09 08:47:09 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
2020-02-14 12:36:44 +01:00
|
|
|
#endif /*LV_SPINNER_H*/
|