How to correctly reference components and their children

I have created a component and have it at the top of 3 screens, I have exported all the files, ensured that the includes are there for the ui.h, ui_helpers.h, and ui_comp.h in my main.cpp (in platformio). I can address the lebels, change their text, etc outside of the component like normal. However I cant seem to get to the child items on the component. I have tried using the following code to set the temprature on a label in the component inside the panel:

lv_obj_t * child = ui_comp_get_child(ui_PnlTemp, UI_COMP_PNLTEMP_TXTTEMP);

lv_label_set_text(child,String(curtemp).c_str());

and get no errors till the very end of the compile with :

“undefined reference to `ui_comp_get_child(_lv_obj_t*, unsigned int)” although there is no intellisense errors, squiggles, etc… all looks good in platformio until just as its linking the firmware.elf then poof the error… Can somone assist with what im doing incorrectly. have tried all i can think of…

Thanks so much in advance!!!

Can you really see ui_comp_get_child in ui_comp.c?

I can, here it is:

lv_obj_t * ui_comp_get_child(lv_obj_t * comp, uint32_t child_idx)

{

ui_comp_get_child_t info;

info.child = NULL;

info.child_idx = child_idx;

lv_event_send(comp, LV_EVENT_GET_COMP_CHILD, &info);

return info.child;

}

and in the ui_comp.h the following exists:

lv_obj_t * ui_comp_get_child(lv_obj_t * comp, uint32_t child_idx);

extern uint32_t LV_EVENT_GET_COMP_CHILD;

// COMPONENT PnlTemp

#define UI_COMP_PNLTEMP_PNLTEMP 0

#define UI_COMP_PNLTEMP_TXTTEMP 1

#define UI_COMP_PNLTEMP_LBLTEMP 2

#define UI_COMP_PNLTEMP_LBLHUM 3

#define UI_COMP_PNLTEMP_TXTHUM 4

#define UI_COMP_PNLTEMP_LBLDEW 5

#define UI_COMP_PNLTEMP_TXTDEW 6

#define UI_COMP_PNLTEMP_LBLBARO 7

#define UI_COMP_PNLTEMP_TXTBARO 8

#define _UI_COMP_PNLTEMP_NUM 9

lv_obj_t * ui_PnlTemp_create(lv_obj_t * comp_parent);

Are you sure ui_comp.c is being compiled?

Please add #error "test" to ui_comp.c to see it’s really seen by the compiler.

Ill give that a shot, although i can verify that if i remove the include, then the intellisense will scream and put squiggles under the code. (as buggy as intellisense is) also when i start to specify the components, the autocomplete sees the component function and the children described in the .h file. so im pretty certain that its good, but ill test that anyways… I moved on and did the project another way as i need to finish it, so ill open up the saved project that was giving me issues and try that later today…

Wow, very interesting. So the file is built, the header file is included, but the function is not seen.

In lack of a better idea, pleas try if you can create a component manually. E.g. ui_mycomp_create(parent)

I will give it a shot once i can come up for air! Ill update once I know more.

Hi, ist there a solution now? I’ve got the same problem whith PlatformIO.
best regards

I believe it’s a PlatformIO specific issue. Probably the ui_... files are not built or linked.

it’s not a compiler problem, I compile with arduino and the same strange thing happens, it’s a SLS problem. I ask for help with the same problem, thanks.

Could you send the whole Arduino project? You can use a very simple UI just the demonstrate the issue.

Please also attache the relevant part of Arduino’s compile log.

Have same issue, were anyone to get a component working on arduino? You get undefined reference and extern doesn’t work either, nor struct

Please send a project so that we can reproduce the issue.

I found the “issue”.
Its you just can’t reference the components nor the childens with its variable name cui_var_name_xxx etc just like the other lv_obj objects.
You have to get them with the function lv_obj_get_child(obj_name, num_id_child).
Note:
Its easier to work with widgets throught their var name directly, if theres other ways to work with the components than with lv_obj_get_child hit me up.

Take look at this: Components | SquareLine Studio