Set label long mode doesn't work

Description

I use label object to refresh some datas in a task, because data’s length is flexible, so I use function lv_label_set_static_text , and I set the long mode LV_LABEL_LONG_SCROLL_CIRC , but it doesn’t work. But If I put the document’s example code it works well. It confused me.

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

What do you want to achieve?

What have you tried so far?

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:

/*\brief clear_all_table_cells
 *      清除整个表格的所有单元格
 */
static void clear_all_table_cells(void)
{
    /* 清空序号 */
    for (int i = ALARMINFO_ROW1; i < ALARMINFO_ROWNUM; i++)
        lv_table_set_cell_value(AlarmInfoObj.AlarmInfoTable, i, ALARMINFO_COL1, "     ");

    for (int i = ALARM_1; i < ALARM_NUM; i++)
    {
        memset(AlarmInfoRuntime.EventTimeStr[i], 0, sizeof(AlarmInfoRuntime.EventTimeStr[i]));
        memset(AlarmInfoRuntime.EventPointStr[i], 0, sizeof(AlarmInfoRuntime.EventPointStr[i]));
        memset(AlarmInfoRuntime.EventTypeStr[i], 0, sizeof(AlarmInfoRuntime.EventTypeStr[i]));
        memset(AlarmInfoRuntime.EventDescStr[i], 0, sizeof(AlarmInfoRuntime.EventDescStr[i]));

        strncpy(AlarmInfoRuntime.EventTimeStr[i], "", MAX_NAME_LEN);
        strncpy(AlarmInfoRuntime.EventPointStr[i], "", MAX_NAME_LEN);
        strncpy(AlarmInfoRuntime.EventTypeStr[i], "", MAX_NAME_LEN);
        strncpy(AlarmInfoRuntime.EventDescStr[i], "", 4 * MAX_NAME_LEN);

        lv_label_set_static_text(AlarmInfoObj.EventTime[i], AlarmInfoRuntime.EventTimeStr[i]);
        lv_label_set_static_text(AlarmInfoObj.EventPoint[i], AlarmInfoRuntime.EventPointStr[i]);
        lv_label_set_static_text(AlarmInfoObj.EventType[i], AlarmInfoRuntime.EventTypeStr[i]);
        lv_label_set_static_text(AlarmInfoObj.EventDesc[i], AlarmInfoRuntime.EventDescStr[i]);

        lv_obj_set_hidden(AlarmInfoObj.AlarmLevelPage[i], true);
    }

}

/*\brief refresh_alarm_event_table
 *      
 */
static void refresh_alarm_event_table(void)
{
    /* 先清空缓存 */
    clear_all_table_cells();

    if (!gEvent.HMIEvent.cnt)
        return;

    /* 计算起始 */
    uint16_t start = ALARM_NUM * (PageFlag.CurPage - 1);

    /* 确定结束位置 */
    uint16_t refreshNum;
    if (PageFlag.CurPage == PageFlag.TotPage)
    {
        if (!(gEvent.HMIEvent.cnt % ALARM_NUM))
            refreshNum = ALARM_NUM;
        else
            refreshNum = gEvent.HMIEvent.cnt % ALARM_NUM;
    }
    else
        refreshNum = ALARM_NUM;

    /* 刷新表格, 写序号 */
    char tempsn[MAX_NAME_LEN];
    char TempModel[MAX_NAME_LEN];
    for (int i = ALARM_1; i < refreshNum; i++)
    {
        /* 设置属性,先改长模式,然后再设置宽度 */
        lv_label_set_long_mode(AlarmInfoObj.EventPoint[i], LV_LABEL_LONG_SROLL_CIRC);
        lv_label_set_long_mode(AlarmInfoObj.EventType[i], LV_LABEL_LONG_SROLL_CIRC);
        lv_label_set_long_mode(AlarmInfoObj.EventDesc[i], LV_LABEL_LONG_SROLL_CIRC);

        lv_obj_set_width(AlarmInfoObj.EventPoint[i], 210);
        lv_obj_set_width(AlarmInfoObj.EventType[i], 140);
        lv_obj_set_width(AlarmInfoObj.EventDesc[i], 440);

        /* 写入编号 */
        memset(tempsn, 0, sizeof(tempsn));
        snprintf(tempsn, MAX_NAME_LEN, "%5d", start + 1 +i);
        lv_table_set_cell_value(AlarmInfoObj.AlarmInfoTable,
                        ALARMINFO_ROW1 + i % ALARM_NUM,
                        ALARMINFO_COL1 + 4 * (i / ALARM_NUM), tempsn);

        /* 更新告警点位信息 */
        strncpy(AlarmInfoRuntime.EventPointStr[i], gEvent.HMIEvent.events[start + i].pointName, MAX_NAME_LEN);
        lv_label_set_static_text(AlarmInfoObj.EventPoint[i], AlarmInfoRuntime.EventPointStr[i]);

        /* 更新事件类型信息,转换成中文 */
        memset(TempModel, 0, sizeof(TempModel));
        eventmodel_str_deal(TempModel, gEvent.HMIEvent.events[start + i]);
        strncpy(AlarmInfoRuntime.EventTypeStr[i], TempModel, MAX_NAME_LEN);
        lv_label_set_static_text(AlarmInfoObj.EventType[i], AlarmInfoRuntime.EventTypeStr[i]);

        /* 更新事件描述 */
        strncpy(AlarmInfoRuntime.EventDescStr[i], gEvent.HMIEvent.events[start + i].stationName, MAX_NAME_LEN);
        strcat(AlarmInfoRuntime.EventDescStr[i], gEvent.HMIEvent.events[start + i].equipmentName);
        strcat(AlarmInfoRuntime.EventDescStr[i], gEvent.HMIEvent.events[start + i].logicDevName);
        lv_label_set_static_text(AlarmInfoObj.EventDesc[i], AlarmInfoRuntime.EventDescStr[i]);

    }

    /*TODO TEST */
    lv_label_set_long_mode(AlarmInfoObj.EventPoint[ALARM_10], LV_LABEL_LONG_SROLL_CIRC);
    lv_label_set_long_mode(AlarmInfoObj.EventType[ALARM_10], LV_LABEL_LONG_SROLL_CIRC);
    lv_label_set_long_mode(AlarmInfoObj.EventDesc[ALARM_10], LV_LABEL_LONG_SROLL_CIRC);

    lv_obj_set_width(AlarmInfoObj.EventPoint[ALARM_10], 210);
    lv_obj_set_width(AlarmInfoObj.EventType[ALARM_10], 140);
    lv_obj_set_width(AlarmInfoObj.EventDesc[ALARM_10], 440);

    lv_label_set_text(AlarmInfoObj.EventPoint[ALARM_10], "12344567890ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    lv_label_set_text(AlarmInfoObj.EventType[ALARM_10], "12344567890ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    lv_label_set_text(AlarmInfoObj.EventDesc[ALARM_10], "12344567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopq");

}

Screenshot and/or video

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

Could you send a very simple copy snippet to reproduce? I mean 5-10 line of code where you try only this feature.

the code is shown below.It should scroll circle but it never worked.

lv_label_set_long_mode(AlarmInfoObj.EventPoint[ALARM_10], LV_LABEL_LONG_SROLL_CIRC);
    lv_label_set_long_mode(AlarmInfoObj.EventType[ALARM_10], LV_LABEL_LONG_SROLL_CIRC);
    lv_label_set_long_mode(AlarmInfoObj.EventDesc[ALARM_10], LV_LABEL_LONG_SROLL_CIRC);

    lv_obj_set_width(AlarmInfoObj.EventPoint[ALARM_10], 210);
    lv_obj_set_width(AlarmInfoObj.EventType[ALARM_10], 140);
    lv_obj_set_width(AlarmInfoObj.EventDesc[ALARM_10], 440);

    lv_label_set_text(AlarmInfoObj.EventPoint[ALARM_10], "12344567890ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    lv_label_set_text(AlarmInfoObj.EventType[ALARM_10], "12344567890ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    lv_label_set_text(AlarmInfoObj.EventDesc[ALARM_10], "12344567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopq");

This works for me in both v6.1.2 and dev-7.0. I’ve just used label[] instead of AlarmInfoObj.

Have you enabled LV_UE_ANIMATIONS in lv_conf.h?

lv_obj_t * label[3];
label[0] = lv_label_create(lv_scr_act(), NULL);
label[1] = lv_label_create(lv_scr_act(), NULL);
label[2] = lv_label_create(lv_scr_act(), NULL);

lv_obj_set_y(label[0], 0);
lv_obj_set_y(label[1], 20);
lv_obj_set_y(label[2], 40);

lv_label_set_long_mode(label[0], LV_LABEL_LONG_SROLL_CIRC);
lv_label_set_long_mode(label[1], LV_LABEL_LONG_SROLL_CIRC);
lv_label_set_long_mode(label[2], LV_LABEL_LONG_SROLL_CIRC);

lv_obj_set_width(label[0], 210);
lv_obj_set_width(label[1], 140);
lv_obj_set_width(label[2], 440);

lv_label_set_text(label[0], "12344567890ABCDEFGHIJKLMNOPQRSTUVWXYZ");
lv_label_set_text(label[1], "12344567890ABCDEFGHIJKLMNOPQRSTUVWXYZ");
lv_label_set_text(label[2], "12344567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopq");


I have enabled it.I maybe found the reason. Because the code I upload is one part in a task event call back function. It will refresh reset the text every one second, but I found the animations will effect a little later. So every 1 second I reset the text of the label it will show from the beginning ,and it seems doesn’t work at all

Hi,

Sorry for the late replay.

I see. I’ve improved this behavior in dev-7.0 branch. Now the position is kept when the text changes.

If you could try it and it doesn’t work well please open an issue on GitHub.