当前位置:网站首页>Esp32 development -lvgl animation display

Esp32 development -lvgl animation display

2022-06-11 04:07:00 z_ Curtain

LVGL Animation

LVGL Support dynamic effects , Including dynamic switching screen , Component animation effects, etc .


Animation creation steps and API explain

In the official demo As an example of animation creation in

	// Define animation variables 
    lv_anim_t a; 
    // Initialize animation variables 
    lv_anim_init(&a);
    // Set the components to be animated 
    lv_anim_set_var(&a, gauge);
    // Animating features 
    lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)gauge_anim);
    // Set the start and end values of the animation 
    lv_anim_set_values(&a, 0, 100);
    // Set the duration of the animation 
    lv_anim_set_time(&a, 4000);
    // Set the animation playback time 
    lv_anim_set_playback_time(&a, 1000);
    // Number of animation repetitions 
    lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
    // Start the animation effect 
    lv_anim_start(&a);

Animation function lv_anim_set_exec_cb()

In routine , This function is equivalent to registering an animation callback function , Values and components during animation execution can be passed to the callback function as parameters ,gauge_anim It's the function name .

static void gauge_anim(lv_obj_t * gauge, lv_anim_value_t value)
{
    
    lv_gauge_set_value(gauge, 0, value);

    static char buf[64];
    lv_snprintf(buf, sizeof(buf), "%d", value);
    lv_obj_t * label = lv_obj_get_child(gauge, NULL);
    lv_label_set_text(label, buf);
    lv_obj_align(label, gauge, LV_ALIGN_IN_TOP_MID, 0, lv_obj_get_y(label));
}
原网站

版权声明
本文为[z_ Curtain]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020549199500.html