This issue is for LVGL 8
I have an animation that creates a flashing effect (for alarms), the animation loops infinitely, with the intention to delete the animation when the alarm clears, returning to the rest state.
The flash animation works perfectly, however calling lv_anim_del()
returns false everytime, indicating the animation is not deleted, and indeed the flashing continues.
The stop, start and animation cb code:
bool colourAnimating;
lv_anim_t colourAnimation;
static void anim_x_cb(void * var, int32_t bgColour){
lv_obj_set_style_bg_color(statusLeft, lv_color_hex(bgColour), LV_PART_MAIN);
lv_obj_set_style_bg_color(statusCenter, lv_color_hex(bgColour), LV_PART_MAIN);
lv_obj_set_style_bg_color(statusRight, lv_color_hex(bgColour), LV_PART_MAIN);
}
if(flash && !colourAnimating){//start flash animation
LV_LOG_USER("Start the header flashing animation\n");
colourAnimating = true;
lv_anim_init(&colourAnimation);
lv_anim_set_var(&colourAnimation, statusCenter);
lv_anim_set_exec_cb(&colourAnimation, anim_x_cb);
lv_anim_set_values(&colourAnimation, lv_color_to32(lv_palette_darken(LV_PALETTE_GREY, 3)), lv_color_to32(bgColour));
lv_anim_set_time(&colourAnimation, 750);
lv_anim_set_repeat_count(&colourAnimation, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_path_cb(&colourAnimation, lv_anim_path_step);
lv_anim_set_repeat_delay(&colourAnimation, 750);
lv_anim_start(&colourAnimation);
} else if (!flash) { //stop flash animation
colourAnimating = false;
bool success = lv_anim_del(&colourAnimation, anim_x_cb);
LV_LOG_USER("Stop the header flashing animation, %s\n", success ? "Deleted" : "Not Deleted");
lv_anim_set_values(&colourAnimation, lv_color_to32(lv_palette_darken(LV_PALETTE_GREY, 3)), lv_color_to32(lv_palette_darken(LV_PALETTE_GREY, 3)));
lv_obj_set_style_bg_color(statusLeft, lv_palette_darken(LV_PALETTE_GREY, 3), LV_PART_MAIN);
lv_obj_set_style_bg_color(statusCenter, lv_palette_darken(LV_PALETTE_GREY, 3), LV_PART_MAIN);
lv_obj_set_style_bg_color(statusRight, lv_palette_darken(LV_PALETTE_GREY, 3), LV_PART_MAIN);
}
I have tried a couple of options to get the same affect, such as calling:
lv_anim_set_values(&colourAnimation, lv_color_to32(lv_palette_darken(LV_PALETTE_GREY, 3)), lv_color_to32(lv_palette_darken(LV_PALETTE_GREY, 3)));
to make the start and stop colours the same, this too does not work.
Any help would be greatly appreciated. Thanks.