Oliver, does this line need replacing for u8_glib?Code: [Select]M2tk m2(&el_main_menu, m2_es_arduino, m2_eh_4bs, m2_gh_lc);Yes: Please replace m2_gh_lc with m2_gh_u8g_bf (or one of the other u8g graphics handler)
M2tk m2(&el_main_menu, m2_es_arduino, m2_eh_4bs, m2_gh_lc);
Time to read up on m2tklib at http://code.google.com/p/m2tklib/wiki/
QuoteTime to read up on m2tklib at http://code.google.com/p/m2tklib/wiki/After all the threads, i see that a menu lib is difficult to handle (also i think it has a simple concept). I did my best to add tutorial pages to the wiki, but i also see that there is still a lot of discussion required. I am not sure how to improve this. Let me know if something is missing... and do not hestitate to ask directly...Oliver
dannix, I had the same problem, built a huge menu, couldnt get it to work, and now turning to this option. Seems like it has much more functionality just trying to learn how to use its features
Well, working functions is a start! reading this thread I noticed the GLCD support in m2tklib.
QuoteWell, working functions is a start! reading this thread I noticed the GLCD support in m2tklib.Please note that I was informed about a bug in M2tklib for GLCD recently. I have released a new version of M2tklib for GLCD today.Oliver
error: cannot convert 'LiquidCrystal_SR*' to 'LiquidCrystal*' for argument '1' to 'void m2_SetLiquidCrystal(LiquidCrystal*, uint8_t, uint8_t)'
//DEBUG#include <MemoryFree.h> int tempMemCount = 0;///*LCD*/#include <LCD.h>#include <LiquidCrystal_SR.h> // ShiftRegister LCDLiquidCrystal_SR iLCD(10, 11, 12); //Data,Clk,Enable.//END LCD//MENU SETUP#include "M2tk.h"#include "utility/m2ghlc.h"//initialize menuM2_LABEL(hello_world_label, NULL, "Hello World!");M2tk m2(&hello_world_label, NULL, NULL, m2_gh_lc);//initialize menuitemsunsigned long menuTimer = millis(); byte timerEnable = 0;//END MENU //INTERRUPT BUTTONSconst int pin = 13; // test for interruptconst int buttonPin = A0; // buttons can be read herevolatile byte buttonAct = 0; // flag, follow button pressvolatile int buttonValue = 0; // button pressed analogue value volatile int buttonPressed = 0; // which button was pressedvolatile byte lastButtonPressed = 0; // prev button pressedvolatile byte state = LOW; // state of led on pin13volatile byte lastState = HIGH; // unused?void setup(){ //MENU SETUP m2_SetLiquidCrystal(&iLCD, 20, 4); // <<<<<<------------- ERROR this line //configure menu //END MENU SETUP Serial.begin(38400); Serial.println(F("STARTED")); pinMode(pin, OUTPUT); attachInterrupt(0, readButtons, RISING); iLCD.begin(20,4); // initialize the lcd delay(400); // wait to start lcd writing iLCD.home (); // go home iLCD.print(F("Button Interrupt")); Serial.print(F("freeMemory() reports at startup ")); Serial.println( freeMemory() );}void buttonStat(){ Serial.print(buttonPressed); Serial.print(" "); Serial.println(lastButtonPressed);}void loop(){ if(timerEnable == 1 && millis() - menuTimer >=8000){ //in the middle of something, set menuTimer = 0 to disable and drop timerEnable Serial.print(F("freeMemory() reports ")); Serial.println( freeMemory() ); Serial.println(F("Timer Clear.........")); /* menu.moveToLevel(1); this resets the uno????*/ // go back to root of menu here timerEnable = 0; iLCD.clear(); // go home iLCD.print(F("Button Interrupt")); delay(60); buttonAct = 0; } if(buttonAct == 1){ //buttonAct eq 1 when interrupt received buttonAct = 0; navMenu(); } //lastButtonPressed = 0; delay(100); tempMemCount++; if(tempMemCount > 9){ //once a sec will do Serial.print(F("freeMemory() reports ")); Serial.println( freeMemory() ); tempMemCount = 0; }}void readButtons(){ state = !state; digitalWrite(pin, state); /* 511 : none | 614 : up | 768 : down | 1023 : select */ lastButtonPressed = buttonPressed; buttonValue = analogRead(buttonPin); if(buttonValue >= 900) { buttonPressed = 3; } else if(buttonValue >= 700){ buttonPressed = 2; } else if(buttonValue >= 600){ buttonPressed = 1; } buttonAct = 1; Serial.print(buttonPressed); Serial.print(" "); Serial.println(buttonValue);}void navMenu(){ //MenuItem currentMenu=menu.getCurrent(); switch (buttonPressed){ case 3: //select /* if (menu.getCurrent().getRight() != 0){ //The current item has an element right, it's a sub menu so nav right. menu.moveRight(); Serial.print(menu.getCurrent().getName()); Serial.println(F("has menu right")); } else{ //otherwise, menu has no child and has been pressed. enter the current menu menu.use(); } */ break; case 2: //down //menu.moveDown(); break; case 1: //up //menu.moveUp(); break; }}
m2_SetLiquidCrystal(&iLCD, 20, 4); // <<<<<<------------- ERROR this line
Question. I have 3 buttons up, down & select , which you have no handler for, I thought no problem I can use SetKey() in my ISR? this is ok I assume?
Code: [Select]m2_SetLiquidCrystal(&iLCD, 20, 4); // <<<<<<------------- ERROR this lineThe problem is, that LiquidCrystal_SR is the same type as LiquidCrystal. The warning is correct and it will not work.M2tklib currently only supports output to LiquidCrystal. Howver, other libs could be added also, but M2tklib needs another graphics output handler. The existing LCD output code might serve as a template: http://code.google.com/p/m2tklib/source/browse/dev/LiquidCrystal/m2ghlc.cppQuoteQuestion. I have 3 buttons up, down & select , which you have no handler for, I thought no problem I can use SetKey() in my ISR? this is ok I assume? It is no problem to have only three buttons. And yes, you probably can use setKey within an ISR (it has not been fully tested by me). Oliver
Serial.print(F("freeMemory() reports "));