LVGL screen lagging issue

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the FAQ and read the relevant part of the documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.

Description

What MCU/Processor/Board and compiler are you using?

MCU - MIMX RT1176

What LVGL version are you using?

8.3

What do you want to achieve?

We are receiving image hex data from UART and want to display images faster (like 3 images per second) without hanging or delay during runtime.

What have you tried so far?

  1. Copying received data to the image descriptor variable .data
    lv_img_dsc_t img_des_;
    memcpy((uint8_t *)img_des_.data, rcvdImgData, sizeof(rcvdImgData));

2 Tried lv_img_cache_invalidate_src(&img_des_);

3, Enabled
#define LV_MEM_CUSTOM 1

  1. #define LV_IMG_CACHE_DEF_SIZE 4

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

void setup_scr_screen(lv_ui *ui)
{
	//Write codes screen
	ui->screen = lv_obj_create(NULL);
	lv_obj_set_size(ui->screen, 800, 480);
	lv_obj_set_scrollbar_mode(ui->screen, LV_SCROLLBAR_MODE_OFF);
 
	//Write style for screen, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
	lv_obj_set_style_bg_opa(ui->screen, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
	lv_obj_set_style_bg_color(ui->screen, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
 
	//LV_USE_PNG
	lv_png_init();
 
	arr = malloc(640*480*4);
	if(arr == NULL)
	{
		while(1)
		{
 
		}
	}
	img_des_.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA;
	img_des_.header.always_zero = 0;
	img_des_.header.reserved = 0;
	img_des_.header.w = 640;
	img_des_.header.h = 480;
	img_des_.data_size = 640*480*4; 
	img_des_.data = arr;
 
	//Update current screen layout.
	lv_obj_update_layout(ui->screen);
}
 
uint8_t screen_flag;
 
void change_screen(lv_ui *ui)
{
	if(update) //when image data is received completely Set update flag =1
	{
		memcpy((uint8_t *)img_des_.data, rcvdImgData, sizeof(rcvdImgData));  //rcvdImgData = Recieved data from UART
 
		ui->screen_img_1 = lv_img_create(ui->screen);
		lv_obj_add_flag(ui->screen_img_1, LV_OBJ_FLAG_CLICKABLE);
		lv_img_set_src(ui->screen_img_1, &img_des_);
		lv_img_set_pivot(ui->screen_img_1, 50,50);
		lv_img_set_angle(ui->screen_img_1, 0);
		lv_obj_set_pos(ui->screen_img_1, 0, 0);
		lv_obj_set_size(ui->screen_img_1, img_des_.header.w, img_des_.header.h);
		lv_obj_set_scrollbar_mode(ui->screen_img_1, LV_SCROLLBAR_MODE_OFF);
 
		//Write style for screen_img_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
		lv_obj_set_style_img_opa(ui->screen_img_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
 
 
		// Invalidate the cache of the image source
		lv_img_cache_invalidate_src(&img_des_);
 
		lv_img_set_src(ui->screen_img_1, &img_des_);
		lv_obj_center(ui->screen_img_1);
 
		lv_obj_set_style_img_opa(ui->screen_img_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
		lv_obj_update_layout(ui->screen);
 
		update = 0;
		recvFlag = 1;
 
		SCB_EnableDCache();  //Disabled before recieving data from UART , Enable after image update
		SCB_EnableICache();
	}
 
 
	if(screen_flag)
	{
		lv_obj_set_style_bg_color(ui->screen, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
	}
}

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

@kisvegabor

Thanks
Akhil

Hi,

For i.MX RT 1176 we found that moving the code to RAM helps a lot. (Project settings → C/C++ Build → Settings → Linker settings)