Hi all
I need to use the lvgl lib version 8.4.0 and I wnat create a anmitation that update every second a text field. I was able create the textfiel and wirte in it.
I have the created to functions, one for setting up the animation, and one for calling every 1 sewcond
void lv_label_set_time(void* text_label_value, int32_t v) {
Serial.println("lv_label_set_time");
char time_str_[9];
time_t now_ = time(nullptr);
struct tm* timeinfo_ = localtime(&now_);
sprintf(time_str_, "%02d:%02d:%02d", timeinfo_->tm_hour, timeinfo_->tm_min, timeinfo_->tm_sec);
lv_label_set_text((lv_obj_t*)text_label_value, time_str_);
Serial.println(time_str_);
}
void lv_create_anim_update_time(void) {
// Create an animation to update the time every second
lv_anim_t a_;
lv_anim_init(&a_);
lv_anim_set_var(&a_, text_label_time_value);
lv_anim_set_values(&a_, 0, 59);
lv_anim_set_time(&a_, 1000);
lv_anim_set_repeat_count(&a_, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_exec_cb(&a_, (lv_anim_exec_xcb_t)lv_label_set_time);
lv_anim_start(&a_);
Serial.println("Animation started");
}
void loop(){
lv_task_handler(); // let the GUI do its work
lv_tick_inc(5); // tell LVGL how much time has passed
delay(5); // let this time pass
}
lv_label_set_time is called once at the creation time, but then it is not anymore called. Any idea why it is not working?