How to display generic menu on Nokia LCD

Hi,
My question is how to display generic menu on LCD (5110 Nokia). At the moment I am working on code from examples.

#include <menu.h>
#include <menuIO/serialOut.h>
#include <menuIO/chainStream.h>
#include <menuIO/serialIn.h>
#include <Adafruit_GFX.h>     //Nokia 5110 LCD library for graphics
#include <Adafruit_PCD8544.h> //more about Nokia LCD => https://lastminuteengineers.com/nokia-5110-lcd-arduino-tutorial/

Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
int pinLcdBL = 9; //pin for LCD backlight (use PWM pin for dimming)
int contrast = 57; //contrast for LCD 0-100

using namespace Menu;

#define LEDPIN LED_BUILTIN
#define MAX_DEPTH 1

unsigned int timeOn=10;
unsigned int timeOff=90;

MENU(mainMenu, "Blink menu", Menu::doNothing, Menu::noEvent, Menu::wrapStyle
  ,FIELD(timeOn,"On","ms",0,1000,10,1, Menu::doNothing, Menu::noEvent, Menu::noStyle)
  ,FIELD(timeOff,"Off","ms",0,10000,10,1,Menu::doNothing, Menu::noEvent, Menu::noStyle)
  ,EXIT("<Back")
);

serialIn serial(Serial);
MENU_INPUTS(in,&serial);

MENU_OUTPUTS(out,MAX_DEPTH
  ,SERIAL_OUT(Serial)
  ,NONE//must have 2 items at least
);

NAVROOT(nav,mainMenu,MAX_DEPTH,in,out);

void setup() {
  display.begin();    //Initialize Display
  display.setContrast(contrast); // change the LCD contrast 
  display.clearDisplay(); // Clear the display buffer.
  display.display();

//display some text on LCD
  display.println("Menu 4.x");
  display.println("Use keys + - * /");
  display.println("to control the menu navigation");
  display.display();
 
  pinMode(LEDPIN, OUTPUT);
  Serial.begin(9600);
  while(!Serial);

}

bool blink(int timeOn,int timeOff) {return millis()%(unsigned long)(timeOn+timeOff)<(unsigned long)timeOn;}

void loop() {
  nav.poll();
  digitalWrite(LEDPIN, blink(timeOn,timeOff));
}

As far as I was able to figure it out a part of the code to display text on LCD should be (plus additional stuff like size, cursor position etc.):

  display.println("text");
  display.display();

It won't work without display.display();

i think you need to understand how NAVROOT() works

Could you provide me some starting point?

Is it this part (from here ArduinoMenu/nav.cpp at master · neu-rah/ArduinoMenu · GitHub)?

void navRoot::initPath(idx_t d) {
  for(idx_t n=0;n<=d;n++)//initialize path chain for this root (v4.0)
    path[n].root=this;
}
void navRoot::useMenu(menuNode &menu) {
  path[0].useMenu(menu);
  reset();
  refresh();
}

I am affraid I don't understand it.

neither do i. I assume use of the LCD comes down to a print function that displays just a few lines of information

i'm a big fan of tables, capturing what the code needs to do as data instead of a spaggetti bowl of logic.

with a menu'd system, you need to know what to display and what to do for the inputs possible for what is being displayed. here's something i recently did for a model railroad turntable controller based on this commercial unit using 4 7-segment displays and 4 buttons.

#define FArg  int8_t *p
typedef void(*Func_t)(FArg);

typedef struct {
    const char *lbl;
    const char *pfx;

    void (*up)  (int8_t *);
    void (*dn)  (int8_t *);
    void (*go)  (int8_t *);
    void (*esc) (int8_t *);

    int8_t     *ptr;
} Menu_t;

Menu_t menu [] = {
    { "tr",   "tr",   posInc, posDec, trGo,  escape, &pos  },
    { "CAL",  "CAL",  NULL,   NULL,   cal,   escape, NULL  },
    { "Prog", "pr",   prUp,   prDn,   prGo,  prEsc,  &pos  },

    { "dEl",  "d",    posInc, posDec, delGo, escape, &pos  },
    { "rEs",  "rEs",  NULL,   NULL,   res,   escape, NULL  },
    { "id",   "id",   NULL,   NULL,   ver,   escape, NULL  },
};

the entries in the table indicate what characters to display in different modes and function pointers doing some action when one of the 4 buttons is pressed AND that menu has been selected. Elsewhere, there is code that sequences thru the menu items with up/down buttons and using the go button to select that menu item

something like the nokia display could have multiple tables for main, sub and sub-sub menus. Hopefully you see how using tables and function pointers can make managing a complicated menu system manageable and expandable by simply adding new table-entries or tables and the sub-functions to perform what's needed

Thanks a lot for an input. I was hoping that it will be something simple. Probably you are right and I will switch to menu with more transparent code. I was hoping to use that menu as it seems to be ok in terms of inputing data in different ways. Anyway, thanks a lot for your time and I will try something different like you tables.