MENWIZ: yet another character lcd menu wizard library

Kalid, thank you a great help !! ( and exacly what a "dummy" like me need ! explanation and example ! thanks !! )

This is my solution for the Lcd Keypad Shield with the anologic buttons !
I think something like a delay has to be put somewhere because sometimes I have to push the button twice ... let give me a bit more time to fix it :slight_smile: (or help :slight_smile: )

/*
  Analog values representing the pushbutton value are depending on the resitor value used.
   Test the values first with the serial.monitor
   */
  buttonValue = analogRead(buttonPin); //analog value to simulate the pushed buttons
  Serial.println(buttonValue );
  
  if(buttonValue >= 850)
  {
    buttonPressed = 0;
    noButtonPressed(); // is calling an extra fucntion
  }
  else  if(buttonValue >= 380 & buttonValue <= 450)
  {
    buttonPressed = 4;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 200 & buttonValue <=300)
  {    
    buttonPressed = 3;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 0 & buttonValue <=50)
  {    
    buttonPressed = 2;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 80 & buttonValue <=150)
  {    
    buttonPressed = 1;
    buttonAct = 1; // set the menu flag1
  }
}

int noButtonPressed()
{
  return MW_BTNULL;
}

As soon I do my homework ...

(from the Master Brunialti)
at a first glance I see some point to check:

  • the following line is not necessary: MW_navbtn=4;
  • when you use addusernav the declared callback should be in charge with button checking and code returning. The call to readButtons() should be therefore inside the callback funcion , not in the loop. the code works the same, but is more polite
  • you defined the menu framework, but after each creation of menu nodes of type MW_VAR you need to create the variable with addVar in order to let the menu working.

I will post the complete code
Thanks