I directly create a canvas in the page, and create an animation with following code:
static void func(void * var, lv_anim_value_t value)
{
lv_obj_t * canvas = (lv_obj_t *)var;
lv_canvas_rotate(canvas, &qq, value, 0, 0, CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2);
}
lv_obj_t * canvas = lv_canvas_create(sb, NULL);
static lv_color_t buffer[LV_CANVAS_BUF_SIZE_TRUE_COLOR_ALPHA(CANVAS_WIDTH, CANVAS_HEIGHT)];
lv_canvas_set_buffer(canvas, buffer, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR_ALPHA);
lv_canvas_draw_img(canvas, 10, 10, &qq, &style1);
//lv_canvas_rotate(canvas, &qq, 0, 0, 0, CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2);
lv_anim_t a;
lv_anim_set_exec_cb(&a, canvas, func); /*Set the animator function and variable to animate*/
lv_anim_set_time(&a, 10*1000, 0);
lv_anim_set_values(&a, 0, 359); /*Set start and end values. E.g. 0, 150*/
lv_anim_set_path_cb(&a, lv_anim_path_linear); /*Set path from `lv_anim_path_...` functions or a custom one.*/
//lv_anim_set_ready_cb(&a, ready_cb); /*Set a callback to call then animation is ready. (Optional)*/
//lv_anim_set_playback(&a, 0); /*Enable playback of teh animation with `wait_time` delay*/
lv_anim_set_repeat(&a, 0); /*Enable repeat of teh animation with `wait_time` delay. Can be compiled with playback*/
lv_anim_create(&a);
The problem is the image rotating take too much times, cause other controls become a little slow(response delays).
how to solve it?? Maybe i can put the rotating operation into another worker thread?
Is there any better way??