I am trying to get the text on my GUI to update. Every time there’s a new value updated via UART, the text should automatically update itself. For example, if text A has a new value, text A is updated while the other tabs are kept the same.
What MCU/Processor/Board and compiler are you using?
STM32F769-DISCO
What LVGL version are you using?
v8.0
What do you want to achieve?
To update the text in my GUI.
What have you tried so far?
Every time there’s a new value for a variable sent via UART, it’s ‘rewritten’ but there’s no change in the GUI. Shouldn’t lv_task_handler() automatically update the GUI or do I have to call something like lv_chart_refresh to refresh a particular part of the GUI? Also, I’ve removed HAL_Delay(5) as it causes problems with other functions. I’m not sure if it affects it or not.
Hi, thank you for your reply. I am using my own code, but it’s based on the STM32F769-DISCO demo. As my code is way too long, I’ve made a short demo of what I’m trying to do below. Essentially, the variables ‘Val’ is an external variable that updates when there’s data in the UART. The GUI should then update the text according to what the UART has received.
Main code:
int main(void) {
CPU_CACHE_Enable();
HAL_Init(); //Initialise HAL
SystemClock_Config();
PeriphCommonClock_Config();
MX_GPIO_Init();
lv_init(); //Initialise LVGL
tft_init(); //Initialise TFT driver
touchpad_init(); //Initialise touchpad driver
COM(); //start UART
test();
while(1) {
RX(); //Receive data from UART
lv_task_handler();
}
}
As others have mentioned, with lv_label_set_text, the label keeps its own copy of the text, so you would need to call that function each time you update Val.
Alternatively, you can use lv_label_set_text_static(label, Val), which expects you to maintain the text buffer yourself (as you’re doing), and then you can just call lv_label_set_text_static(label, NULL) to instruct the label to refresh its text. This avoids the label needing to reallocate its own buffer each time.
I see. Thank you very much for your help. How about if I want to refresh the entire screen or tab? For example, if I want to refresh tab(lv_obj_t * parent), how what would I input as the parent?
I see. Thank you very much for your help. How about if I want to refresh the entire screen or tab? For example, if I want to refresh tab(lv_obj_t * parent), how what would I input as the parent?
If you are referring to changing the displayed value, you would need to update the individual widgets’ values (e.g. if you had 3 labels, you’d need to call lv_label_set_text on each).
If you are referring to the widget being redrawn on the screen, LVGL takes care of that for you.
I realised I wasn’t very clear with my question. Essentially, I wanted to update the values of the texts in a particular tab. But I had problems calling the function of tab(lv_obj_t * parent) as it requires an lv_obj_t object called parent which is not declared in the UART file as parent isn’t an extern variable. I managed to solve this by declaring the parent as an extern so I could refresh/update the tab and everything in the tab whenever a value needs to be updated.