Could you please provide an example of having multiple/several screens in LVGL and navigate from one to another by pressing a button in each screen?
I know you have provided TABs example in the “Learn LVGL” PDF Book, but I don’t want to handle tabs, I want to have individual screens to display different kinds of information and capture user inputs.
Thanks in advance for your help.
Hi.
At the moment, we don’t have any example like that.
I’ll add it to my to-do list and either add it to the next version of the eBook or create a free tutorial about it.
But, it may take some time as we’re currently out of the office and we already have the projects lined up for the next weeks.
Regards,
Rui
Thanks Rui.
I hope it will be soon, as I guess many people would need to do something like this, so it would benefit many of us.
Regards.
Hi Rui and Juan,
I am facing the same problem with CYD and EEZ studio. Multiple screens works well by using buttons to navigate between screens. No problem either to add an event (switch, slider, arc…) operating with the CYD WITH ONLY ONE SCREEN but I get the following error if I use the same function with multiple screens :
In function ‘void setup()’:
92 | lv_obj_add_event_cb(objects.switch_screen_a, switch_event_handler, LV_EVENT_VALUE_CHANGED, objects.off_on);
| ^~~~~~~
exit status 1
Compilation error: ‘objects’ was not declared in this scope
The problem could be specifying the action screen even if the structure in the sketch directory mentions the objects.
If I comment this line 92 in the setup, no issue to load the sketch. I can navigate but, of course, no event/action with the leds/inputs/outputs of the CYD.
typedef struct _objects_t {
lv_obj_t *screen_a;
lv_obj_t *screen_b;
lv_obj_t *screen_c;
lv_obj_t *obj0;
lv_obj_t *obj1;
lv_obj_t *obj2;
lv_obj_t *obj3;
lv_obj_t *obj4;
lv_obj_t *obj5;
lv_obj_t *switch_screen_a;
lv_obj_t *off_on;
lv_obj_t *arc_screen_b;
lv_obj_t *scale_arc_b;
lv_obj_t *led_arc_b;
lv_obj_t *text_arc_b;
} objects_t;
Regards,
Fabrice
Hi.
objects was not declared in this scope, which means they are not created before being called.
Ýou’re creating objects_t, shouldn’t you use that instead of objects?
lv_obj_add_event_cb(objects.switch_screen_a, switch_event_handler, LV_EVENT_VALUE_CHANGED, objects.off_on);
Regards,
Sara
Hi Sara,
Issue still the same with objects_t.
the structure with 1 or more screens is the identical with objects_t.
I tried different codes by specifying screen_a but nothing work.
Regards,
Fabrice
When you say nothing works, what happens exactly?
Do you always get the same error?
Regards,
Sara
Sorry Sara, I was not specific enough.
All the codes I used for the line lv_obj_add_event_cb… did not work. I always get the same error :
Compilation error: ‘objects’ was not declared in this scope.
If I replace “objects” by another item (like screen_a), I get this error “Compilation error: ‘screen_a’ was not declared in this scope.
Without this line, I can upload the code and all the display functions (widgets, screens…) run perfectly but no action with the leds or in/outputs of the CYD of course.
With one screen only, everything runs properly.
With multiple screens, It seems that the code cannot identify the object in the structure.