Here following the manual instructions:
MENWIZ uses the Buttons library to manage standard pushbuttons (each one using 1 Arduino pin). If you want to use your own device (for instance analog buttons, rotary encoders etc.) to replace the internal functions you need to write your own function and to declare it to MENWIZ library using addUsrNav method.
void addUsrNav(int (*f)(), int nb)
where f is your function and nb is the number of buttons emulated by f. The only allowed values for nb are 6 or 4.
If you use addUsrNav you have not to use the navButtons function.
The user defined function will replace the following internal one:
int menwiz::scanNavButtons(){
if(btx->BTU.check()==ON){
return MW_BTU;}
else if (btx->BTD.check()==ON){
return MW_BTD;}
else if (btx->BTL.check()==ON){
return MW_BTL;}
else if (btx->BTR.check()==ON){
return MW_BTR;}
else if (btx->BTE.check()==ON){
return MW_BTE;}
else if (btx->BTC.check()==ON){
return MW_BTC;}
else
return MW_BTNULL;
}
The user defined function must return one of the following integer values, defined in MENWIZ.h (allways use the literals instead of the values, as values can be changed in new MENWIZ versions):
// BUTTON CODES
// ----------------------------------------------------------------------
#define MW_BTNULL 30 //NOBUTTON
#define MW_BTU 31 //UP
#define MW_BTD 32 //DOWN
#define MW_BTL 33 //RIGTH
#define MW_BTR 34 //LEFT
#define MW_BTE 35 //ESCAPE
#define MW_BTC 36 //CONFIRM
The returned integer code represent the last pushed button, if any, or MW_BTNULL if no button has been pushed since last call.
The user defined function, (same as the replaced built-in scanNavButtons) is called once for every time the method menwiz::draw is called.
The returned code will activate the behavior associated to the pushed button (or no behaviour if MW_BTNULL is returned). Any other return value (or no explicit return value) makes the library behavior unpredictable.
Resuming
in case of any custom device (as analog button or any other) you must:
- write your own function in the sketch (the name is up to the user)
- the function must return one of the 7 values above, depending on the pushed button (or the simulated ones)
- the function must be declared to MENWIZ with the method addUsrNav
In your case the custom function should replace the btx->BTx.check() function with mcp.digitalRead(<button x>).
That should solve the button mapping.
Tha other main problem to solve is how to port the lcd functions. If the adafruit library has the same functions as LiquidCrystal library as claimed it should'nt be a problem. Of course that is something you have to check and implement.