Go Down

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

Khalid

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?
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...:)

fm

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.

   

brunialti

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?

brunialti

@straddlethemoon
If you want use your own input routine, instead of replacing menwiz::scanNavButtons() code (breaking the library compatibility) you can use  the menwiz::addUsrNav to declare your own routine. After declaration the library will use your code instead of the built-in one ...

Khalid

Hi,
Can i use this library with your Menu?
http://code.google.com/p/arduinoshiftreglcd/http://code.google.com/p/arduinoshiftreglcd/
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

In the url it is stated that the library is now included in the New LiquidCrystal library. As far as this statement is true, you should be able to use it with your LCD. I'm not able to test it directly.
I suggest at first to build some sort of  "Hello World" sketch able to drive your LCD using the before mentioned library. When it works, you can add to your sketch  the MENWIZ and the other required libs , with the same order suggested in the examples (this is a Arduino peculiarity I'll never be acquainted to...).

Ciao!

straddlethemoon

thank you for your reply
actually 32k of flash is plenty of space for most projects, and it's better to have good, reliable code at the expense of memory. It is only one particular project I'm working with which uses a ton of libraries (soft serial, tiny gps, lcd, keypad, SD card etc) and takes about 20k as it is now that made me think that I can't add menwiz although it would make things easier


brunialti

Of course is up to you. I think it can be shrinked a little bit (say 1/2 k max). But I need time to work about. Consider that if menwiz will use flash memory for strings  (in order to let some ram free for variables, parameters and so on) it will use flash memory and it could affect the available space.
Consider Mega board o other with same processor.

Khalid


That's the nice thing about the "New LiquidCrystal" library, it already supports a wide range of LCD controllers:

  • I2C base on the PCF8574 or compatible

  • 4bit and 8bit parallel

  • ShiftRegister: 3wire, 2wire, 1wire (beta)



Your code would look something like this:

Code: [Select]

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C myLCD (0x27);  // Base address of IO expander

void setup ()
{
   menu.begin ( &myLCD, 20, 4 );
   ...
}


Assuming that your menu class makes the following modification:
Code: [Select]

#include <LCD.h>

void menu::begin ( LCD *iLCD, uint8_t cols, uint8_t rows )


With this LCD library you will get almost 32 fps as opposed to the one you are currently using that barely does 10fps.

Now if you want to use for example a 4bit parallel interface, the only thing that would change in you code is the creation of the LCD object:

Code: [Select]

#include <LiquidCrystal_I2C.h>

LiquidCrystal myLCD ( 12, 11, 5, 4, 3, 2 ); // Rs, E, D4, D5, D6, D7

void setup ()
{
   menu.begin ( &myLCD, 20, 4 );
   ...
}

Not a lot to do in your code really.

You are kind enough for explaining the codes. I would be really very thankful if you please elaborate changes for ShiftRegLCD say 3-wire LCD example skecth like you posted above.
Regards
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...:)

fm

You can find the initialisation code in the project wiki for all supported LCD drivers, simple schematic and associated int code.
   

Khalid

#85
Jun 15, 2012, 09:00 pm Last Edit: Jun 15, 2012, 09:08 pm by Khalid Reason: 1
Thank You:) I am working on it.. Very good explanation there.. One more favour i need .. I am using 6-Buttons that are attached to single analoge pin with different resistors...Your NavigateButton command shows each button connected to digital pins which takes 4 minimum or 6 maximum number of digital pins:(...
I am using following code for getting the values of each button:
Code: [Select]

// ===================================================================
// Convert ADC value to key number
//read the keyboard routine
int get_key(unsigned int keyboardValue){
 int k;
  keyboardValue = analogRead(ANALOG_PIN); // read the value (0-1023)
  if (keyboardValue <25){k=0; return k;}
  if ((keyboardValue >25) && (keyboardValue < 67)){k = 1;return k;}
  if ((keyboardValue >67) && (keyboardValue < 108)){k = 2;return k;}
  if ((keyboardValue >108) && (keyboardValue < 162)){k = 3;return k;}
  if ((keyboardValue >162) && (keyboardValue < 253)){k = 4;return k;}
  if ((keyboardValue >253) && (keyboardValue < 361)){k = 5;return k;}
  if ((keyboardValue >361) && (keyboardValue < 479)){k = 6;return k;}

 //NOTE: the values used above are all halfway between the value obtained with each keypress in previous test sketch
 
//  while (keyboardValue > 25) {
  //  delay (100);
  //  keyboardValue = analogRead(ANALOG_PIN); // read the value (0-1023)
 // }//wait until key no longer being pressed before continuing
     
 
  //Serial.println(keypressed);      // print the value back to the Serial view window on your PC
  delay(100);                     // wait 100 milliseconds before the next loop
                    }
 //end of read the keyboard routine
// new key detection routine, without delays!

int     lastKeyEvent = 0;
int     curKeyEvent  = 0;
int     keyToReturn  = 0;
boolean keyToProcess = false;
int     adc_key_in   = 0;
int detectKey()
{
   keyToReturn = -1;
   adc_key_in = analogRead(ANALOG_PIN);       // read the value from the sensor  
   curKeyEvent = get_key(adc_key_in); // convert into key press
   if (curKeyEvent != lastKeyEvent)
   {
       if (!keyToProcess)
       {
           lastKeyEvent = curKeyEvent;
           keyToProcess = true;
       }
       else
       {
           keyToReturn = lastKeyEvent;
           lastKeyEvent = -1;
           keyToProcess = false;
       }
   }
   return keyToReturn;
}


and this is in my Void loop() function:
Code: [Select]
int keyEvent = detectKey();
Serial.println(keyEvent);
if (keyEvent >= 0){
 switch (keyEvent){


Is it possible to use analog buttons in MENWIZ?..If yes then this shall be a wonderful Menu:)
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

#86
Jun 15, 2012, 10:06 pm Last Edit: Jun 15, 2012, 10:35 pm by brunialti Reason: 1
Khalid,
I am not sure to understand your needs. I try to resume the procedure.
if you want to use your own device to replace the standards buttons managed by MENWIZ and Buttons libraries (and declared with navButtons functions) you need to write your own function and to declare it to MENWIZ library using  addUsrNav method.
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:

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, as the internal 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 no button has been pushed).
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

WARNING: THE USER DEFINED FUNCTION SIMULATING BUTTONS HAVE TO RETURN PUSHED BUTTON CODES JUST ONCE, AS IT WOULD A STANDARD DIGITAL BUTTON! OTHERWISE THE LIBRARY ASSUME MULTIPLE BUTTON PUSHES, ONE FOR EACH TIME THE FUNCTION RETURNS THAT "BUTTON" CODE....

That should be all.
Does it make sense in your case?.

brunialti

Here attached please find a tour guide to the  library.
It can be usefull to decide if and how to use MENWIZ

Khalid

Dear brunialti,
Thank you for such a nice PDF tour of MENWIZ... You are very kind for answering our silly question. I am stuck with the buttons controlled with single Analog Pin.

I am using following Button Library:
http://arduino.cc/playground/Code/AnalogButtons

Can you kindly look into and give me some solution to use this library with MENWIZ?..My programming is not that good i seek your help in this.
Regards
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

#89
Jun 16, 2012, 03:36 pm Last Edit: Jun 16, 2012, 03:38 pm by brunialti Reason: 1
At first glance it could, as it seems to emulate multiple "digital" buttons, with integrated debouncing functionalities.
As long  as it gives you back a univoke code for pushed button for each call and "forget" (clean) that given event, it should work...

Go Up