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
I use lv_label_create create two Label widgets to display times and number;
the object hander is global variable,and i only create them one time,and set their style,
then,i try to updata the text of the labels,lilke this
"
for(PlayCounter=0;PlayCounter<CanDataPlayTotalCount;PlayCounter++)
{
lv_label_set_text_fmt(guider_ui.CanDataPlayLabel6,“%lld Times”,PlayCounter);
DelayMs(1);
}
lv_label_set_text_fmt(guider_ui.CanDataPlayLabel6,“%lld Times”,PlayCounter);
printf(PlayCounter= %lld\r\n,PlayCounter);
lv_img_set_src(guider_ui.CanDataPlayImg,&Compelet);
"
the nmber can updata when the Circulation running;
when the Circulation have finished execution,
i see the printf contents is correct,but some times the lab shows the smaller data;
for example printf shows 12345,but i see 12341 on the screnn
what is more important,when the number not equal to the fact,
the code "lv_img_set_src(guider_ui.CanDataPlayImg,&Compelet);"did not work,it can not change the image;
when the printf number equals to label show,the lv_img_set_src work,and change the image.
What MCU/Processor/Board and compiler are you using?
stm32
What LVGL version are you using?
V8.3.5
What do you want to achieve?
i want the Label show the data that needs to change
What have you tried so far?
i guess,the Circulation function run too fast,the LVGL memory manage can not creat and free memory
in time,(infact,i allocate a huge memry to LVGL 40KB,it is enough ,wen the code runs,it have 20KB left)
i change the Label up data like lv_label_set_text_static,but it can not show the last data probability
the code like this(PlayCounterStr is globle)
"
for(PlayCounter=0;PlayCounter<CanDataPlayTotalCount;PlayCounter++)
{
sprintf(PlayCounterStr,“%lld Times”,PlayCounter);
lv_label_set_text_static(guider_ui.CanDataPlayLabel6,PlayCounterStr);
}
sprintf(PlayCounterStr,“%lld Times”,PlayCounter);
lv_label_set_text_static(guider_ui.CanDataPlayLabel6,PlayCounterStr);
printf(PlayCounter= %lld\r\n,PlayCounter);
lv_img_set_src(guider_ui.CanDataPlayImg,&Compelet);
"
When the value of the label is not equal to the actual value, the image does not change;just
have less probability compared with lv_label_set_text_fmt;
i can affirm lv_task_handler();run correctly all the time.
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:
C
/You code here/
the code is
typedef struct
{
lv_obj_t *ScrCanDataPlay;
bool ScrCanDataPlay_Del;
lv_obj_t *CanDataPlayLabel6;
}lv_ui;
lv_ui guider_ui;
//Write codes ScrCanDataPlay
guider_ui.ScrCanDataPlay = lv_obj_create(NULL);
lv_obj_set_scrollbar_mode(guider_ui.ScrCanDataPlay, LV_SCROLLBAR_MODE_OFF);
//Write style state: LV_STATE_DEFAULT for style_screen_main_main_default
static lv_style_t style_screen_main_main_default;
if (style_screen_main_main_default.prop_cnt > 1)
lv_style_reset(&style_screen_main_main_default);
else
lv_style_init(&style_screen_main_main_default);
lv_style_set_bg_color(&style_screen_main_main_default, lv_color_make(0xff, 0xff, 0xff));
lv_style_set_bg_opa(&style_screen_main_main_default, 0);
lv_obj_add_style(guider_ui.ScrCanDataPlay, &style_screen_main_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);
//Write style state: LV_STATE_DEFAULT for style_screen_label_all_main_main_default
static lv_style_t style_screen_label_all_main_main_default;
if (style_screen_label_all_main_main_default.prop_cnt > 1)
lv_style_reset(&style_screen_label_all_main_main_default);
else
lv_style_init(&style_screen_label_all_main_main_default);
lv_style_set_radius(&style_screen_label_all_main_main_default, 0);
lv_style_set_bg_color(&style_screen_label_all_main_main_default, lv_color_make(0xff, 0xff, 0xff));
lv_style_set_bg_grad_color(&style_screen_label_all_main_main_default, lv_color_make(0x21, 0x95, 0xf6));
lv_style_set_bg_grad_dir(&style_screen_label_all_main_main_default, LV_GRAD_DIR_NONE);
lv_style_set_bg_opa(&style_screen_label_all_main_main_default, 255);
lv_style_set_shadow_width(&style_screen_label_all_main_main_default, 0);
lv_style_set_shadow_color(&style_screen_label_all_main_main_default, lv_color_make(0x21, 0x95, 0xf6));
lv_style_set_shadow_opa(&style_screen_label_all_main_main_default, 255);
lv_style_set_shadow_spread(&style_screen_label_all_main_main_default, 0);
lv_style_set_shadow_ofs_x(&style_screen_label_all_main_main_default, 0);
lv_style_set_shadow_ofs_y(&style_screen_label_all_main_main_default, 0);
lv_style_set_text_color(&style_screen_label_all_main_main_default, lv_color_make(0x00, 0x00, 0x00));
lv_style_set_text_font(&style_screen_label_all_main_main_default, &HeiTi16);
lv_style_set_text_letter_space(&style_screen_label_all_main_main_default, 0);
lv_style_set_text_line_space(&style_screen_label_all_main_main_default, 0);
lv_style_set_text_align(&style_screen_label_all_main_main_default, LV_TEXT_ALIGN_CENTER);
lv_style_set_pad_left(&style_screen_label_all_main_main_default, 0);
lv_style_set_pad_right(&style_screen_label_all_main_main_default, 0);
lv_style_set_pad_top(&style_screen_label_all_main_main_default, 5);
lv_style_set_pad_bottom(&style_screen_label_all_main_main_default, 0);
guider_ui.CanDataPlayLabel6 = lv_label_create(guider_ui.ScrCanDataPlay);
lv_obj_set_pos(guider_ui.CanDataPlayLabel6, CHINESELABWIDTH, 25);
lv_obj_set_size(guider_ui.CanDataPlayLabel6, INFORMATIONLABWIDTH, INFORMATIONLABHIGH);
lv_obj_set_scrollbar_mode(guider_ui.CanDataPlayLabel6, LV_SCROLLBAR_MODE_OFF);
lv_label_set_text(guider_ui.CanDataPlayLabel6, "");
lv_label_set_long_mode(guider_ui.CanDataPlayLabel6, LV_LABEL_LONG_SCROLL);
lv_obj_add_style(guider_ui.CanDataPlayLabel6, &style_screen_label_all_main_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_scr_load(guider_ui.ScrCanDataPlay);
uint64_t PlayCounter;
uint64_t CanDataPlayTotalCount = 12345;
char PlayCounterStr[50];
for(PlayCounter=0;PlayCounter<CanDataPlayTotalCount;PlayCounter++)
{
lv_label_set_text_fmt(guider_ui.CanDataPlayLabel6,"%lld Times",PlayCounter);
DelayMs(1);//1 ms delay
}
lv_label_set_text_fmt(guider_ui.CanDataPlayLabel6,“%lld Times”,PlayCounter); //updata the last time
printf("CanDataPlayTotalCount =%lld\r\n",CanDataPlayTotalCount);
for(PlayCounter=0;PlayCounter<CanDataPlayTotalCount;PlayCounter++)
{
sprintf(PlayCounterStr,“%lld Times”,PlayCounter);
lv_label_set_text_static(guider_ui.CanDataPlayLabel6,PlayCounterStr);
DelayMs(1);//1 ms delay
}
sprintf(PlayCounterStr,“%lld Times”,PlayCounter);//updata the last time
lv_label_set_text_static(guider_ui.CanDataPlayLabel6,PlayCounterStr);
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.