How to create a log page to show some log when a system run?


I want to create a page which consists a textarea, then I want to print some logs when a system is running. I don’t want to opreating memory frequently(like malloc ). But it doesn’t work, it only can show it current log.

Is there any other solutions besides textarea?

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

ARM 335X

What do you want to achieve?

What have you tried so far?

Code to reproduce

static uint32_t logidx;

/*\brief PrintHmiLog
 *      打印HMIlog信息
void PrintHmiLog(char* log)
    char idx[LOG_LEN];
    snprintf(idx, LOG_LEN, "%d", logidx);
    strcat(idx, log);
    strcat(idx, "\n");
    lv_ta_set_text(ta_log, idx);

/*\brief btn_event_cb
static void btn_event_cb(lv_obj_t* btn, lv_event_t event)
    if (event != LV_EVENT_CLICKED)

    lv_obj_set_hidden(page_hmilog, true);

bool create_hmilog_page(lv_obj_t* parent)
    page_hmilog = lv_page_create(parent, NULL);
    lv_obj_set_size(page_hmilog, 1024, 600);
    lv_page_set_sb_mode(page_hmilog, LV_SB_MODE_AUTO);
    lv_page_set_style(page_hmilog, LV_PAGE_STYLE_BG, &style_generalpage);
    lv_page_set_style(page_hmilog, LV_PAGE_STYLE_SCRL, &style_generalpage);

    ta_log = lv_ta_create(page_hmilog, NULL);
    lv_ta_set_text(ta_log, "");
    lv_obj_set_size(ta_log, 900, 600);

    lv_obj_t* btn = lv_btn_create(page_hmilog, NULL);
    lv_obj_set_size(btn, 32, 32);
    lv_obj_align(btn, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
    lv_obj_set_event_cb(btn, btn_event_cb);
    lv_obj_t* label = lv_label_create(btn, NULL);
    lv_label_set_text(label, LV_SYMBOL_CLOSE);

    lv_obj_set_hidden(page_hmilog, true);

    logidx = 0;

    return true;

Screenshot and/or video

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

The only built-in objects that can display text in the manner you want are the text area and label objects.