Description
When an img widget showing after it hidden very short term may cause the some content missing.
What MCU/Processor/Board and compiler are you using?
arm
What LVGL version are you using?
8.0.1
What do you want to achieve?
Hide an img widget, and subsquently update an image to it and show it, correct content is displayed. Any solutions or suggetions would be appreciated.
What have you tried so far?
- canvas widget also has the same problem.
- The problem is caused by the mechanism of refreshing:
When lv_img_set_src is called, nothing redrawing is happened until lv_task_handler is called.
- While showing the img widget after a short term, seems it’s states are confused?
- lv_refr_now can sync the image content, but need to mutex between lv_task_handler, howerver it’s a good method, and lv_refr_now may cause crash( seems by timers’ list competition) .
Code to reproduce
hide an display a gray image.
const int SCR_WIDTH = 800;
const int SCR_HEIGHT = 1280;
uint8_t* img_data = (uint8_t*)malloc(SCR_WIDTH * SCR_HEIGHT * 4);
memset(img_data, 0x88, SCR_WIDTH * SCR_HEIGHT * 4);
lv_img_dsc_t img_dsc;
memset(&img_dsc, 0x0, sizeof(img_dsc));
img_dsc.header.w = SCR_WIDTH;
img_dsc.header.h = SCR_HEIGHT;
img_dsc.header.always_zero = 0;
img_dsc.header.cf = LV_IMG_CF_TRUE_COLOR;
img_dsc.data = img_data;
img_dsc.data_size = SCR_WIDTH * SCR_HEIGHT * 4;
lv_obj_t* img_widget = lv_img_create(lv_scr_act());
while (1) {
lv_obj_add_flag(img_widget, LV_OBJ_FLAG_HIDDEN);
usleep(10 * 1000);
lv_img_set_src(img_widget, &img_dsc);
lv_obj_clear_flag(img_widget, LV_OBJ_FLAG_HIDDEN);
sleep(2);
}
Screenshot and/or video
Partition of the image can be display while sleeping 2 seconds.