MENWIZ: yet another character lcd menu wizard library

ok. I suggest to expand the whole new liquidcrystal library, with all the .h files

After putting in all new libs everything screwed up.
So I used all OLD libs and samples and got it to work again with the I2C lib.

I put this menu code in my sketch.

Then I started to add the libs from menwiz 0.3.0

Now it still screams for LCD.h where I created a new folder under libaries and put the .h and .cpp file in.
Compiling gives the LCD.h error.

Paco

Copied all .h and .cpp files in the I2c lib and got rid of the LCD.H problem.

Now still have this and more errors to come...........

I see. The New LiquidCrystal library is uncorrectly installed.
You have to cleanup at first:

  • delete current LiquidCrystal_I2C,LiquidCrystal and LCD directories
  • open the zip file MENWIZ_0_3_0.zip you find in github or in the last file attached to my post

and then install new LiquidCrystal and button libraries:

  • drag and drop into /Arduino-1.0/libraries directory the two directories LiquidCrystal_I2C and Buttons you find inside the zip file (LCD is not an independent lib, it is part of the New LiquidCrystal lib)
    After that you should see something similar to the two attache images.

You can try the new library running the Hello World example. If it works you can start with MENWIZ ...

Hope it helps

Sorry. My last answer was to your post #59
This is the anwer to #60

You are using the old version of MENWIZ. Please use the latest, as it is based on New LiquindCrystal lib and has a differente lcd initialization.
After installing the libraries get the latest example.
As you can see the initialization of the LCD is different

//MENWIZ ESAMPLE
#include <Wire.h>
//INSERT ALL THE FOLLOWING 4 INCLUDES AFTER INCLUDING WIRE LIB 
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <buttons.h>
#include <MENWIZ.h>

// DEFINE ARDUINO PINS FOR THE NAVIGATION BUTTONS
#define UP_BOTTON_PIN       9
#define DOWN_BOTTON_PIN     10
#define LEFT_BOTTON_PIN     7 
#define RIGHT_BOTTON_PIN    8
#define CONFIRM_BOTTON_PIN  12
#define ESCAPE_BOTTON_PIN   11

//Create global object menu and lcd
menwiz menu;
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

The code
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

works for my LCD (that has 0x27 I2C address). You need to put the I2C address of your actual LCD and the pins your LCD is using (the above pins could be ok for you, but I can't check) .The number 3 is the backligth pin.

If you see previous posts on this thread, I had the same problem with that library, but fm (author of the library) helped me a lot.

I'm using the lib by fm because it is much faster than the "original" and it supports lot of different lcd interfaces. So, should you get an lcd by different providers, it is likely to work properly.
This lib could become the new standard lib for Arduino.

I believe the time spent on it is extremely well done.

No need for sorry... :slight_smile:

My display worked with original I2C lib.
I think it uses LiquidCrystal_I2C lcd(0x27,20,4); as this was used in the original I2Csample
No idea what pin numbers are used.

At the rear of the display the I2C board is connected.
It has a bridge connector to light the backlight fixed and that is what I use.
So far no need to switch if ON or OFF by software.
So this connector is placed.

When your ideas are placed in the sketch and compiled I get no error.
But after reset the display is empty and the back light is flashing when the LED connector is placed.
It should be so easy...................:wink:

I2c sample does not work either.

Paco

You have the same LCD I tested. So it must work :slight_smile:

Brute force approach
Here attached you can find the libraries directory I'm using under Arduino-1.0 IDE.
Delete MENWIZ directories everywhere. Backup your current libraries directory. Delete it. Drag and drop libraries directory from the attached zip file.

Test it with the following code

//MENWIZ ESAMPLE
#include <Wire.h>
//INSERT ALL THE FOLLOWING 4 INCLUDES AFTER INCLUDING WIRE LIB 
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <buttons.h>
#include <MENWIZ.h>

// DEFINE ARDUINO PINS FOR THE NAVIGATION BUTTONS
#define UP_BOTTON_PIN       9
#define DOWN_BOTTON_PIN     10
#define LEFT_BOTTON_PIN     7 
#define RIGHT_BOTTON_PIN    8
#define CONFIRM_BOTTON_PIN  12
#define ESCAPE_BOTTON_PIN   11

//Create global object menu and lcd
menwiz menu;
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

//instantiate global variables to bind to menu
int tp=0;
int  gp=26;
boolean wr=0;

void setup(){
  _menu *r,*s1,*s2;
  _var *v; 
  int  mem;

  Serial.begin(19200);  
  
  // have a look on memory before menu creation
  Serial.println(sizeof(menwiz));
  mem=menu.freeRam();
  
  // inizialize the menu object (20 colums x 4 rows)
  menu.begin(&lcd,20,4);

  //create the menu tree
  r=menu.addMenu(MW_ROOT,NULL,"MAIN MENU");           //create a root menu at first (required)
    s1=menu.addMenu(MW_SUBMENU,r,"MEASURE SUBMENU");  //add a submenu node to the root menu
      s2=menu.addMenu(MW_VAR,s1,"Choose T scale");    //add a terminal node in the menu tree (that is "variable"); 
          s2->addVar(MW_LIST,&tp);                    //create the terminal node variable of type OPTION LIST and bind it to the app variable "tp"
          menu.getErrorMessage(true);
          s2->addItem(MW_LIST,"C°");             //add an option to the OPTION LIST
          s2->addItem(MW_LIST,"F°");           //add an other option to the OPTION LIST
          s2->addItem(MW_LIST,"Raw data");     //add the third and last option to the OPTION LIST
      s2=menu.addMenu(MW_VAR,s1,"Set T1 trigger");
          s2->addVar(MW_AUTO_INT,&gp,10,100,2);
      s2=menu.addMenu(MW_VAR,s1,"Enable heater");
          s2->addVar(MW_BOOLEAN,&wr);

  //(optional) create a splash screen with some usefull infos 
  //the character # marks end of line (WARNING: this could be changed in the next releases)
  //(tip): use preallocated internal menu.sbuf buffer to save memory space!
  sprintf(menu.sbuf,"MENWIZ TEST V %s\n.Free mem. :%d\n.Used mem  :%d\n.Lap secs  :%d",menu.getVer(),menu.freeRam(),mem-menu.freeRam(),5);
  menu.addSplash((char *) menu.sbuf, 5000);
 
  //declare navigation buttons (required)
  // equivalent shorter call: menu.navButtons(9,10,7,8,11,12);
  menu.navButtons(UP_BOTTON_PIN,DOWN_BOTTON_PIN,LEFT_BOTTON_PIN,RIGHT_BOTTON_PIN,ESCAPE_BOTTON_PIN,CONFIRM_BOTTON_PIN);

  //create a user define screen callback to activate after 7 secs since last button push 
  menu.addUsrScreen(msc,7000);
  }

void loop(){
  // NAVIGATION & DRAWING MANAGEMENT
  menu.draw(); 
  //PUT APPLICATION CODE HERE
  }

// user defined default screen
void msc(){
  sprintf(menu.sbuf,"User screen\nUptime (s): %ld\nFree mem  : %d\n\n",millis()/1000,(int)menu.freeRam());
  menu.drawUsrScreen(menu.sbuf);
  }

Let me know

libraries.zip (3.52 MB)

What I see, is that the part number on the LCD backpack is a PCF8574. For that ASIC the I2C address should be in the range of 0x38. It depends also on how they've configured the address lines on it.

If that is not the correct value try in the following range: (0x38 - 0x3F). You will need to look at their datasheet.

As in post #63, if I understood correctly, it seems that the lcd at certain point worked, so I suggest also to use that address...

Thanks for your assistance.

This works.

Paco

I'm considering to add a variable pinpointing method, that is: use EEPROM library to save actual values of the user defined variables in order to let settings be available even after an arduino restart.
It is not very clear to me if the 1024 bytes available on at328 are the same used by F() metafunction.
In this case I have to hand off or consider different implementation ways.

By the way ... floating points variables are now implemented and will be available on next prerelease.

Wow, long thread!

fm, brunialti, olikraus, just to side track this thread once more, I've done some improvement to my library and now it has these neat features. By no means can I support newbies with these features that can't even be turned into generic library function calls but to more experienced people trying to make money with their products, these features add values. Hope I can use fund I get from professional help to support the free end of my library (actually all library function calls are free to use but how you use them to make advanced features are not yet open).

http://arduino.cc/forum/index.php/topic,101503.0.html

I'll be adding more features including variable length of list (say you adjust one parameter and the list expands to show its details).

Liudr, I saw the video. Impressive.

My goal with MENWIZ is to return some to the community. I've got lot of support from the social and as far as I can I would like to give back my contribute. I have some ideas about new clever functionalities and cleaner code and architecture. If I had time I would even like to write a code generator.But I do'nt know if there are interested candidate users. With a little bit more powerfull platform I would be able to do really interesting things...

The point you arise about the balance between free and charged efforts is also a good point. I think it is easier on the hw side.
On my side (sw) i see very difficult to get money from. By now I'm surprised how short has been the learning curve in Arduino. Of course I've been helped by long programming experience.

Anyway, untill i'll get fun i'll develop menwiz and other libs... This is not o promise , it is a menace ... :slight_smile:

Great! I maintain half a dozen arduino libraries and this one (phi_prompt) gets most attention since it has practical use in products. I'm trying to support the beginners with simple function calls that needs not much programming skills. I'm also helping intermediate users with standard function calls. But I can't support advanced features freely since that would be too much work especially when someone "that doesn't know which end of the equal sign does what" wants fancy features with the advanced features but is not in the right coding skill level to do it.

I posted the version 0.4.0 at GitHub - brunialti/MENWIZ: ARDUINO LCD menu library: short user code to manage complex menu structures and here attached
Added support for float and byte variable data types.
Feedback are welcome.

MENWIZ_0_4_2.zip (517 KB)

I've just tried the menwiz library and I'm totally satisfied :slight_smile:
clean, concise code, support for New LiquidCrystalLibrary, plus it's easily hackable if you want to insert your own input routines (just replace the code of menwiz::scanNavButtons() with your own, in the .cpp file)

I have one question though: I see that the examples take about 16K of flash. Could this be lowered? For example, I'm using a 595 3-wire LCD so I suppose I don't need to include the Wire.h library(?). But when I don't include it I get an error. In general, could I further squeeze menwiz's footprint?

I'm happy it can be usefull for you.
Wire is not directly required by menwiz but isi called by LiquidCrystalLibrary (at least on the I2c version). I did'nt test with a 3wire lcd so i'm not 100% sure. The wire include is called not only by the sketch but also by MENWIZ.h. I frankly do'nt know if it is required by LiquidCrystalLibrary LCD.h (the virtualized lcd managemnt layer) inlcude.
I implemented a menwiz version using flash memory for menu item strings. it save some precious sram. About flash ram: I unfortunately do not think the total amount is significantly squeezable , due to the coding approach (preallocated objects vectors). I could save some memory with a more aggressive dynamic allocation, but it could increase small sketches (sketches with small menu structures) footprint due to the added pointer tables.
You can carefully tweak the following values inMENWIZ.h, provided you understand exactly what they mean (use menwiz::getErrorMessage while debugging)

// DIMENSIONS (DIMENSIONAL LIMITS OF STATICALLY ALLOCATED STRUCTURES)
// ---------------------------------------------------------------------------

#define MAX_MENU       15   //maximum number of nodes (absolute supported max number of addMenu calls)
#define MAX_OPTXMENU   5    //maximum number of options/submenus for each node (max number of addItem call for each menu item) 
#define MAX_BUFFER     84   //dimension=columns x rows + rows. CHANGE IT IF LCD IS BIGGER/SMALLER THAN 4X20 CHARS

The footprint in Leonardo board shoud be even worse: as it manage USB/serial directly you must add 4k more (but that is true for all sketches ...)

By the way I'm currently trying to network integrate a raspberrypi with arduino, using mqtt protocol. I can assure that arduino is really simple to use .... :slight_smile:

Hi brunialti,
I am also interested in your library for my solar tracker circuit, but i am also using ShiftRegLCD 3 wire 20x4 LCD. Is their any chance to use your library. Actually i am very thin in using more pins for LCD as my sun tracker almost consumed all the pins on 328PU IC.

The LCD is connected to DIY 3 wire 12x12 keypad..

Liuder, your lcd library is good but if you can post some very simple example it will be beneficial. one question, i am using 3 wire LCD using ShiftRegLCD library, do your library support it?

The current MENWIZ library is using the ¨New LiquidCrystal" library, a.k.a. "LCD library" you should be able to connect all the supported LCD drivers that it supports.

Currently the New LiquidCrystal library supports the following LCD drivers: I2C, SR latching and non-latching configurations 2 and 3 wires, 4 bit parallel and 8 bit parallel LCDs.

The way the New LiquidCrystal was developed makes adding new LCD drivers very easy. If you use LCD abstract class references in our project or other libraries, it is a trivial plug-and-play configuration.

Here is a link to its wiki: https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home. You will also find wiring schematics for all supported configurations.

I suggest to try the new LiquidCrystal lib alone with your lcd befor using MENWIZ.
By the way if you have lots of devices can I suggest to expore the I2C bus?