Container example not animate

Hi,

Description

The example in the link: “https://docs.littlevgl.com/en/html/object-types/cont.html#layout”, only print the full text container.
“Short text”
“It is a long text”
“Here is an even longer text”

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

ESP32

What do you want to achieve?

make the example work

What have you tried so far?

Code to reproduce

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "driver/gpio.h"
#include "esp_freertos_hooks.h"

#include "lvgl.h"


//#include "demo.h"



#include "disp_spi.h"
#include "ili9341.h"     
#include "tp_spi.h"
#include "xpt2046.h"    

static void IRAM_ATTR lv_tick_task(void);

void lv_ex_cont_1(void);


void app_main()
{
	lv_init();

	disp_spi_init();
	ili9341_init();

	tp_spi_init();
    xpt2046_init();

    static lv_color_t buf1[DISP_BUF_SIZE];
    static lv_color_t buf2[DISP_BUF_SIZE];
    static lv_disp_buf_t disp_buf;
    lv_disp_buf_init(&disp_buf, buf1, buf2, DISP_BUF_SIZE);

	lv_disp_drv_t disp_drv;
	lv_disp_drv_init(&disp_drv);
	disp_drv.flush_cb = ili9341_flush;
	disp_drv.buffer = &disp_buf;
	lv_disp_drv_register(&disp_drv);

    
	
	//Set TOUCH_SUPPORT on drv\component.mk to 1 if
    //your board have touch support
    //#if ENABLE_TOUCH_INPUT
    lv_indev_drv_t indev_drv;
    lv_indev_drv_init(&indev_drv);
    indev_drv.read_cb = xpt2046_read;
    indev_drv.type = LV_INDEV_TYPE_POINTER;
    lv_indev_drv_register(&indev_drv);
	//#endif
	


	esp_register_freertos_tick_hook(lv_tick_task);

	
	//demo_create();

	while(1)
    {
		lv_ex_cont_1();

		vTaskDelay(1);
		lv_task_handler();		
	}
}

////////////////////////////////////////////////////////
////////////////////////////////////////////////////////

static void IRAM_ATTR lv_tick_task(void)
{
	lv_tick_inc(portTICK_RATE_MS);
}

////////////////////////////////////////////////////////
////////////////////////////////////////////////////////


void lv_ex_cont_1(void)
{
    lv_obj_t * cont;

    cont = lv_cont_create(lv_scr_act(), NULL);
    lv_obj_set_auto_realign(cont, true);                    /*Auto realign when the size changes*/
    lv_obj_align_origo(cont, NULL, LV_ALIGN_CENTER, 0, 0);  /*This parametrs will be sued when realigned*/
    lv_cont_set_fit(cont, LV_FIT_TIGHT);
    lv_cont_set_layout(cont, LV_LAYOUT_COL_M);

    lv_obj_t * label;
    label = lv_label_create(cont, NULL);
    lv_label_set_text(label, "Short text");
	vTaskDelay(2000 / portTICK_PERIOD_MS);


    label = lv_label_create(cont, NULL);
    lv_label_set_text(label, "It is a long text");
	vTaskDelay(2000 / portTICK_PERIOD_MS);


    label = lv_label_create(cont, NULL);
    lv_label_set_text(label, "Here is an even longer text");
	vTaskDelay(2000 / portTICK_PERIOD_MS);
}

Screenshot and/or video

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

Please provide a screenshot of the current behavior, and explain the desired behavior in detail. From what you’ve described, I don’t know what’s wrong.

If you are expecting the container to resize like the animation in the documentation, it won’t. That screenshot is just so that you understand how the autofit feature works.

yes. i expected that.

There are two problems with your code:

  1. You are calling lv_ex_cont_1 and thus creating the container object over and over. You don’t need to do that.
  2. Putting a native delay function inside lv_ex_cont_1 will not work. The delay executes but lv_task_handler is not called. Instead, you should use an async callback to add a new label to the container.