Lcd menu, help needed

Hello all!

I'm new to all of this and I've been trying to build a menu for an 20x4 lcd (with I2C backpack).
What I would like to have is first a few pages with live data,
and after a settings menu, where I can adjust some variables,
and let the system perform some actions.

The closest I got to my final goal is with the Menwiz library.
I'm able to change and execute what I want.
The only thing I can't figure out is how to display the live data.

Other libraries I've tried are:
phi_prompt: can't figure out how to get the I2C working with that.
MenuBackend: took the example from coagula.org, works, but no live data.
Menu: has library issues I can't figure out (same goes for some others)

Could somebody kick me in the right direction?

Thanks,

Bart

Could somebody kick me in the right direction?

I'd be OK with kicking you (for not posting code; for not explaining what the problems were; etc.), but I'm not sure that it would accomplish anything. Perhaps a few hints would be better...

Hi!

These days I'm trying the MenuBackEnd library and I think that I have mostly understand it. I have also an LCD 1602, so my situation seems quite similar to yours.

There are four main routines that you must configure:

  1. MenuSetup():
    This must be called upon setup() and defines the behaviour of your Menu Items, that it is to say the linkage between them and how the user moves amongst them.

  2. NagivateMenus():
    This must trigger a menuChangeEvent with menu.moveRight() or menu.moveDown() methods associated to a push-button, an incoming character from the Serial port or anything you can imagine.

  3. menuChangeEvent:
    This routine defines the change event triggered for each menu item.

  4. menuUseEvent:
    The loop() should call this as menu.use(). This must call any routine to refresh RTC or I/O and display it on the LCD.

I'm stuck just at the beginning of this, because I'm not able to define a suitable item for the menu root. I've posted another question in the Forum but there is no answer. I'll directly try it with the author of this library.

Best Wishes for 2014

MenWiz has the ability to display a user screen, and the menu will invoke a function in your code when the menu times out.

What you need to do is format the string you want to display (with the 'live' data) and then call the menWiz function to display it for you. I think (from memory) that the menwiz example uses this to display the millis() (this is live) and the free memory (which is live but does not change much).

If your question is how to change the data screens, this code may help.

void myDisplay(void)
// Callback from the menu system to display my own screen data
{
  static	uint8_t	state = 0;
  static  char	buf[7];
  static	uint32_t	tmStart = 0;

  // switch user screens once every period
  if (millis() - tmStart >= 3000)
  {
    state++;
    tmStart = millis();
  }

  switch (state)
  {
  case 0:
    // line 1
    strcpy(menu.sBuf,"Uptime : ");
    strcat(menu.sBuf, itoa((int)(millis()/1000), buf, 10));
    // line 2
    strcat(menu.sBuf,"\nFreeRAM: ");
    strcat(menu.sBuf, itoa((int)menu.freeRAM(), buf, 10));
    break;

  case 1:
    // line 1
    strcpy(menu.sBuf,"Int8 : "); 
    strcat(menu.sBuf, itoa(varInt8, buf, 10));
    // line 2
    strcat(menu.sBuf,"\nInt16: ");
    strcat(menu.sBuf, itoa(varInt16, buf, 10));
	break;

  case 2:
    // line 1
    strcpy(menu.sBuf,"Bool : ");
    strcat(menu.sBuf, varBool ? "YES" : "NO");
    // line 2
#if USE_FLOAT
    strcat(menu.sBuf,"\nFloat: ");
    strcat(menu.sBuf, dtostrf(varFloat, 0, FLOAT_DEC, buf));
#else
    strcat(menu.sBuf,"\n");
#endif
    break;

  case 3:
    // line 1
    strcpy(menu.sBuf,"Short List: "); 
    strcat(menu.sBuf, itoa(varShortList, buf, 10));
    // line 2
    strcat(menu.sBuf,"\nLong  List: ");
    strcat(menu.sBuf, itoa(varLongList, buf, 10));
	break;

  default:
    state = 0;
    return;		// don't update the screen
  }

  menu.drawUserScreen(menu.sBuf);
}