How to properly declare image as screen-background and avoid it "memorizing" changes after reset


I set an image as the background of an LVGL-screen. On the physical display is the same image, so everytime something is added to the background (LVGL-screen) it’s written to the display. The problem is that the screen “memorizes” the changes made even after a system-reset, when the image it’s referring to is renewed (copied from an SD-card). How to properly declare the LVGL-image to reset the changes?

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


What LVGL version are you using?


What do you want to achieve?

Declare an image as screen-background and be able to start with a “clean slate” after a system-reset

What have you tried so far?

Declared lv_img_dsc_t as const, static, globally, locally,…

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:

#define DISP_WIDTH 1440
#define DISP_HEIGHT 900

static lv_img_dsc_t BB_Background_Image; // globally defined
static uint16_t u16_noBootDeviceLogo[NUM_PIXELS] // array to be displayed
static u8_bootscreen_lvglBackground[NUM_PIXELS*3] // array for the LVGL-screen-image

...initialize LVGL and copy data from SD-card to u16_noBootDeviceLogo
Then call the following functions

/* Transform uint16-RGB565-array to LVGL-compatible image an copy it */
void lvgl_create_bootscreen_backGround (void)
	uint32_t j = 0;

	// Turn boot-background to uint8 to be compatible with LVGL
	for (int i = 0; i < NUM_PIXELS*2; i=i+2)
		u8_bootscreen_lvglBackground[i] = u16_noBootDeviceLogo[j] & 0xFF; // Copy Low Byte
		u8_bootscreen_lvglBackground[i+1] = u16_noBootDeviceLogo[j] >> 8; // Copy High Byte

	// Copy alpha channel to array
	memset(&u8_bootscreen_lvglBackground[NUM_PIXELS*2], 0xFF, NUM_PIXELS);

void lvgl_set_parent_backGround (void)
    // Set data of the LVGL-image-struct: = LV_IMG_CF_RGB565A8;
    BB_Background_Image.header.always_zero = 0;
    BB_Background_Image.header.reserved = 0;
    BB_Background_Image.header.w = DISP_WIDTH;
    BB_Background_Image.header.h = DISP_HEIGHT;
    BB_Background_Image.data_size = NUM_PIXELS*3; // screen-pixels + alpha-channel = u8_bootscreen_lvglBackground;

    // Create new screen with image as background:
    parent_bootScreen_backGround = lv_obj_create(NULL);
    lv_obj_t * obj = lv_img_create(parent_bootScreen_backGround);
    lv_img_set_src(obj, &BB_Background_Image);

    // Load the new screen

SOLVED: Stupid me…I declared the LVGL-background image chronologically before it was copied from the SD-card to the external RAM. So the old image, that has been edited before the reset was used as background