Files
luban-lite-t3e-pro/packages/artinchip/lvgl-ui/aic_demo/gif_demo/gif_ui.c

52 lines
942 B
C
Raw Normal View History

2024-01-27 08:47:24 +08:00
/*
2024-09-03 11:16:08 +08:00
* Copyright (C) 2022-2024 ArtInChip Technology Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
2024-01-27 08:47:24 +08:00
* Authors: Ning Fang <ning.fang@artinchip.com>
*/
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include "lvgl.h"
#include "gif_ui.h"
2024-09-03 11:16:08 +08:00
static int end_flag = 0;
2024-01-27 08:47:24 +08:00
static void gif_event(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
if (code == LV_EVENT_READY) {
2024-09-03 11:16:08 +08:00
end_flag = 1;
2024-01-27 08:47:24 +08:00
}
}
2024-09-03 11:16:08 +08:00
int gif_check_finish()
{
return end_flag;
}
void gif_ui_init()
2024-01-27 08:47:24 +08:00
{
lv_obj_t * img;
img = lv_gif_create(lv_scr_act());
2024-09-03 11:16:08 +08:00
lv_gif_set_src(img, LVGL_PATH(gif/bulb.gif));
2024-01-27 08:47:24 +08:00
2024-09-03 11:16:08 +08:00
printf("path:%s\n", LVGL_PATH(gif/bulb.gif));
2024-01-27 08:47:24 +08:00
// must call after lv_gif_set_src
lv_gif_set_loop_count(img, 1);
lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
2024-09-03 11:16:08 +08:00
lv_obj_add_event_cb(img, gif_event, LV_EVENT_ALL, NULL);
2024-01-27 08:47:24 +08:00
printf("gif_ini_ok\n");
}
2024-11-26 13:23:39 +08:00
void ui_init(void)
{
gif_ui_init();
}