Go Down

Topic: menubackend library submenus (Read 5331 times) previous topic - next topic

olikraus


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)


Regarding the compile problem:
The latest version of m2tklib for u8glib is here:
http://code.google.com/p/m2tklib/downloads/detail?name=m2tklib_arduino_u8g_1.08.zip
U8glib requires another download (only for AVR - none Arduino - there is a combined zip)

Usually the best is to remove the old m2tklib folder and unzip the version above.

Oliver

a.mlw.walker

Ah yes, new library means everything has compiled.
nice...

dannix

Time for me to kick menubackend out of my prog. I'm not convinced it's working properly given the problems I've had with it.

Time to read up on m2tklib at http://code.google.com/p/m2tklib/wiki/

olikraus


Quote
Time 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

a.mlw.walker

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

dannix



Quote
Time 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



Hi, I've only tried menubackend and menu that came with the IDE I don't like the submenus on menu, menubackend I got a working menu with submenus but most of the functions don't work. What I'm after is a char LCD scrolling top to bottom menu with submenus (like your PWM pin example) But I couldn't use .....getBefore().getName() etc they don't compile so I had no way to work out what to display as the before and after items. I'm hoping your structure does what it says, it's much better documented example wise despite what you said above. There is only one example for menubackend, most of it's feature are not used or exampled.

Many thanks for the offer of assistance, It's great you release the library in the first place! I'll try myself and post if I need to :D

dannix


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. I don't need it now, but I will sometime later ;-)

I'm glad it wasn't just me. I'm newish to this arduino and I normally program in Perl so not having dynamic memory etc I thought it could be me using menubackend wrong but there is to many posts I've seen with similar issues when it comes to anything beyond a basic list of menu items.

I'll let you know how I get on with m2tklib

olikraus

#22
Jul 18, 2012, 10:58 pm Last Edit: Jul 18, 2012, 11:41 pm by olikraus Reason: 1
Quote
Well, 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

dannix


Quote
Well, 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


I'm using LiquidCrystal with a shift register attached LCD. I've hit my first problem though and I suspect it is because of the shift register:
Quote
error: cannot convert 'LiquidCrystal_SR*' to 'LiquidCrystal*' for argument '1' to 'void m2_SetLiquidCrystal(LiquidCrystal*, uint8_t, uint8_t)'


Don't read too much into the code, top bit only really needed as I've edited the menubackend code I had.

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]

//DEBUG
#include <MemoryFree.h>
int tempMemCount = 0;
//

/*LCD*/
#include <LCD.h>
#include <LiquidCrystal_SR.h>      // ShiftRegister LCD
LiquidCrystal_SR iLCD(10, 11, 12); //Data,Clk,Enable.
//END LCD

//MENU SETUP
#include "M2tk.h"
#include "utility/m2ghlc.h"
//initialize menu
M2_LABEL(hello_world_label, NULL, "Hello World!");
M2tk m2(&hello_world_label, NULL, NULL, m2_gh_lc);
//initialize menuitems


unsigned long menuTimer = millis();             
byte timerEnable = 0;
//END MENU 




//INTERRUPT BUTTONS
const int pin = 13;  // test for interrupt
const int buttonPin = A0; // buttons can be read here
volatile byte buttonAct = 0; // flag, follow button press
volatile int buttonValue = 0; // button pressed analogue value
volatile int buttonPressed = 0;  // which button was pressed
volatile byte lastButtonPressed = 0; // prev button pressed
volatile byte state = LOW; // state of led on pin13
volatile 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;     
  }
}

olikraus

Code: [Select]
m2_SetLiquidCrystal(&iLCD, 20, 4);      //   <<<<<<------------- ERROR this line


The 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.cpp

Quote
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?

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

dannix


Code: [Select]
m2_SetLiquidCrystal(&iLCD, 20, 4);      //   <<<<<<------------- ERROR this line


The 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.cpp

Quote
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?

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


I tired renaming LiquidCrystal to LiquidCrystal_SR http://code.google.com/p/m2tklib/source/browse/dev/LiquidCrystal/m2ghlc.cpp renaming it as m2ghlc_sr but it hit another strange error "error: __c causes a section type conflict" it was flagged against my Serial.print messages that had flash strings in them like

Code: [Select]
Serial.print(F("freeMemory() reports "));

I had a look at MENWIZ which also supports LiquidCrystal, but all variations of ie shift register, I2C etc maybe there is some confusion over the names LiquidCrystal vs this "new" LiquidCrystal that I'm using?

Jomelo

hi, i have updated my lib "LCDMenu2"  for arduino version 1.0.1

Go Up