#include "U8glib.h" #include "M2tk.h" #include "m2ghu8g.h" #define EN 23 #define RW 17 #define RS 16 // U8g setup U8GLIB_ST7920_128X64_1X lcd(EN, RW, RS); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 // DOGM132, DOGM128 and DOGXL160 shield uint8_t uiKeyUpPin = 33; uint8_t uiKeyBackPin = 31; uint8_t uiKeySelectPin = 35; uint8_t u; /* the number, which was entered by the user */ float srednica1; float srednica2; void fn_ok(m2_el_fnarg_p fnarg) { /* do something with the number */ } M2_LABEL(el_goto_title, NULL, "Wybierz srednice"); M2_LABEL(el_goto_title2, NULL, "filamenu:"); M2_ROOT(el_goto_part1, NULL, "1.75", &srednica1); M2_ROOT(el_goto_part2, NULL, "2.85", &srednica2); M2_LIST(list_menu) = {&el_goto_title,&el_goto_title2, &el_goto_part1, &el_goto_part2,}; M2_VLIST(el_menu_vlist, NULL, list_menu); M2_ALIGN(el_top, "W64H64", &el_menu_vlist); M2tk m2(&el_top, m2_es_arduino, m2_eh_4bs, m2_gh_u8g_bfs); void draw(void) { m2.draw(); } // Arduino setup procedure (called only once) void setup() { // Connect u8glib with m2tklib m2_SetU8g(lcd.getU8g(), m2_u8g_box_icon); // Assign u8g font to index 0 m2.setFont(0, u8g_font_7x13); // Setup keys m2.setPin(M2_KEY_SELECT, uiKeySelectPin); m2.setPin(M2_KEY_NEXT, uiKeyUpPin); m2.setPin(M2_KEY_PREV, uiKeyBackPin); } void loop() { m2.checkKey(); if ( m2.handleKey() ) { lcd.firstPage(); do { m2.checkKey(); draw(); } while( lcd.nextPage() ); } }