Child component usage

What do you want to achieve?

     I want to use the  label which is present in the component, in user function.

What have you tried so far?

    I want to set the date so i created label and i tried to add user function and call it in timer. i am getting segmentation fault when i run the build. 

Screenshot or video

Others

  • **SquareLine Studio version: 1.3.2
  • Operating system:
  • Target hardware:

For example
lv_obj_set_style_text_color(ui_comp_get_child(yourcompo, UI_COMP_PANEL_LABEL17), lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT );

Hi, I had tried like this it’s not showing any error but its not enter the if condition only to get the date and time.

void UpdateFooterDateTime()
{
    printf("UpdateFooterDateTime--------------------------\n");
    //Update Date and Time label -> ui_Label5 in footer from the structure
   if(lv_obj_get_screen(ui_comp_get_child(ui_footerPanel, UI_COMP_FOOTERPANEL_LABEL5) ) == lv_scr_act())
    {
       printf("Success\n");
        char buf[300];
        sprintf(buf, "%02d %s %04d %02d:%02d %s", tDateTime.day, GetMonthName(tDateTime.month), tDateTime.year, tDateTime.hour,tDateTime.minute, GetAMPM(tDateTime.hour));
        lv_label_set_text(ui_comp_get_child(ui_footerPanel, UI_COMP_FOOTERPANEL_LABEL5), buf);
    }
}

Thanks,

Why you mean this will work? You need ask obj on screen no component def name.

Thank you Marian… I didn’t get how to use, could you please help me out of this?

My crystal ball say your object on screen have other name … and better is check existent component on screen as his child…

Ok Marian I will check. Thank you so much.

Please print these:

lv_obj_t * comp = ui_comp_get_child(ui_footerPanel, UI_COMP_FOOTERPANEL_LABEL5);
lv_obj_t * comp_screen = lv_obj_get_screen(comp_screen);
lv_obj_t * act_scr = lv_scr_act();

printf("%p, %p, %p\n", comp, comp_screen, act_scr);