init lvgl code
This commit is contained in:
7
LVGL.Simulator/lvgl/examples/widgets/animimg/index.rst
Normal file
7
LVGL.Simulator/lvgl/examples/widgets/animimg/index.rst
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
Simple Animation Image
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/animimg/lv_example_animimg_1
|
||||
:language: c
|
||||
:description: A simple example to demonstrate the use of an animation image.
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_ANIMIMG && LV_BUILD_EXAMPLES
|
||||
LV_IMG_DECLARE(animimg001)
|
||||
LV_IMG_DECLARE(animimg002)
|
||||
LV_IMG_DECLARE(animimg003)
|
||||
|
||||
static const lv_img_dsc_t * anim_imgs[3] = {
|
||||
&animimg001,
|
||||
&animimg002,
|
||||
&animimg003,
|
||||
};
|
||||
|
||||
void lv_example_animimg_1(void)
|
||||
{
|
||||
lv_obj_t * animimg0 = lv_animimg_create(lv_scr_act());
|
||||
lv_obj_center(animimg0);
|
||||
lv_animimg_set_src(animimg0, (lv_img_dsc_t **) anim_imgs, 3);
|
||||
lv_animimg_set_duration(animimg0, 1000);
|
||||
lv_animimg_set_repeat_count(animimg0, LV_ANIM_REPEAT_INFINITE);
|
||||
lv_animimg_start(animimg0);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
from imagetools import get_png_info, open_png
|
||||
|
||||
# Register PNG image decoder
|
||||
decoder = lv.img.decoder_create()
|
||||
decoder.info_cb = get_png_info
|
||||
decoder.open_cb = open_png
|
||||
|
||||
anim_imgs = [None]*3
|
||||
# Create an image from the png file
|
||||
try:
|
||||
with open('../../assets/animimg001.png','rb') as f:
|
||||
anim001_data = f.read()
|
||||
except:
|
||||
print("Could not find animimg001.png")
|
||||
sys.exit()
|
||||
|
||||
anim_imgs[0] = lv.img_dsc_t({
|
||||
'data_size': len(anim001_data),
|
||||
'data': anim001_data
|
||||
})
|
||||
|
||||
try:
|
||||
with open('../../assets/animimg002.png','rb') as f:
|
||||
anim002_data = f.read()
|
||||
except:
|
||||
print("Could not find animimg002.png")
|
||||
sys.exit()
|
||||
|
||||
anim_imgs[1] = lv.img_dsc_t({
|
||||
'data_size': len(anim002_data),
|
||||
'data': anim002_data
|
||||
})
|
||||
|
||||
try:
|
||||
with open('../../assets/animimg003.png','rb') as f:
|
||||
anim003_data = f.read()
|
||||
except:
|
||||
print("Could not find animimg003.png")
|
||||
sys.exit()
|
||||
|
||||
anim_imgs[2] = lv.img_dsc_t({
|
||||
'data_size': len(anim003_data),
|
||||
'data': anim003_data
|
||||
})
|
||||
|
||||
animimg0 = lv.animimg(lv.scr_act())
|
||||
animimg0.center()
|
||||
animimg0.set_src(anim_imgs, 3)
|
||||
animimg0.set_duration(1000)
|
||||
animimg0.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
|
||||
animimg0.start()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user