用lvgl定时器1s刷新一次时间,但是偶尔会直接跳2s,请教下这种该怎么处理,按秒刷新
代码如下
static char formattedTime[50];
static void clock_timer_cb(lv_timer_t *timer) {
getCurrentLocalTime(formattedTime, sizeof(formattedTime));
lv_label_set_text(timer->user_data, formattedTime);
}
void background_set_clock(lv_obj_t *parent) {
lv_obj_t *clock_label = lv_label_create(parent);
lv_obj_set_style_text_font(clock_label, &MyFontNormal20, 0);
lv_label_set_text(clock_label, "1970-01-01 00:00:00");
lv_obj_align(clock_label, LV_ALIGN_TOP_LEFT, 10, 10);
lv_obj_move_foreground(clock_label);
lv_timer_t *clock_timer = lv_timer_create(clock_timer_cb, 1000, clock_label);
lv_timer_set_repeat_count(clock_timer, -1);
}