How to remove unwanted objects from screen

Description

Hi kisvegabor,
We are facing an issue while switching the two screens.
I have 2 screens when i redirect the screen from screen 1 to screen 2 some unknown objects are showing in the second screen.
I don’t know from where these objects are coming.
Please see the screenshot attached.
In below screen shot text area is showing at top left corner and my two text areas below the “Hello, Please login Here” are not showing.

What MCU/Processor/Board and compiler are you using?

ARM

What LVGL version are you using?

Version 7

What do you want to achieve?

I want to show the screen what i have written.

What have you tried so far?

lv_obj_t *prev_scr=lv_scr_act();
lv_obj_t * curr_scr=lv_obj_create(NULL,NULL);
lv_scr_load(curr_scr);
lv_obj_del(prev_scr);
//Added these lines in every screen but not worked .

Code to reproduce

Screen 1:

void iotgizmo_wifi(void)
{

    lv_obj_t *prev_scr=lv_scr_act();
        lv_obj_t * curr_scr=lv_obj_create(NULL,NULL);
        lv_scr_load(curr_scr);
        lv_obj_del(prev_scr);
#if LV_IOTGIZMO_WALLPAPER
    lv_obj_t * wp = lv_img_create(lv_scr_act(), NULL);
    lv_img_set_src(wp, &final_bg);
    lv_obj_set_click(wp, true);
#endif
    //logo
    lv_obj_t * logo_title = lv_img_create(lv_scr_act(), NULL);
    lv_img_set_src(logo_title, &logo);
    lv_obj_align(logo_title, NULL, LV_ALIGN_IN_TOP_MID, 0, 120);
    lv_obj_add_style(logo_title, LV_OBJ_PART_MAIN, &style_border);
    //label
    lv_obj_t * label_txt;
    label_txt = lv_label_create(lv_scr_act(),NULL);
    lv_label_set_recolor(label_txt,true);
    lv_label_set_text(label_txt, "#FFFFFF Please Enter WIFI Details Here.");
    lv_obj_set_width(label_txt, 150);
    lv_obj_align(label_txt, logo_title, LV_ALIGN_CENTER, 0, 100);
    //textarea_ssid
    ssid= lv_textarea_create(lv_scr_act(), NULL);
    lv_obj_set_size(ssid, 300, 100);
    lv_obj_align(ssid, label_txt, LV_ALIGN_CENTER, 0, 100);
    lv_textarea_set_text(ssid, "ssid");
    lv_textarea_set_one_line(ssid, true);
    lv_textarea_set_cursor_hidden(ssid, true);
    lv_textarea_set_placeholder_text(ssid, "SSID");
   // lv_obj_set_event_cb(ssid, ta_event_cb);
    lv_textarea_set_text_sel(ssid, true);
    //textarea_password
    password= lv_textarea_create(lv_scr_act(), NULL);
    lv_obj_set_size(password, 300, 100);
    lv_obj_align(password, ssid, LV_ALIGN_CENTER, 0, 100);
    lv_textarea_set_text(password, "password");
    lv_textarea_set_pwd_mode(password,true);
    lv_textarea_set_one_line(password, true);
    lv_textarea_set_cursor_hidden(password, true);
    lv_textarea_set_placeholder_text(password, "Password");
   // lv_obj_set_event_cb(password, ta_event_cb);
    //button
    lv_obj_t * label;
    lv_obj_t * cnt_btn = lv_btn_create(lv_scr_act(), NULL);
    lv_obj_set_event_cb(cnt_btn, event_handler);
    lv_obj_align(cnt_btn, NULL, LV_ALIGN_CENTER, 0, 100);
    label = lv_label_create(cnt_btn, NULL);
    lv_label_set_text(label, "Connect");
    //Keyboard
    keyboard = lv_keyboard_create(lv_scr_act(), NULL);
    lv_obj_set_size(keyboard,480,250);
    lv_keyboard_set_textarea(keyboard, ssid);
    lv_keyboard_set_cursor_manage(keyboard, true);
    lv_obj_align(keyboard, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);


}

Screen 2:

void iotgizmo_login(void)
{

    lv_obj_t *prev_scr=lv_scr_act();
        lv_obj_t * curr_scr=lv_obj_create(NULL,NULL);
        lv_scr_load(curr_scr);
        lv_obj_del(prev_scr);
#if LV_IOTGIZMO_WALLPAPER
    lv_obj_t * wp = lv_img_create(lv_scr_act(), NULL);
    lv_img_set_src(wp, &final_bg);
    lv_obj_set_click(wp, true);
#endif
    //loader
    loader=lv_spinner_create(lv_scr_act(),NULL);
    lv_obj_set_size(loader,75,75);
    lv_obj_set_hidden(loader,true);
    lv_obj_align(loader,NULL,LV_ALIGN_IN_TOP_MID,0,20);
    //logo
    logo_title = lv_img_create(lv_scr_act(), NULL);
    lv_img_set_src(logo_title, &logo);
    lv_obj_align(logo_title,loader, LV_ALIGN_OUT_BOTTOM_MID, 0, 50);
    //label
    lv_obj_t * label_txt;
    label_txt = lv_label_create(lv_scr_act(),NULL);
    lv_label_set_recolor(label_txt, true);
    lv_label_set_text(label_txt, " #FFFFFF Hello, Please Login Here.");
    lv_obj_set_width(label_txt, 150);
    lv_obj_align(label_txt, logo_title, LV_ALIGN_CENTER, 0, 100);
    //textarea
    email= lv_textarea_create(lv_scr_act(), NULL);
    lv_obj_set_size(email, 300, 100);
    lv_obj_align(email, label_txt, LV_ALIGN_CENTER, 0, 100);
    lv_textarea_set_text(email, "test@gmail.com");
    lv_textarea_set_one_line(email, true);
    lv_textarea_set_cursor_hidden(email, true);
    lv_textarea_set_placeholder_text(email, "Email");
   // lv_obj_set_event_cb(email, ta_event_cb);
    lv_textarea_set_text_sel(email, true);

    password= lv_textarea_create(lv_scr_act(), NULL);
    lv_obj_set_size(password, 300, 100);
    lv_obj_align(password, email, LV_ALIGN_CENTER, 0, 100);
    lv_textarea_set_text(password, "password");
    lv_textarea_set_one_line(password, true);
    lv_textarea_set_cursor_hidden(password, true);
    lv_textarea_set_placeholder_text(password, "Password");
   // lv_obj_set_event_cb(password, ta_event_cb);
    //button
    lv_obj_t * label;
    lv_obj_t * lgn_btn = lv_btn_create(lv_scr_act(), NULL);
    lv_obj_set_event_cb(lgn_btn, event_handler);
    lv_obj_align(lgn_btn, NULL, LV_ALIGN_CENTER, 0, 100);
    label = lv_label_create(lgn_btn, NULL);
    lv_label_set_text(label, "Login");
    //Keyboard
    keyboard = lv_keyboard_create(lv_scr_act(), NULL);
    lv_obj_set_size(keyboard,480,250);
    lv_keyboard_set_textarea(keyboard, email);
    lv_keyboard_set_cursor_manage(keyboard, true);
    lv_obj_align(keyboard, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);


}

Screenshot and/or video

Hi Any Update ? Please help me with this issue.

I would confirm that all your objects are being created on the right screen. This looks like an application issue, not an LVGL one.

Hi embeddedt, can you please give me a suggestion how to resolve this application issue.

I do not see any problems with the code you provided here.

Hi robekras,
Yes. But I don’t know why these objects are coming at top left corner.
If possible can you please give an example for switching between two screens.
is lv_scr_load and lv_obj_del implementation is correct in both screens. Because sometimes it showing null pointer error.

Any theme changes need to be done from my side ? I think I am not using any theme.

The objects are very likely to be appearing in the top left corner because they are being created on the wrong screen/container, however you would be the best person to check whether that is the case.

chandumanem,

I tried the code which you posted here.
I don’t have your image, but I’ve taken one of mine (shouldn’t matter) and you use some globals (keyboard, ssid, password, …), I added them.
I do not know what are you doing besides the code you posted here (the button event handler are missing too).

But the code here, doesn’t show a textarea at the top left corner.

Robekras,
From first screen button event handler I am connecting my board to wifi network. Once my board connected to wifi network i am calling second screen function. In second screen some objects like textarea,button etc are showing at top left corner.

Try to skip the wifi connect, and just do the screen change, and look what happens.

I have a simple handler for the connect button and for the login button, and everything is ok.

void event_handler1_cb (lv_obj_t* G_UNUSED (button), lv_event_t event)
{
  lv_obj_t* label;

  if (event == LV_EVENT_CLICKED) {
      iotgizmo_login ();
  }
}

void event_handler2_cb (lv_obj_t* G_UNUSED (button), lv_event_t event)
{
  lv_obj_t* label;

  if (event == LV_EVENT_CLICKED) {
      iotgizmo_wifi ();
  }
}

yes. i just skipped wifi connect and tried its working fine.
But why the issue is coming during wifi connect?
in my wifi connect(after connect button is clicked) their is no involvement of LVGL objects.
in my wifi connect program if wifi connection status is connected then i am calling iotgizmo_login (); that’s it.

Hmm, good question.

On your screenshot, the ‘textarea’ on the top left, with the string “Textarea”,
this code exists somewhere in you code?

Maybe an erroneous jump to that code?
In the past you had some string overflows. Maybe something similiar here?
Just a guess, as I don’t know your code.

Try to find out by inserting the wifi connect code step by step, until the error occurs again.

1 Like

Thanks for your help robekras.