Hello,
I’m a hobbyist and just found littlevgl thanks for sharing.
I have a nanopi neo2 with a 1.8" ST7735 LCD setup as /dev/fb0
I managed to display some text and image on the lcd using the library.
The library is overkill for what I wanted to do with my nanopi since I have
a tiny screen but it’s working for me. I have a 5 images that I would like
to animate in a loop sort of like an animated gif. If it is possible, how can I do it?
I have converted all 5 images to C array with the online converter.
This code should do what you’re looking for. It uses the task system which calls my_image_looper over and over every second. You can adjust the frequency if you wish.
static int img_index = 0;
static void my_image_looper(void *custom_ptr)
{
lv_img_set_src(img_obj, <your image>); /* Set the next image */
img_index++;
if(img_index == 5)
img_index = 0;
}
lv_task_create(my_image_looper, 1000, LV_TASK_PRIO_LOWEST, NULL);
Thanks. I’m going to try it, but I’m not clear with
setting the next image. The images are in separate C files.
Do I need to create an array of image descriptor and cycle through it?
What I really want to do is make something like a preloader.
Like when I read a sensor and it takes time, analogous to “hour glass” on pc :).
Edit:
I’ve tried it works for a few seconds then it freezes,
with 100% CPU usage.
I’m using the dev-6.0 of the library, I figured if it’s going to be released soon I might as well use that version.
I couldn’t find the definition of lv_img_t but
I found this lv_img_dsc_t
Hi,How about your project,I have same project which need Images as animation,I edit my code like up,But it works for a few seconds then it freezes, I do not know where is wrong?(I use the dev-5.3 of the library)
Thanks I’ll get back to you on that.
I’m recompiling the kernel to go back to fbtft, I tried to tinker
with tinydrm but couldn’t get it to work.
It’s going to take a while, I think my nanopi neo2 is faster than my pc
(void)param;
lv_img_dsc_t const *my_images[] = {
&img1,
&img2,
&img3,
&img4,
&img5
};
static int img_index = 0;
lv_obj_t * img_loop = lv_img_create(lv_scr_act(), NULL); /*Create an image object*/
lv_obj_set_pos(my_images, 60, 50);
lv_img_set_src(img_loop, my_images[img_index]); /* Set the next image */
img_index++;
if(img_index == 5)
img_index = 0;
}
I think I’m doing it wrong.
The parameter for the creation of task seems different from 5.3 to 6.0.
If I use void *ptr for the callback parameter the compiler complains and says
I should be using lv_task_t pointer type. And so I did. Then of-course I don’t know what to do with that
Sorry for the delay…My project can work normally,it is myself problem,I malloc some memory for every img,but i forget free them, so after it works some time, it freeze.So you can check your code if these is the same problem.
I’ve just tried it in the simulator and it’s the same thing.
It works for a few seconds and it freezes.
I had to do it in the console via make, eclipse is not cooperating with me.
@oldersu I didn’t do any malloc, I just have my images as arrays converted online.