jiamin
1
Description
i want to rotation the image always.would you give some guidance?
The code block(s) should be formatted like:
void loading_test()
{
lv_obj_clean(lv_scr_act());
lv_obj_t* page = lv_page_create(lv_scr_act(), NULL);
lv_obj_set_size(page, 320, 224);
lv_obj_align(page, NULL, LV_ALIGN_CENTER, 0, 10);
lv_page_set_scrlbar_mode(page, LV_SCRLBAR_MODE_DRAG);
/*lv_obj_t* Title = lv_label_create(page, NULL);
lv_label_set_text(Title, "PROCESSING");
lv_obj_set_size(Title, 320, 10);
lv_obj_align(Title, page, LV_ALIGN_IN_TOP_MID, 0, 0);
lv_obj_set_style_local_bg_color(Title, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLUE);
lv_obj_set_style_local_bg_opa(Title, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_obj_t* Promt = lv_label_create(page, NULL);
lv_label_set_text(Promt, "connecting to server...");
lv_obj_set_size(Promt, 320, 10);
lv_obj_align(Promt, page, LV_ALIGN_IN_TOP_MID, 0, 30);*/
lv_obj_t* loading = lv_img_create(page, NULL);
lv_img_set_src(loading, &lv_Icon_loading);
lv_obj_align(loading, page, LV_ALIGN_IN_TOP_MID, 0, 60);
lv_img_set_pivot(loading, 0, 80);
lv_img_set_angle(loading, 3600);
}
Screenshot and/or video
Set the rotation angle of the image
by the way,i have used the same imge as yours.
if you want it rotationing all the time,you need a task to called lv_img_set_angle(loading, angle);
jiamin
3
void loading_test()
{
lv_obj_clean(lv_scr_act());
lv_obj_t* page = lv_page_create(lv_scr_act(), NULL);
lv_obj_set_size(page, 320, 224);
lv_obj_align(page, NULL, LV_ALIGN_CENTER, 0, 10);
lv_page_set_scrlbar_mode(page, LV_SCRLBAR_MODE_DRAG);
/*lv_obj_t* Title = lv_label_create(page, NULL);
lv_label_set_text(Title, "PROCESSING");
lv_obj_set_size(Title, 320, 10);
lv_obj_align(Title, page, LV_ALIGN_IN_TOP_MID, 0, 0);
lv_obj_set_style_local_bg_color(Title, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLUE);
lv_obj_set_style_local_bg_opa(Title, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_obj_t* Promt = lv_label_create(page, NULL);
lv_label_set_text(Promt, "connecting to server...");
lv_obj_set_size(Promt, 320, 10);
lv_obj_align(Promt, page, LV_ALIGN_IN_TOP_MID, 0, 30);*/
lv_obj_t* loading = lv_img_create(page, NULL);
lv_img_set_src(loading, &lv_Icon_loading);
lv_obj_align(loading, page, LV_ALIGN_IN_TOP_MID, 0, 60);
lv_img_set_pivot(loading, 0, 80);
while (1)
{
lv_img_set_angle(loading, 3600);
}
}
void ui_create(void )
{
...
...
...
imge_rotatin_handle = lv_task_create(imge_rotatin_cb,10,LV_TASK_PRIO_LOW,NULL);
}
void imge_rotatin_cb(lv_obj_t* obj, lv_event_t event)
{
static uint8_t temp_count=0;
static uint16_t step_count=0;
temp_count++;
if(temp_count>=1)//rotatin speed
{
temp_count=0;
step_count++;
lv_img_set_angle(icon_img,step_count*60);
if(step_count>=60)
{
step_count=0;
lv_task_del(imge_rotatin_handle );
}
}
}
jiamin
6
Thanks a lot.it is my expect