How to display time

Description

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

stm32f4discovery

What LVGL version are you using?

v7.11.0-dev

What do you want to achieve?

Print the value of variables

What have you tried so far?

RTC_GetTime(RTC_Format_BIN, &RTC_DateTime);
sprintf(clock_buf, " %02d:%02d:%02d\r\n", RTC_DateTime.RTC_Hours,
RTC_DateTime.RTC_Minutes, RTC_DateTime.RTC_Seconds);
LCD_setCursor(180, 5);
LCD_setTextColor(WHITE);
LCD_setTextBgColor(BLUE);
LCD_setTextSize(2);
LCD_writeString((unsigned char*) clock_buf);

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:

/*You code here*/

Screenshot and/or video


If possible, add screenshots and/or videos about the current state.
how to do the same with LVGL? Thank.

leihao,the examples just like that:

lv_obj_t* label = lv_label_create(lv_scr_act(), NULL);

lv_label_set_text(label, "00:01:38");  // set text
lv_obj_set_pos(label, 400, 5);         // set position

lv_obj_set_style_local_bg_opa(label, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_100);
lv_obj_set_style_local_text_color(label, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);           // fg color
lv_obj_set_style_local_bg_color(label, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLUE);            // bg color
lv_obj_set_style_local_text_font(label, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, &lv_font_montserrat_22);  // font size(template:lv_font_montserrat_xx)

Something like this should work:

RTC_GetTime(RTC_Format_BIN, &RTC_DateTime);
lv_label_set_text_fmt(label, "%02d:%02d:%02d", RTC_DateTime.RTC_Hours,
RTC_DateTime.RTC_Minutes, RTC_DateTime.RTC_Seconds);

many thanks for the help.