This commit is contained in:
Gabor Kiss-Vamosi
2021-05-07 15:04:08 +02:00
14 changed files with 2477 additions and 0 deletions
+4
View File
@@ -660,6 +660,10 @@ menu "LVGL configuration"
endmenu
menu "Extra components"
config LV_USE_ANIMIMG
bool "Anim image."
select LV_USE_IMG
default y if !LV_CONF_MINIMAL
config LV_USE_CALENDAR
bool "Calendar."
default y if !LV_CONF_MINIMAL
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

@@ -0,0 +1,23 @@
#include "../../lv_examples.h"
#if LV_USE_ANIMIMG && LV_BUILD_EXAMPLES
LV_IMG_DECLARE(anim001)
LV_IMG_DECLARE(anim002)
LV_IMG_DECLARE(anim003)
static const lv_img_dsc_t* anim_imgs[3] = {
&anim001,
&anim002,
&anim003,
};
void lv_example_animimg(void)
{
lv_obj_t * animimg0 = lv_animimg_create(lv_scr_act());
lv_obj_set_pos(animimg0, 189, 79);
lv_animimg_set_src(animimg0, (lv_img_dsc_t**) anim_imgs, 3);
lv_animimg_set_duration(animimg0, 1000);
lv_animimg_set_repeat_count(animimg0, 3000);
lv_animimg_start(animimg0);
}
#endif
+2
View File
@@ -28,6 +28,8 @@ extern "C" {
void lv_example_arc_1(void);
void lv_example_arc_2(void);
void lv_example_animimg(void);
void lv_example_bar_1(void);
void lv_example_bar_2(void);
void lv_example_bar_3(void);
+2
View File
@@ -371,6 +371,8 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#define LV_USE_ARC 1
#define LV_USE_ANIMIMG 1
#define LV_USE_BAR 1
#define LV_USE_BTN 1
+176
View File
@@ -0,0 +1,176 @@
/**
* @file lv_animimg.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_animimg.h"
#if LV_USE_ANIMIMG != 0
/*Testing of dependencies*/
#if LV_USE_IMG == 0
#error "lv_animimg: lv_img is required. Enable it in lv_conf.h (LV_USE_IMG 1) "
#endif
#include "../../../misc/lv_assert.h"
#include "../../../draw/lv_img_decoder.h"
#include "../../../misc/lv_fs.h"
#include "../../../misc/lv_txt.h"
#include "../../../misc/lv_math.h"
#include "../../../misc/lv_log.h"
#include "../../../misc/lv_anim.h"
/*********************
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_animimg"
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void index_change(lv_obj_t * obj, int32_t index);
static void lv_animimg_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
/**********************
* STATIC VARIABLES
**********************/
const lv_obj_class_t lv_animimg_class = {
.constructor_cb = lv_animimg_constructor,
.instance_size = sizeof(lv_animimg_t),
.base_class = &lv_img_class
};
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Create an animation image objects
* @param par pointer to an object, it will be the parent of the new animation image
* @param copy pointer to a image object, if not NULL then the new object will be copied from it
* @return pointer to the created animation image
*/
lv_obj_t * lv_animimg_create(lv_obj_t * parent)
{
LV_LOG_INFO("begin")
return lv_obj_create_from_class(&lv_animimg_class, parent);
}
/**
* Set the animation images source.
* @param img pointer to an animation image object
* @param dsc pointer to a series images
* @param num images' number
*/
void lv_animimg_set_src(lv_obj_t * obj, lv_img_dsc_t ** dsc, uint8_t num)
{
lv_animimg_t * animimg = (lv_animimg_t *)obj;
animimg->dsc = dsc;
animimg->pic_count = num;
lv_anim_set_values(&animimg->anim, 0 , num);
}
/**
* Startup the image animation.
* @param img pointer to an animation image object
*/
void lv_animimg_start(lv_obj_t * obj)
{
lv_animimg_t * animimg = (lv_animimg_t *)obj;
lv_anim_start(&animimg->anim);
}
/*=====================
* Setter functions
*====================*/
/**
* Set the image animation wait before repeat. unit:ms
* @param img pointer to an animation image object
*/
void lv_animimg_set_repeat_delay(lv_obj_t * obj, uint32_t delay)
{
lv_animimg_t * animimg = (lv_animimg_t *)obj;
animimg->anim.repeat_delay = delay;
}
/**
* Set the image animation duration time. unit:ms
* @param img pointer to an animation image object
*/
void lv_animimg_set_duration(lv_obj_t * obj, uint32_t duration)
{
lv_animimg_t * animimg = (lv_animimg_t *)obj;
lv_anim_set_time(&animimg->anim, duration);
lv_anim_set_playback_time(&animimg->anim, duration);
}
/**
* Set the image animation reapeatly play times.
* @param img pointer to an animation image object
*/
void lv_animimg_set_repeat_count(lv_obj_t * obj, uint16_t count)
{
lv_animimg_t * animimg = (lv_animimg_t *)obj;
lv_anim_set_repeat_count(&animimg->anim, count);
}
/*=====================
* Getter functions
*====================*/
/**********************
* STATIC FUNCTIONS
**********************/
static void lv_animimg_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
{
LV_TRACE_OBJ_CREATE("begin");
LV_UNUSED(class_p);
lv_animimg_t * animimg = (lv_animimg_t *)obj;
animimg->dsc = NULL;
animimg->pic_count = -1;
//initial animation
lv_anim_init(&animimg->anim);
lv_anim_set_var(&animimg->anim, obj);
lv_anim_set_time(&animimg->anim, 30);
lv_anim_set_exec_cb(&animimg->anim, (lv_anim_exec_xcb_t)index_change);
lv_anim_set_values(&animimg->anim, 0 , 1);
lv_anim_set_playback_time(&animimg->anim, 100);
lv_anim_set_repeat_count(&animimg->anim, LV_ANIM_REPEAT_INFINITE);
}
/**
* Handle the drawing related tasks of the images
* @param img pointer to an image animationobject
* @param clip_area the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return an element of `lv_design_res_t`
*/
static void index_change(lv_obj_t * obj, int32_t index)
{
lv_coord_t idx;
lv_animimg_t * animimg = (lv_animimg_t *)obj;
idx = index % animimg->pic_count;
lv_img_set_src(obj, animimg->dsc[idx]);
}
#endif
+104
View File
@@ -0,0 +1,104 @@
/**
* @file lv_animimg.h
*
*/
#ifndef LV_ANIM_IMG_H
#define LV_ANIM_IMG_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../../lvgl.h"
#if LV_USE_ANIMIMG != 0
#include "../../../misc/lv_anim.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of image*/
typedef struct {
lv_img_t img;
lv_anim_t anim;
/*picture sequence */
lv_img_dsc_t **dsc;
int8_t pic_count;
} lv_animimg_t;
/*Image parts*/
enum {
LV_ANIM_IMG_PART_MAIN,
};
typedef uint8_t lv_animimg_part_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create an animation image objects
* @param par pointer to an object, it will be the parent of the new button
* @param copy pointer to a image object, if not NULL then the new object will be copied from it
* @return pointer to the created animation image object
*/
lv_obj_t * lv_animimg_create(lv_obj_t * parent);
/**
* Startup the image animation.
* @param img pointer to an animation image object
*/
void lv_animimg_start(lv_obj_t * obj);
/*=====================
* Setter functions
*====================*/
/**
* Set the image animation duration time. unit:ms
* @param img pointer to an animation image object
*/
void lv_animimg_set_duration(lv_obj_t * img, uint32_t duration);
/**
* Set the image animation wait before repeat. unit:ms
* @param img pointer to an animation image object
*/
void lv_animimg_set_repeat_delay(lv_obj_t * img, uint32_t delay);
/**
* Set the image animation images source.
* @param img pointer to an animation image object
* @param dsc pointer to a series images
* @param num images' number
*/
void lv_animimg_set_src(lv_obj_t * img, lv_img_dsc_t ** dsc, uint8_t num);
/**
* Set the image animation reapeatly play times.
* @param img pointer to an animation image object
*/
void lv_animimg_set_repeat_count(lv_obj_t * img, uint16_t count);
/*=====================
* Getter functions
*====================*/
#endif /*LV_USE_ANIMIMG*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_ANIM_IMG_H*/
+1
View File
@@ -13,6 +13,7 @@ extern "C" {
/*********************
* INCLUDES
*********************/
#include "animimg/lv_animimg.h"
#include "calendar/lv_calendar.h"
#include "calendar/lv_calendar_header_arrow.h"
#include "calendar/lv_calendar_header_dropdown.h"
+8
View File
@@ -1072,6 +1072,14 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
# endif
#endif
#ifndef LV_USE_ANIMIMG
# ifdef CONFIG_LV_USE_ANIMIMG
# define LV_USE_ANIMIMG CONFIG_LV_USE_ANIMIMG
# else
# define LV_USE_ANIMIMG 1
# endif
#endif
#ifndef LV_USE_BAR
# ifdef CONFIG_LV_USE_BAR
# define LV_USE_BAR CONFIG_LV_USE_BAR