Im trying to get the ESP32 to send stuff like automatically update text label for Temperature sensor data and various other inputs.
I already managed to get the other way around working, clicking a button on my touchscreen prints in the output. But i’m not sure how to do it backwards and send data to the GUI.
Additionally, since editing text value might be rather simple, what would be the most convenient way of creating an event. like say, open a new page that displays an alarm animation. Are there some kind of invisible variables within squareline studio that i can use to create events, then trigger them remotely from the ESP32 code?
(Programmed from Arduino IDE 2.2.1)
If you need to pass numbers to a label:
lv_label_set_text_fmt(ui_Label1, “%d”, data);
ui_Label1 - label name
data - the name of your variable
Only integers can be passed
What do you mean integer only,is there is no way to send string values? How would you, say, create a wifi scanning page and receive the string value for the name?
Exist many variants, but most simple and classic is place this code into loop code as event triggered by previously showed data require change (for example temperature) And ofcourse no only integer , show is based on func used …
This code should work if you declare as 'int' and init the 'data' variable well (and add an 'l' at the beginning of function name). No explicit events are needed to update a label widget's text, you just need to use the lv_label_set_text function. If you want to watch the change of a string or variable and set this automatically you need to do it periodically ('observe' in main loop) as Marian_M suggets.
ok,
if i put this lv_label_set_text(ui_Pressure,“test 123”);
no problem,it work.
if i put this lv_label_set_text_fmt(ui_Pressure, “%d”, MyVAR);
Doesn`t work,gave me d not declared and something about chars convertion permissive.
what is fmt and %d ?
this doesn`t work too lv_label_set_text(ui_Pressure,MYVAR);
i`m only stuck with this,as a newbies i am.
i don`t see anything about ‘l’ at the beginning.
thanks in advance!!!
(i will surely buy a plan,like a small business)
You probably need to turn on the floating point support in lv_conf.h if it’s not set already. So search for LV_SPRINTF_USE_FLOAT definition in lv_conf.h and set it to 1 if it’s 0… This is needed to enable printing floating numbers by sprintf which is used by lv_label_set_text_fmt.