ESP32 / Arduino 1.8.9 working off the Example file ESP32_TFT_eSPI
What do you want to achieve?
Update the text of a label with lv_task_once
What have you tried so far?
Tried the documentation and all the examples I can find but i’m clearly missing something simple here as I slowly get my head around LittlevGL :|:upside_down_face:
Code to reproduce
When i want to update the label i’m running…
lv_task_once(my_task);
which is erroring with "cannot convert ‘void ()()’ to 'lv_task_t {aka _lv_task_t*}’ for argument ‘1’ to ‘void lv_task_once(lv_task_t*)’*
lv_obj_t * my_label;
int num = 0;
/* In setup */
my_label = lv_label_create(lv_scr_act(), NULL);
/* In loop: */
char buf[32];
sprintf(buf, "num: %d\n", num);
num++;
lv_label_set_text(my_label, buf);
Method 2,
lv_obj_t * my_label;
int num = 0;
char buf[32]; /* Must be persistent */
/* In setup */
my_label = lv_label_create(lv_scr_act(), NULL);
lv_label_set_static_text(my_label, buf);
/* In loop: */
sprintf(buf, "num: %d\n", num);
num++;
lv_label_set_static_text(my_label, NULL);
The difference is that with method 1, lv_label_set_text needs to reallocate memory each time you call it (from its perspective the string length may have changed) and with method 2, lv_label_set_text_static does not does not need to as it merely uses the static buffer you have allocated to the label when it was first called.
I recommend turning on the related warnings for your compiler. Warnings seem annoying at first, but in many cases they actually save you a lot of debugging time by finding the issue for you.