add lv_prloader

This commit is contained in:
Gabor Kiss-Vamosi
2018-06-11 10:36:36 +02:00
parent df226053cf
commit e4a12b22b4
8 changed files with 103 additions and 33 deletions
+7
View File
@@ -209,6 +209,13 @@
/*Calendar (dependencies: -)*/
#define USE_LV_CALENDAR 1
/*Preload (dependencies: arc)*/
#define USE_LV_PRELOAD 1
#if USE_LV_PRELOAD != 0
#define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
#define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
#endif
/*************************
* User input objects
*************************/
-1
View File
@@ -14,7 +14,6 @@
#include "../lv_hal/lv_hal_tick.h"
#include "lv_task.h"
#include "lv_math.h"
#include "lv_trigo.h"
/*********************
* DEFINES
-1
View File
@@ -9,7 +9,6 @@ CSRCS += lv_ll.c
CSRCS += lv_color.c
CSRCS += lv_txt.c
CSRCS += lv_ufs.c
CSRCS += lv_trigo.c
CSRCS += lv_math.c
DEPPATH += --dep-path lvgl/lv_misc
-1
View File
@@ -14,7 +14,6 @@
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_txt.h"
#include "../lv_misc/lv_trigo.h"
#include "../lv_misc/lv_math.h"
#include <stdio.h>
#include <string.h>
-1
View File
@@ -13,7 +13,6 @@
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_core/lv_group.h"
#include "../lv_misc/lv_trigo.h"
#include "../lv_misc/lv_math.h"
/*********************
+2
View File
@@ -1,9 +1,11 @@
CSRCS += lv_arc.c
CSRCS += lv_bar.c
CSRCS += lv_cb.c
CSRCS += lv_ddlist.c
CSRCS += lv_kb.c
CSRCS += lv_line.c
CSRCS += lv_mbox.c
CSRCS += lv_preloader.c
CSRCS += lv_roller.c
CSRCS += lv_tabview.c
CSRCS += lv_btn.c
+68 -19
View File
@@ -17,7 +17,13 @@
/*********************
* DEFINES
*********************/
#ifndef LV_PRELOAD_DEF_ARC_LENGTH
# define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
#endif
#ifndef LV_PRELOAD_DEF_SPIN_TIME
# define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
#endif
/**********************
* TYPEDEFS
**********************/
@@ -62,22 +68,21 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, lv_obj_t * copy)
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_func(new_preload);
/*Initialize the allocated 'ext' */
ext->type = LV_PRELOAD_TYPE_SPINNING_ARC;
ext->arc_length = LV_PRELOAD_DEF_ARC_LENGTH;
/*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);
lv_anim_t a;
a.var = new_preload;
a.start = 0;
a.end = 360;
a.fp = (lv_anim_fp_t)preload_spin;
a.path = lv_anim_path_momentum;
a.path = lv_anim_path_ease_in_out;
a.end_cb = NULL;
a.act_time = 0;
a.time = 1000;
a.time = LV_PRELOAD_DEF_SPIN_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 1;
@@ -91,7 +96,8 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, lv_obj_t * copy)
/*Copy an existing pre loader*/
else {
lv_preload_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->type = copy_ext->type;
ext->arc_length = copy_ext->arc_length;
ext->time = copy_ext->time;
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_preload);
}
@@ -103,20 +109,48 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, lv_obj_t * copy)
* Add/remove functions
*=====================*/
/*
* New object specific "add" or "remove" functions come here
/**
* Set the length of the spinning arc in degrees
* @param preload pointer to a preload object
* @param deg length of the arc
*/
void lv_preload_set_arc_length(lv_obj_t * preload, uint16_t deg)
{
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
ext->arc_length = deg;
}
/**
* Set the spin time of the arc
* @param preload pointer to a preload object
* @param time time of one round in milliseconds
*/
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;
lv_anim_t a;
a.var = preload;
a.start = 0;
a.end = 360;
a.fp = (lv_anim_fp_t)preload_spin;
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);
}
/*=====================
* Setter functions
*====================*/
/*
* New object specific "set" functions come here
*/
/**
* Set a style of a pre loader.
* @param preload pointer to pre loader object
@@ -125,8 +159,6 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, lv_obj_t * copy)
* */
void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, lv_style_t *style)
{
lv_preload_ext_t *ext = lv_obj_get_ext_attr(preload);
switch (type) {
case LV_PRELOAD_STYLE_MAIN:
lv_arc_set_style(preload, LV_ARC_STYLE_MAIN, style);
@@ -138,9 +170,26 @@ void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, lv_style_
* Getter functions
*====================*/
/*
* New object specific "get" functions come here
/**
* Get the arc length [degree] of the a pre loader
* @param preload pointer to a pre loader object
*/
uint16_t lv_preload_get_arc_length(lv_obj_t * preload)
{
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
return ext->arc_length;
}
/**
* Get the spin time of the arc
* @param preload pointer to a pre loader object [milliseconds]
*/
uint16_t lv_preload_get_spin_time(lv_obj_t * preload)
{
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
return ext->time;
}
/**
* Get style of a pre loader.
@@ -150,7 +199,6 @@ void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, lv_style_
* */
lv_style_t * lv_preload_get_style(lv_obj_t * preload, lv_preload_style_t type)
{
lv_preload_ext_t *ext = lv_obj_get_ext_attr(preload);
switch (type) {
case LV_PRELOAD_STYLE_MAIN: return lv_arc_get_style(preload, LV_ARC_STYLE_MAIN);
@@ -257,8 +305,9 @@ static lv_res_t lv_preload_signal(lv_obj_t * preload, lv_signal_t sign, void * p
static void preload_spin(void * ptr, int32_t val)
{
lv_obj_t * preload = ptr;
uint16_t angle_start = val + 15;
uint16_t angle_end = angle_start + 60;
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
int16_t angle_start = val - ext->arc_length / 2 + 180;
int16_t angle_end = angle_start + ext->arc_length;
angle_start = angle_start % 360;
angle_end = angle_end % 360;
+26 -10
View File
@@ -3,14 +3,6 @@
*
*/
/* TODO Remove these instructions
* Search an replace: pre loader -> object normal name with lower case (e.g. button, label etc.)
* preload -> object short name with lower case(e.g. btn, label etc)
* PRELOAD -> object short name with upper case (e.g. BTN, LABEL etc.)
*
*/
#ifndef LV_PRELOAD_H
#define LV_PRELOAD_H
@@ -43,8 +35,7 @@ typedef enum {
typedef struct {
lv_arc_ext_t arc; /*Ext. of ancestor*/
/*New data for this type */
lv_preloader_type_t type;
uint16_t indic_length; /*Length of the spinning indicator in degree*/
uint16_t arc_length; /*Length of the spinning indicator in degree*/
uint16_t time; /*Time of one round*/
}lv_preload_ext_t;
@@ -71,6 +62,19 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, lv_obj_t * copy);
* Add/remove functions
*=====================*/
/**
* Set the length of the spinning arc in degrees
* @param preload pointer to a preload object
* @param deg length of the arc
*/
void lv_preload_set_arc_length(lv_obj_t * preload, uint16_t deg);
/**
* Set the spin time of the arc
* @param preload pointer to a preload object
* @param time time of one round in milliseconds
*/
void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time);
/*=====================
* Setter functions
@@ -88,6 +92,18 @@ void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, lv_style_
* Getter functions
*====================*/
/**
* Get the arc length [degree] of the a pre loader
* @param preload pointer to a pre loader object
*/
uint16_t lv_preload_get_arc_length(lv_obj_t * preload);
/**
* Get the spin time of the arc
* @param preload pointer to a pre loader object [milliseconds]
*/
uint16_t lv_preload_get_spin_time(lv_obj_t * preload);
/**
* Get style of a pre loader.
* @param preload pointer to pre loader object