LV_IMAGE_DECLARE(animimg001);
LV_IMAGE_DECLARE(animimg002);
LV_IMAGE_DECLARE(animimg003);
static const lv_image_dsc_t * anim_imgs[3] = {
& animimg001,
& animimg002,
& animimg003,
};
int main(int argc, char *argv[])
{
lv_init();
lv_display_t * disp = lv_linux_fbdev_create();
lv_linux_fbdev_set_file(disp, "/dev/fb0");
indev_keypad = lv_indev_create();
lv_indev_set_type(indev_keypad, LV_INDEV_TYPE_KEYPAD);
lv_indev_set_read_cb(indev_keypad, keypad_read);
group = lv_group_create();
lv_indev_set_group(indev_keypad, group); //将组绑定到输入设备
lv_obj_t * animimg0 = lv_animimg_create(lv_screen_active());
lv_obj_center(animimg0);
lv_animimg_set_src(animimg0, (const void **) anim_imgs, 3);
lv_animimg_set_duration(animimg0, 1000);
lv_animimg_set_repeat_count(animimg0, LV_ANIM_REPEAT_INFINITE);
lv_animimg_start(animimg0);
/*Handle LVGL tasks*/
while(1) {
lv_timer_handler();
usleep(5000);
}
}
在上面的代码中 如果不执行
indev_keypad = lv_indev_create();
lv_indev_set_type(indev_keypad, LV_INDEV_TYPE_KEYPAD);
lv_indev_set_read_cb(indev_keypad, keypad_read);
group = lv_group_create();
lv_indev_set_group(indev_keypad, group); //将组绑定到输入设备
这部分代码,则动画正常播放,但如果执行了这段代码,就会导致动画无法自动播放。实际的效果是,物理键盘每次按键,动画图片才会切换一张。这是为什么? 有什么解决办法?