I'm done just this moment. 
It's not perfect and not everything is working 100% but here it is:
#include "U8glib.h"
#include "M2tk.h"
#include "utility/m2utl.h"
#include "utility/m2ghu8g.h"
#include "config.h"
U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
uint8_t hour=0;
uint8_t minute=0;
uint8_t value=0;
uint8_t led_menu_current_index = 0;
uint8_t time_menu_current_index = 0;
#define LED_NUM 4
#define TIME_NUM 10
//=================================================
// forward declaration
extern M2tk m2;
M2_EXTERN_ALIGN(top_el_time_list);
M2_EXTERN_GRIDLIST(set_led_grid);
M2_EXTERN_ALIGN(top_el_led_list);
M2_EXTERN_GRIDLIST(top_el_clock_screen);
M2_EXTERN_ALIGN(el_top_menu);
/************ Set LED Screen *************/
void dt_ok_set_led(m2_el_fnarg_p fnarg) {
m2_SetRoot(&top_el_time_list);
}
// Zeit
M2_U8NUM(el_li_hour, "c2", 1,31,&hour);
M2_LABEL(el_li_sep1, "b1", ":"); // dot is drawn on the baseline
M2_U8NUM(el_li_minute, "c2", 1,12,&minute);
M2_LIST(list_time) = { &el_li_hour, &el_li_sep1, &el_li_minute};
M2_HLIST(el_time, NULL, list_time);
// Value
M2_U8NUM(el_li_val, "r1c2", 0, 100, &value);
M2_LABEL(el_li_sep2, "b1", "%");
M2_LIST(list_value) = { &el_li_val, &el_li_sep2};
M2_HLIST(el_value, NULL, list_value);
// Buttons
M2_ROOT(el_dt_cancel, NULL, "cancel", &top_el_time_list);
M2_BUTTON(el_dt_ok, NULL, "ok", dt_ok_set_led);
M2_LABEL(el_dt_time, "b1", "Zeit");
M2_LABEL(el_dt_level, "b1", "Level");
M2_LIST(set_led_grid_list) = {
&el_dt_time, &el_time,
&el_dt_level, &el_value,
&el_dt_ok, &el_dt_cancel
};
M2_GRIDLIST(set_led_grid, "c2",set_led_grid_list);
/********************* END LED SCREEN ***********************************/
/********************* Liste Zeiten ***********************************/
uint8_t time_list_first = 0;
uint8_t time_list_cnt = TIME_NUM;
// callback procedure for the STRLIST element
const char *time_list_cb(uint8_t idx, uint8_t msg) {
static char s[12];
s[0] = '\0';
if ( msg == M2_STRLIST_MSG_SELECT ) {
time_menu_current_index = idx;
// Call Werte setzen Grid
m2.setRoot(&set_led_grid);
} else {
strcpy(s, "Zeit ");
strcpy(s+5, m2_utl_u8d(idx+1,2));
}
return s;
}
// selection menu for the pins, composed of a STRLIST element with a scroll bar
M2_STRLIST(el_time_list_strlist, "l3W56", &time_list_first, &time_list_cnt, time_list_cb);
M2_SPACE(el_time_list_space, "W1h1");
M2_VSB(el_time_list_vsb, "l3W4r1", &time_list_first, &time_list_cnt);
M2_LIST(list_time_list) = { &el_time_list_strlist, &el_time_list_space, &el_time_list_vsb };
M2_HLIST(el_time_list_hlist, NULL, list_time_list);
M2_ALIGN(top_el_time_list, "-1|1W64H64", &el_time_list_hlist);
/********************* END ZEIT LISTE ***********************************/
/********************* Liste LED's ***********************************/
uint8_t led_list_first = 0;
uint8_t led_list_cnt = LED_NUM;
// callback procedure for the STRLIST element
const char *led_list_cb(uint8_t idx, uint8_t msg) {
static char s[6];
s[0] = '\0';
if ( msg == M2_STRLIST_MSG_SELECT ) {
led_menu_current_index = idx;
// call time List
m2.setRoot(&top_el_time_list);
} else {
// convert the idx into some readable line for the user
strcpy(s, "LED ");
strcpy(s+4, m2_utl_u8d(idx+1,2));
}
return s;
}
// selection menu for the pins, composed of a STRLIST element with a scroll bar
M2_STRLIST(el_led_list_strlist, "l3W56", &led_list_first, &led_list_cnt, led_list_cb);
M2_SPACE(el_led_list_space, "W1h1");
M2_VSB(el_led_list_vsb, "l3W4r1", &led_list_first, &led_list_cnt);
M2_LIST(list_led_list) = { &el_led_list_strlist, &el_led_list_space, &el_led_list_vsb };
M2_HLIST(el_led_list_hlist, NULL, list_led_list);
M2_ALIGN(top_el_led_list, "-1|1W64H64", &el_led_list_hlist);
/********************* END LED LISTE ***********************************/
/********************* Zeit Einstellen ***********************************/
uint8_t dt_hour = 1;
uint8_t dt_minute = 1;
uint8_t dt_day = 1;
uint8_t dt_month = 1;
uint8_t dt_year = 12;
void dt_clock_ok(m2_el_fnarg_p fnarg) {
m2_SetRoot(&el_top_menu);
}
// Zeit
M2_U8NUM(el_clock_hour, "c2", 0,24,&dt_hour);
M2_LABEL(el_clock_sep1, "b1", ":");
M2_U8NUM(el_clock_minute, "c2", 0,59,&dt_minute);
M2_LIST(list_clock_time) = { &el_clock_hour, &el_clock_sep1, &el_clock_minute };
M2_HLIST(el_clock_time, NULL, list_clock_time);
// Datum
M2_U8NUM(el_clock_day, "c2", 1,31,&dt_day);
M2_LABEL(el_clock_sep2, "b1", "."); // dot is drawn on the baseline
M2_U8NUM(el_clock_month, "c2", 1,12,&dt_month);
M2_LABEL(el_clock_sep3, "b0", "."); // dot will be too low
M2_U8NUM(el_clock_year, "c2", 0,99,&dt_year);
M2_LIST(list_clock_date) = { &el_clock_day, &el_clock_sep2, &el_clock_month, &el_clock_sep3, &el_clock_year };
M2_HLIST(el_clock_date, NULL, list_clock_date);
M2_ROOT(el_clock_cancel, NULL, "cancel", &el_top_menu);
M2_BUTTON(el_clock_ok, NULL, "ok", dt_clock_ok);
M2_LABEL(el_dt_clock_time, "b1", "Zeit");
M2_LABEL(el_dt_clock_date, "b1", "Datum");
M2_LIST(set_clock_grid_list) = {
&el_dt_clock_time, &el_clock_time,
&el_dt_clock_date, &el_clock_date,
&el_clock_ok, &el_clock_cancel
};
M2_GRIDLIST(top_el_clock_screen, "c2",set_clock_grid_list);
/********************* END ZEIT EINSTELLEN ***********************************/
//=================================================
M2_LABEL(el_menu_title, NULL, "Menu");
M2_ROOT(el_menu_itm1, NULL, "Zeit", &top_el_clock_screen);
M2_ROOT(el_menu_itm2, NULL, "Licht", &top_el_led_list);
M2_LIST(list_menu) = {&el_menu_title, &el_menu_itm1, &el_menu_itm2};
M2_VLIST(el_menu_vlist, NULL, list_menu);
M2_ALIGN(el_top_menu, "W64H64", &el_menu_vlist);
// m2 object and constructor
M2tk m2(&el_top_menu, m2_es_arduino_rotary_encoder, m2_eh_4bd, m2_gh_u8g_bf);
//=================================================
// Draw procedure, Arduino Setup & Loop
void draw(void) {
m2.draw();
}
void setup(void) {
// Connect u8glib with m2tklib
m2_SetU8g(u8g.getU8g(), m2_u8g_box_icon);
// Assign u8g font to index 0
m2.setFont(0, u8g_font_7x13r);
// define button for the select message
m2.setPin(M2_KEY_SELECT, 2); // dogm128 shield, 2nd from top
// The incremental rotary encoder is conected to these two pins
m2.setPin(M2_KEY_ROT_ENC_A, A1);
m2.setPin(M2_KEY_ROT_ENC_B, A0);
}
void loop() {
// check rotary encoder also inside the picture loop
m2.checkKey();
// process events and redraw menu if required
if ( m2.handleKey() != 0 ) {
u8g.firstPage();
do {
// check rotary encoder also inside the picture loop
m2.checkKey();
// draw menu
m2.draw();
} while( u8g.nextPage() );
}
}
atm I can't select the value or get one level up from strlst, but this will be easy to figure out.
I'm kinda scared this "small" menu takes up 22.144 Bytes. I have just a Nano and I think there is not enough space for the rest of the code. Maybe it needs some tweaking or i try your solution with 2 dialoges next.
But at least it works now.
One more the display is a lilbit "off". do you know how to fix this? (see picture)
Nevermind... found it:
To modify the offset of the display, modify line 191 in u8g_dev_ssd1306_128x32.c:
0x000, / set lower 4 bit of the col adr. to 4 /
Try 0x002 or 0x004 instead of the 0x000