Pages: 1 ... 26 27 [28] 29 30 ... 32   Go Down
Author Topic: MENWIZ: yet another character lcd menu wizard library  (Read 68479 times)
0 Members and 2 Guests are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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?
Logged

rome
Offline Offline
Sr. Member
****
Karma: 17
Posts: 481
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

rome
Offline Offline
Sr. Member
****
Karma: 17
Posts: 481
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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...
« Last Edit: August 08, 2013, 05:36:31 am by brunialti » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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));
}
Logged

rome
Offline Offline
Sr. Member
****
Karma: 17
Posts: 481
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
// 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.
« Last Edit: August 09, 2013, 06:12:55 am by brunialti » Logged

rome
Offline Offline
Sr. Member
****
Karma: 17
Posts: 481
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

EDIT 30 AUGUST 2013
Please find here attached the version 1.3_1 beta.
It contains the MW_MENU_INDEX error fixed.

* MENWIZ_1_3_1_beta.zip (79.92 KB - downloaded 36 times.)
« Last Edit: August 30, 2013, 12:45:49 pm by brunialti » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

rome
Offline Offline
Sr. Member
****
Karma: 17
Posts: 481
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


You have to write a function something like this

Code:
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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much for the info..
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: August 16, 2013, 08:48:45 am by phenyl » Logged

rome
Offline Offline
Sr. Member
****
Karma: 17
Posts: 481
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No menwiz does not currently support directory browsing.
Yes the 1.3 does support editable text variables
« Last Edit: August 16, 2013, 09:47:15 am by brunialti » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

rome
Offline Offline
Sr. Member
****
Karma: 17
Posts: 481
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pakistan
Offline Offline
Sr. Member
****
Karma: 6
Posts: 357
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Brunitali,
Nice to see you are working on the sketch. I shall test the new version in the weekend and let u know.
Logged


rome
Offline Offline
Sr. Member
****
Karma: 17
Posts: 481
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Khalid. Nice to see you back again.
I updated the beta version with the MW_MENU_INDEX bug fixed.
« Last Edit: August 30, 2013, 04:12:56 pm by brunialti » Logged

Pages: 1 ... 26 27 [28] 29 30 ... 32   Go Up
Jump to: