Would you have time to possibly rewrite my code so that it will work?
I can try to make some suggestions. But it will be your task to implement this.
Currently, this is a little part of your code:
void draw_graphics(void) {
if ( m2.getRoot() == &m2_null_element ) {
draw_info();
}
}
If i remember correctly, you want to draw different pages with information. Step 1 is to split draw_info() into different pages, say:
draw_info_0(), draw_info_1(), draw_info_2().
Step 2, is to introduce a new variable "uint8_t info_page", which will select the info page. It could be implemented like this:
uint8_t info_page = 0;
void draw_graphics(void) {
if ( m2.getRoot() == &m2_null_element ) {
switch(info_page) {
case 0: draw_info_0(); break;
case 1: draw_info_1(); break;
case 2: draw_info_2(); break;
}
}
}
At the moment you will return immediatly from the info page to your main menu. Your code looks like this:
uint8_t update_graphics(void) {
if ( m2.getRoot() == &m2_null_element ) {
if ( m2.getKey() != M2_KEY_NONE )
m2.setRoot(&top_el_expandable_menu);
return 1;
}
return 0;
}
But additionally, you now want to switch between different pages, that means the new variable "info_page" must be modified to cycle between the three pages. You could do this (again modifiing your exisiting code):
uint8_t update_graphics(void) {
uint8_t key;
if ( m2.getRoot() == &m2_null_element ) {
key = m2.getKey(); // call getKey only once, because key is removed from the queue
if ( key != M2_KEY_NONE ) {
if ( key == M2_KEY_SELECT ) {
info_page++;
if ( info_page >= 3 )
info_page = 0;
}
else {
m2.setRoot(&top_el_expandable_menu);
}
}
}
return 1;
}
return 0;
}
Of course it is not tested, but i hope you understand the concept and i am sure that you can implement this.
If you have other questions on M2tklib, please ask.
Oliver