Go Down

Topic: MENWIZ: yet another character lcd menu wizard library (Read 85911 times) previous topic - next topic

liquidarts

@brunialti

Will there be an update to MENWIZ to include adafruits I2C RGB LCD Sheild or is there a way I can implement using the shield with MENWIZ?

brunialti

I never used such a product. It seems very similar to many other shields working with MENWIZ lib.Neverthless as far as the provided library is Liquidcrystal-like it should work.
Of course you need to use addUsrNav and write your own function to map the shield buttons to the MENWIZ expected return codes.

brunialti

#407
Aug 08, 2013, 11:55 am Last Edit: Aug 08, 2013, 12:36 pm by brunialti Reason: 1
Dear all,
I won my lazyness and coded the next version 1.3 with the following improvements:

It is now possible to set up to 3 users and to set access grant to submenus for each one of them with the following methods:
Code: [Select]
menwiz::setCurrentUser(int);
_menu:: setBehaviour(MW_GRANT_USERx, boolean);


A new data type is now available: the long awaited editable text MW_EDIT_TEXT. It works for now only in the 6 buttons mode ... until one of you will propose a convenient user model for 4 buttons :-)

The overall footprint should be the same. And even better, it leaves more ram available (few tens of bytes...)

Is there any brave to test it before the final delivery? Be warned, I did'nt tested it really extensively despite a quite large portion of code has beeen rewritten...

liquidarts


I never used such a product. It seems very similar to many other shields working with MENWIZ lib.Neverthless as far as the provided library is Liquidcrystal-like it should work.
Of course you need to use addUsrNav and write your own function to map the shield buttons to the MENWIZ expected return codes.


How would I use the buttons from the mcp23017 with the following example to add the addUsrNav
Code: [Select]
#include <Wire.h>
#include "Adafruit_MCP23017.h"

// Basic pin reading and pullup test for the MCP23017 I/O expander
// public domain!

// Connect pin #12 of the expander to Analog 5 (i2c clock)
// Connect pin #13 of the expander to Analog 4 (i2c data)
// Connect pins #15, 16 and 17 of the expander to ground (address selection)
// Connect pin #9 of the expander to 5V (power)
// Connect pin #10 of the expander to ground (common ground)

// Input #0 is on pin 21 so connect a button or switch from there to ground

Adafruit_MCP23017 mcp;
 
void setup() {
  mcp.begin(); // use default address 0

  mcp.pinMode(0, INPUT);
  mcp.pullUp(0, HIGH); // turn on a 100K pullup internally

  pinMode(13, OUTPUT); // use the p13 LED as debugging
}



void loop() {
  // The LED will 'echo' the button
  digitalWrite(13, mcp.digitalRead(0));
}

brunialti

#409
Aug 09, 2013, 11:46 am Last Edit: Aug 09, 2013, 01:12 pm by brunialti Reason: 1
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:

Code: [Select]
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):
Code: [Select]

// 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.

brunialti

#410
Aug 09, 2013, 01:06 pm Last Edit: Aug 30, 2013, 07:45 pm by brunialti Reason: 1
EDIT 30 AUGUST 2013
Please find here attached the version 1.3_1 beta.
It contains the MW_MENU_INDEX error fixed.

liquidarts

Then for the define statments all I would need to do is the following correct?

#define MW_BTNULL    0 
#define MW_BTU         = mcp.digitalRead(0)   //UP
#define MW_BTD         = mcp.digitalRead(1)   //DOWN
#define MW_BTL         = mcp.digitalRead(2)   //RIGTH
#define MW_BTR         = mcp.digitalRead(3)   //LEFT
#define MW_BTE         0 //ESCAPE
#define MW_BTC         = mcp.digitalRead(4)   //CONFIRM

brunialti


You have to write a function something like this

Code: [Select]
int myButtons(){
 if(mcp.digitalRead(0)){
   return MW_BTU;}
 else if (mcp.digitalRead(1)){
   return MW_BTD;}
 else if (mcp.digitalRead(2)){
   return MW_BTL;}
 else if (mcp.digitalRead(3)){
   return MW_BTR;}
 else if (mcp.digitalRead(4)){
   return MW_BTE;}
 else if (mcp.digitalRead(5)){
   return MW_BTC;}
 else
   return MW_BTNULL;
 }


Check the correct numebers (0-5) for the buttons...
Please have a look to the thread. There are some examples about how to write this function.


phenyl

#414
Aug 16, 2013, 03:38 pm Last Edit: Aug 16, 2013, 03:48 pm by phenyl Reason: 1
Hi,

I was looking for an LCD Menu and came across your library yesterday. The examples work well on my leonardo, thank you very much for your work!
Is it possible for example to scroll through a dirctory on an sd-card, and chose a file to give as a parameter to a function?
I read through the last few pages and couldn't really find anything, I believe SD cards were mentioned once in the thread, in passing.



Also a few posts back the generation of strings was discussed. Could this be used to generate a new filename to be passed to a data logger for example?
Thank you very much.

edit: I just downloaded beta 1.3 and saw that in the change log:
"New data type added: the long awaited editable text MW_EDIT_TEXT. It works for now only in the 6 buttons mode. "
so the second part of my question seems answered, thank you very much.

brunialti

#415
Aug 16, 2013, 04:44 pm Last Edit: Aug 16, 2013, 04:47 pm by brunialti Reason: 1
No menwiz does not currently support directory browsing.
Yes the 1.3 does support editable text variables

wired57

I'm using version 1.3 and I can't seem to disable the index on the upper right side of my screen.  MW_MENU_INDEX

thanks

brunialti

Sorry regressive error.... it will be fixed in the final version

Khalid

Hi Brunitali,
Nice to see you are working on the sketch. I shall test the new version in the weekend and let u know.
Simply...You can't afford me..

Author Of:
http://my-woodcarving.blogspot.com/
http://www.free3dscans.blogspot.com/
http://my-diysolarwind.blogspot.com/

Oops..some one gave me Karma...:)

brunialti

#419
Aug 30, 2013, 07:46 pm Last Edit: Aug 30, 2013, 11:12 pm by brunialti Reason: 1
Hi Khalid. Nice to see you back again.
I updated the beta version with the MW_MENU_INDEX bug fixed.

Go Up