Multiple Groups

Description

Defining multiple groups prevent keypad navigation

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

ESP32

What LVGL version are you using?

8.3.9

What do you want to achieve?

I tried to define different groups, each with individual sets of objects (buttons) added to them. These groups should then later beeing interactively assigned to an input device.

What have you tried so far?

I started with a simple project generated in Squareline 1.3.2:
there are in sum 6 buttons (two panels with 3 buttons).

In the ui.h I defined 3 groups as global constants:

extern lv_group_t *groupA;
extern lv_group_t *groupB;
extern lv_group_t *groupC;

The groups are initialized by adding those lines to the top of the ui_Screen1.c. Additionally, all objectes created subsequently are added to the groupA:

void ui_Screen1_screen_init(void)
{
groupA = lv_group_create();
groupB = lv_group_create();
groupC = lv_group_create();
lv_group_set_default(groupA);
...
created objects
}

So far, this works fine. The navigation with the keypad is possible.

But if I try to define for example groupB at the end of the function above (when all objects have been created), by adding

void ui_Screen1_screen_init(void)
{
groupA = lv_group_create();
groupB = lv_group_create();
groupC = lv_group_create();
lv_group_set_default(groupA);
...
created objects
...
lv_group_add_obj(groupB, ui_Button1);
lv_group_add_obj(groupB, ui_Button2);
etc.
}

the navigation with the keypad wont work anymore, and for me its no obvious why this is the case. There is no re assignment of the input-driver, its just a simple definition of the groups.

I created this simple program with only 6 buttons after I ran into trouble with a more complex program. The global variables and groups in this program are placed in a different location, so wrode the test programm with the groups defined more close after the creation of the objects.

Best regards
GeorgS

Did you ever figure this out?

Im also using Keypad with 5 button inputs and when I try to create button groups or add objects to a group.

Im using LVGL 9.1 and it core panics when i add the line to add a object to a group for some reason.

Not sure why yet so figured i would ask.

@georgS miss here, this isnt global def and next miss is edit ui files…
All around groups require management in user code.

So how should the group name be made global and where exactly should the new group be declared?

Ive tried alot of stuff but adding a group always panics.

Any more advice is greatly apperciated!

Show your code

I’m using LVGL 9.1.

Below I simply try to add a button object to the G group that but causes a core panic on my ESP32 as shown below. I get this same core panic if I try to add a new group also.

Seems to be something going on with the functions in the LVGL 9.1, not sure yet.

And here is Screen1 where the ui_Button1 is created if it helps:

I can’t see what I’m doing wrong or if it’s the library but from all the searching I have done I’m calling add object like I’m supposed to.

Even if just try to remove all objects from the default group and then add new objects it crashes at the same lv_group_add_obj function.

Hopefully we can figure it out.

LVGL require to work som object exist in memory alltime. Your lines in setup create local variables removed after setup ends. Learn about this, but one way is place static before or create for example g as global this way

lv_group_t * g1;
void setup()
{
....
g1= lv_group_create();

second issue is ui_Button1 must exist when you use it…
Move add obj after ui_init

Thanks so much for the advice as it worked!

It’s always something so simple :grinning:

Here is how it is now and it’s working without crashing so that’s progress.

Now I can move onto more testing to get the outcome I’m looking for.

I’ll be back if I have any more issues with this.

Thanks again!