Not sure of what you what I do but I tried your code and it’s the same issue.
However, I found from where it comes. It’s from create_screen_2() function. So the problem is here:
lv_obj_t * create_screen_2(bool ErrorMDP)
{
lv_obj_t * screen_MotdePasse = lv_obj_create(NULL);
lv_obj_add_event_cb(screen_MotdePasse, scr_unloaded_delete_cb, LV_EVENT_SCREEN_UNLOADED, &screen_MotdePasse);
//Some other code here to add elements to screen
return screen_MotdePasse;
this works ok because ui_Screen4 is global object variable exist anytime.
your code
`lv_obj_t * create_screen_2(bool ErrorMDP)
{
lv_obj_t * screen_MotdePasse = lv_obj_create(NULL);
lv_obj_add_event_cb(screen_MotdePasse, scr_unloaded_delete_cb, LV_EVENT_SCREEN_UNLOADED, &screen_MotdePasse);
//Some other code here to add elements to screen
return screen_MotdePasse;`
must Sigfault because UNLOADED, &screen_MotdePasse); is local object after exit this func never exist, or better say is used for other and store other data on this &
@HardHeavy
anytime you call updateStatus_Chauffe() your appl creates new label
text_etatCH = lv_label_create(screen_General1);
Thus, after a certain number of calls, the available memory will run out and text_etatCH will take the value NULL, which can potentially lead to a program crash. For example, I don’t know how the program will behave when trying to add a style
I remember what you said before, but as I said upper, I need to create some screens that are similar, so I’m seaching a way to avoid to create same 10x "create_screen1()’ functions.
->Do you speak about the call of the function or in the function itself ?
->No, that’s not what I want and I did not expect that as there is only one label of text_etatCH shown on screen, not two or many. I should just call
text_etatCH = lv_label_create(screen_General1);
once ?
->But because of “enterPrgChauffe” (global variable) is set to ‘1’ after, it won’t create multiples spinner then. Or am I wrong ?
if you need only one object create them once. I can suggest put it in create_screen_1() where all screen_General1 objects are initialized. Similarly for the spinner, create it along with all the screen_General1 objects. As far as I can see, the parameters of these objects (size, position, styles) do not change during the program.
All these sets of created labels will not be visible, because they are created with the same parameters (size, position and even text). Therefore they will simply overlap each other and you will not see that there are 100 of them. You will see only the top one.
To start, I know that “create_screen_2()” and “create_screen_3()” are almost same since it’s a copy/paste and just some minor changes were added to the second. That’s why I asked before how to implement similar screens without created almost same multiples “create_screen_2()”. But because it doesn’t work for now with
lv_obj_t * create_screen_2(bool ErrorMDP)
and as I need “screen_MotdePasse_Erreur” created in “create_screen_3()”, I keep it to do my test.
To continue, I have something I cannot understand in your reply. You started to say that my create_screen_2() function is not the best, and then suggest to do the exact same implementation for the screen in you “create_screen”.
But that’ already what it is done for now. Do you mean I should create 2 functions like:
void init_screen_1()
{
text = lv_label_create(screen_General1)
//etc for all objects
}
void create_screen_1()
{
lv_label_set_text(text_Etat_Salon, "ON");
}
In fact, they were overlapped before and I can see them as the text changed sometimes. So, I change my code and thought it was ok now, but seems not.