1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

Merge branch 'animated_switch' of https://github.com/embeddedt/lvgl into embeddedt-animated_switch

This commit is contained in:
Gabor Kiss-Vamosi 2018-11-20 07:33:53 +01:00
commit 84d20442a4
4 changed files with 124 additions and 42 deletions

View File

@ -27,7 +27,7 @@ In the simplest case you need 5 things:
3. Register a function which can **read an input device**. (E.g. touch pad)
4. Copy `lv_conf_templ.h` as `lv_conf.h` and set at least `LV_HOR_RES`, `LV_VER_RES` and `LV_COLOR_DEPTH`.
5. Call `lv_task_handler()` periodically every few milliseconds.
For a detailed description visit https://littlevgl.com/porting
For a detailed description visit https://github.com/littlevgl/lvgl/wiki/Porting
Or check the [Porting tutorial](https://github.com/littlevgl/lv_examples/blob/master/lv_tutorial/0_porting/lv_tutorial_porting.c)
## Project set-up

View File

@ -262,6 +262,7 @@
#if USE_LV_PRELOAD != 0
#define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
#define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
#define LV_PRELOAD_DEF_ANIM LV_PRELOAD_TYPE_SPINNING_ARC
#endif
/*************************

View File

@ -24,6 +24,12 @@
#ifndef LV_PRELOAD_DEF_SPIN_TIME
# define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
#endif
#ifndef LV_PRELOAD_DEF_ANIM
# define LV_PRELOAD_DEF_ANIM LV_PRELOAD_TYPE_SPINNING_ARC /*animation type*/
#endif
/**********************
* TYPEDEFS
**********************/
@ -73,26 +79,12 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
/*Initialize the allocated 'ext' */
ext->arc_length = LV_PRELOAD_DEF_ARC_LENGTH;
ext->anim_type = LV_PRELOAD_DEF_ANIM;
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_func(new_preload, lv_preload_signal);
lv_obj_set_design_func(new_preload, lv_preload_design);
#if USE_LV_ANIMATION
lv_anim_t a;
a.var = new_preload;
a.start = 0;
a.end = 360;
a.fp = (lv_anim_fp_t)lv_preload_spinner_animation;
a.path = lv_anim_path_ease_in_out;
a.end_cb = NULL;
a.act_time = 0;
a.time = LV_PRELOAD_DEF_SPIN_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 1;
a.repeat_pause = 0;
lv_anim_create(&a);
#endif
/*Init the new pre loader pre loader*/
if(copy == NULL) {
@ -106,6 +98,8 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_style(new_preload, &lv_style_pretty_color);
}
ext->time = LV_PRELOAD_DEF_SPIN_TIME;
}
/*Copy an existing pre loader*/
else {
@ -116,6 +110,8 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_refresh_style(new_preload);
}
lv_preload_set_animation_type(new_preload, ext->anim_type);
LV_LOG_INFO("preload created");
@ -148,22 +144,7 @@ void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time)
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
ext->time = time;
#if USE_LV_ANIMATION
lv_anim_t a;
a.var = preload;
a.start = 0;
a.end = 360;
a.fp = (lv_anim_fp_t)lv_preload_spinner_animation;
a.path = lv_anim_path_ease_in_out;
a.end_cb = NULL;
a.act_time = 0;
a.time = time;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 1;
a.repeat_pause = 0;
lv_anim_create(&a);
#endif
lv_preload_set_animation_type(preload, ext->anim_type);
}
/*=====================
* Setter functions
@ -178,12 +159,85 @@ void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time)
void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, lv_style_t * style)
{
switch(type) {
case LV_PRELOAD_STYLE_MAIN:
lv_arc_set_style(preload, LV_ARC_STYLE_MAIN, style);
break;
case LV_PRELOAD_STYLE_MAIN:
lv_arc_set_style(preload, LV_ARC_STYLE_MAIN, style);
break;
}
}
/**
* Set the animation type of a preloadeer.
* @param preload pointer to pre loader object
* @param type animation type of the preload
* */
void lv_preload_set_animation_type(lv_obj_t * preload, lv_preloader_type_t type)
{
#if USE_LV_ANIMATION
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
/*delete previous animation*/
//lv_anim_del(preload, NULL);
switch(type)
{
case LV_PRELOAD_TYPE_FILLSPIN_ARC:
{
ext->anim_type = LV_PRELOAD_TYPE_FILLSPIN_ARC;
lv_anim_t a;
a.var = preload;
a.start = 0;
a.end = 360;
a.fp = (lv_anim_fp_t)lv_preload_spinner_animation;
a.path = lv_anim_path_ease_in_out;
a.end_cb = NULL;
a.act_time = 0;
a.time = ext->time;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 1;
a.repeat_pause = 0;
lv_anim_create(&a);
lv_anim_t b;
b.var = preload;
b.start = ext->arc_length;
b.end = 360 - ext->arc_length;
b.fp = (lv_anim_fp_t)lv_preload_set_arc_length;
b.path = lv_anim_path_ease_in_out;
b.end_cb = NULL;
b.act_time = 0;
b.time = ext->time;
b.playback = 1;
b.playback_pause = 0;
b.repeat = 1;
b.repeat_pause = 0;
lv_anim_create(&b);
break;
}
case LV_PRELOAD_TYPE_SPINNING_ARC:
default:
{
ext->anim_type = LV_PRELOAD_TYPE_SPINNING_ARC;
lv_anim_t a;
a.var = preload;
a.start = 0;
a.end = 360;
a.fp = (lv_anim_fp_t)lv_preload_spinner_animation;
a.path = lv_anim_path_ease_in_out;
a.end_cb = NULL;
a.act_time = 0;
a.time = ext->time;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 1;
a.repeat_pause = 0;
lv_anim_create(&a);
break;
}
}
#endif //USE_LV_ANIMATION
}
/*=====================
* Getter functions
*====================*/
@ -220,17 +274,28 @@ lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_style_t t
lv_style_t * style = NULL;
switch(type) {
case LV_PRELOAD_STYLE_MAIN:
style = lv_arc_get_style(preload, LV_ARC_STYLE_MAIN);
break;
default:
style = NULL;
break;
case LV_PRELOAD_STYLE_MAIN:
style = lv_arc_get_style(preload, LV_ARC_STYLE_MAIN);
break;
default:
style = NULL;
break;
}
return style;
}
/**
* Get the animation type of a preloadeer.
* @param preload pointer to pre loader object
* @return animation type
* */
lv_preloader_type_t lv_preload_get_animation_type(lv_obj_t * preload)
{
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
return ext->anim_type;
}
/*=====================
* Other functions
*====================*/

View File

@ -43,6 +43,7 @@ extern "C" {
enum {
LV_PRELOAD_TYPE_SPINNING_ARC,
LV_PRELOAD_TYPE_FILLSPIN_ARC,
};
typedef uint8_t lv_preloader_type_t;
@ -52,6 +53,7 @@ typedef struct {
/*New data for this type */
uint16_t arc_length; /*Length of the spinning indicator in degree*/
uint16_t time; /*Time of one round*/
lv_preloader_type_t anim_type; /*Type of the arc animation*/
} lv_preload_ext_t;
@ -103,6 +105,13 @@ void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time);
* */
void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, lv_style_t *style);
/**
* Set the animation type of a preloadeer.
* @param preload pointer to pre loader object
* @param type animation type of the preload
* */
void lv_preload_set_animation_type(lv_obj_t * preload, lv_preloader_type_t type);
/*=====================
* Getter functions
*====================*/
@ -127,6 +136,13 @@ uint16_t lv_preload_get_spin_time(const lv_obj_t * preload);
* */
lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_style_t type);
/**
* Get the animation type of a preloadeer.
* @param preload pointer to pre loader object
* @return animation type
* */
lv_preloader_type_t lv_preload_get_animation_type(lv_obj_t * preload);
/*=====================
* Other functions
*====================*/