How to stop the animation image at the last image

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the FAQ and read the relevant part of the documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.


What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/
#include "../../lv_examples.h"

static const lv_img_dsc_t * anim_imgs[3] = {

void lv_example_animimg_1(void)
    lv_obj_t * animimg0 = lv_animimg_create(lv_scr_act());
    lv_animimg_set_src(animimg0, (lv_img_dsc_t **) anim_imgs, 3);
    lv_animimg_set_duration(animimg0, 1000);
    lv_animimg_set_repeat_count(animimg0, 0);


## Screenshot and/or video
If possible, add screenshots and/or videos about the current state.

Did you try to set

lv_animimg_set_repeat_count(animimg0, 1);

instead of

lv_animimg_set_repeat_count(animimg0, 0);


Yes , it also stop at the first image

It’s a bug in lv_animing here:

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 - 1);   /*Add -1 here*/

I’ve pushed a fix.

Can you see the topic of “How to stop the animation opa at the last opa value?”. I think the opa issue maybe is same as this one.