Go Down

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

#### Khalid

#360
##### Feb 04, 2013, 04:20 am
Declare your variable as Float and
Code: [Select]
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...

#### Silverdog63

#361
##### Feb 04, 2013, 09:19 am
Thanks Khalid,
I had doubt because they told me to not use float because sometimes gives erratic rounding values ....
don't know why ....

Quote
changing the variable from INT to FLOAt is ok ?

Sorry I dnon't know how many times you need telling
DO NOT USE A FLOAT!!!!!
You will suffer from rounding errors. Mathematical operations will not be commutative.
What do you not understand about using an int with the numbers greater than your resolution?

#### Khalid

#362
##### Feb 04, 2013, 02:56 pm

Thanks Khalid,
I had doubt because they told me to not use float because sometimes gives erratic rounding values ....
don't know why ....

I am using it without any trouble...Without the Float you will unable to do step increment like 0.1mm etc...
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...

#### robtillaart

#363
##### Feb 04, 2013, 07:07 pmLast Edit: Feb 04, 2013, 07:16 pm by robtillaart Reason: 1
Saw this one about floats: "Working with floating point is like moving piles of sand. Every time you move one you lose a little sand and pick up a little dirt."

In practice you can do a lot of things with floating points, they have their own points of extra attention, just like integers and bytes etc.

e.g. adding 0.1 in a loop give another kind of error that calculating the next value with a multiply

Code: [Select]

float f = 0;
while (f< 1.0)
{
Serial.println(f, 8);
f += 0.01;
}

float f = 0;
int n = 0;
while ( f < 1.0);
{
Serial.println(f, 8);
n++;
f = n*0.01;
}

In the first loop 100 rounding errors add up, in the second there is only one rounding error (OK it uses an extra integer)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### HansF

#364
##### Feb 04, 2013, 10:31 pm
I am having trouble when using the MW_BOOLEAN. When changing the value, the display updates from OFF to ON in a flicker and goes back to OFF again  :~

(I think it worked on MENWIZ 1.0.2.). I have searched the forum and looked at the examples, but found no help. Any of you have an idea of what I am missing?

Code: [Select]
boolean mashPump = false;        // on-off state for pump
boolean running = false;         // on-off state for BrewCtrl, execute the pid control or only do logging

void setup() {
Serial.begin(9600);
menu.begin(&lcd,20,4);                  //declare lcd object and screen size to menwiz lib

The full code is attached to post #358.

#### jbaum81

#365
##### Feb 06, 2013, 05:47 amLast Edit: Feb 06, 2013, 06:04 am by jbaum81 Reason: 1
Hello, First I want to thank you for an amazingly cool library, it has enhanced my project so much.

So here is what I'm running into I wonder if you might be able to help, I am a novice, but I manage.

I have a variable I use to set the number of identical menu options that control an array of variables, below is a sniplet of working code.

Code: [Select]
for (int count = 0; count < PWMs; count++){
String current = "PWM" + String(count);
}

Code: [Select]

but the error I get is

"error: initializer fails to determine size of '__c"

I've read about string buffers but I get a little lost, I've tried to dig through the .cpp and .h files but can't make much sense of it.

#### jbaum81

#366
##### Feb 06, 2013, 05:59 amLast Edit: Feb 06, 2013, 06:02 am by jbaum81 Reason: 1
On a side note,

I've found a way to make the Menwiz Lib work with the Adafruit I2c backpack.

You need the following:

Adafruit LiquidTWI2 library available here https://github.com/lincomatic/LiquidTWI2

Make these changes to MENWIZ.H

//#include <LCD.h>
and
//MW_LCD*  lcd;
LiquidTWI2*  lcd;

Make this Change to MENWIZ.CPP

//lcd=(MW_LCD*)l;
lcd=(LiquidTWI2*)l;

Make these changes to your sketch
//#include <LCD.h>
//#include <LiquidCrystal_I2C.h>
#include <LiquidTWI2.h>
and
//LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
LiquidTWI2 lcd(0);

and
lcd.setMCPType(LTI_TYPE_MCP23008); // add this at the top of void setup()

Hope this helps someone.

--EDIT--
I found the MENWIZ lib changes in a blog that originally made them work with the LiquidTWI library, when trying to figure out how to make the Adafruit I2c backpack work with LiquidTWI I stumbled on their fork. I do not know the name, nor can I find the blog I found the original information on. My I'd give credit if I could find it.

#### brunialti

#367
##### Feb 27, 2013, 10:15 pm
Hi guys. I'm back.
I'll try to work on menwiz in order to implement some improvement as soon as possible.

I'm also working on a completely different  slim library implementing the notion of "watchdog" on any user variable.
In this new lib it is possible to create for any user defined variable some triggers, that is an action to be fired when the trigger conditions (>,=, <,null  for now) are verified. As many sketches are nothing else than a continuous control on some variable values, this lib let the user concentrate on the actions to be performed instead of the control logic, allowing very compact user code...
stay tuned !

#### Khalid

#368
##### Mar 04, 2013, 06:07 pm
Hi,
I will be the one who will use your great library... Thank You for sharing
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...

#### jbaum81

#369
##### Mar 11, 2013, 11:46 pm

Is Bump, against forum rules?

I was curious because I'm still stuck on the problem I've listed in a previous post.

#### colinc

#370
##### Mar 21, 2013, 02:37 am
Hello,

I am trying to use Menwiz with my setup using an encoder (see code below - I have borrowed a lot from others in this thread!). I have tried setting up an exit function in the menu so I can escape back up to the previous level. The function works as expected but once I exit a submenu I cannot re-enter it without resetting the Arduino. It seems that when I try to re-enter the submenu it automatically selects 'exit' and brings me right back out. I don't think it is a button debounce issue because it seems to be working fine otherwise.

Any thoughts on why this might be happening? I have the feeling I am missing something simple...

Code: [Select]
//The full code is in library example file Quick_tour.ino
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <buttons.h>
#include <MENWIZ.h>
#include <EEPROM.h>
#include <rotary.h>
#include <Bounce.h>

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

// ENCODER
Rotary r = Rotary(2, 3);
int encoderSwitchPin = 4; //push button switch
volatile int virtualButton = 0;

// Instantiate a Bounce object with a 5 millisecond debounce time
Bounce bouncer = Bounce(encoderSwitchPin, 150);

// MENWIZ
int  list,sp = 110;
float setTemp = 25;
float whiOn = 6;
float whiOff = 18;
float actOn = 6;
float actOff = 18;
float ledOn = 6;
float ledOff = 18;

void setup(){

// MENWIZ
Serial.begin(9600);

tree.begin(&lcd,16,2); //declare lcd object and screen size to menwiz lib

s2->setBehaviour(MW_ACTION_CONFIRM, false);
s2->setBehaviour(MW_ACTION_CONFIRM, false);

// ENCODER
pinMode(encoderSwitchPin, INPUT);
digitalWrite(encoderSwitchPin, HIGH); //turn pullup resistor on
PCICR |= (1 << PCIE2);
PCMSK2 |= (1 << PCINT18) | (1 << PCINT19);
sei();

}

void loop(){

tree.draw();

// Update the debouncer
bouncer.update ( );

// Get the update value

if (value == LOW) {
virtualButton = 3;
}

}

void msc(){
static  char buf[7];
strcpy(tree.sbuf,"User screen"); //1st lcd line
strcat(tree.sbuf,"\nsetTemp  : ");strcat(tree.sbuf, dtostrf(setTemp, 4, 1, buf));
tree.drawUsrScreen(tree.sbuf);
}

void myfunc(){
Serial.println("ACTION FIRED");
}

switch(virtualButton) {
case 1: // RIGHT
virtualButton = 0;
return MW_BTD;

break;
case 2: // LEFT
virtualButton = 0;
return MW_BTU;

break;
case 3: // CONFIRM
virtualButton = 0;
return MW_BTC;

break;
case 4: // Escape
virtualButton = 0;
return MW_BTE;

break;
case 0: // NONE
return MW_BTNULL;
break;

}

}

ISR(PCINT2_vect) {
unsigned char result = r.process();
if (result) {
if (result == DIR_CW) {
virtualButton = 1;
}
if (result == DIR_CCW) {
virtualButton = 2;
}
}

}

void escapeFunc() {
virtualButton = 4;

#### AWOL

#371
##### Apr 03, 2013, 02:50 pmLast Edit: Apr 03, 2013, 02:53 pm by AWOL Reason: 1
Code: [Select]
if(list,dc == 0)
What's that?

Please use code tags when posting code.

Code: [Select]
int list,dc = 0;        // Drops Count, Nmber of drops to produce.
byte ds = 0;            // Drops Size, in Milliseconds,Time Solenoid Valve stays open.
byte di12 = 0;          // Drops Interval, in Millisecons, Time Between Drops 1 & 2 That Solenoids Shuts off.
byte di23 = 0;          // Drops Interval, in Millisecons, Time Between Drops 1 & 2 That Solenoids Shuts off.
int svpd = 0;           // Solenoid Valve Purge Delay.
byte svpdo = 2;         // Digital Out Pin For Solenoid Valve Purge.
byte dgo = 3;           // Digital Out Pin For Go Drop Launch.
byte sd = 0;            // Sensor's Delay Value.
byte st = 0;            // Sensor's Threshold Value
int bmd = 0;            // Bulb Delay, When Button Pressed To Confirm, Shutter will Trigger In Bulb Mode For That Set delay.
byte bmo = 4;           // Digital Out Pin For Bulb Mode.
byte sdo = 5;           // Digital Out Pin For Shutter.

Mixing (constant) pin numbers in with variables is a really bad idea.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### AWOL

#372
##### Apr 03, 2013, 06:54 pmLast Edit: Apr 03, 2013, 06:58 pm by AWOL Reason: 1
Quote
if(list,dc == 0) refers to the number of drop from 1 to 3 is set up in  Drop count menu
Nope, sorry, I'm not seeing it.
Can you point to some similar code like that?
What I'm seeing is
"is "list" non zero? Discard that result. Is "dc" equal to zero? If so do something on that basis."

I can see no reason to have "list" in that expression.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### brunialti

#373
##### Apr 03, 2013, 09:57 pm
@JBAUM81

F("...") is not a real function. It is a macro, that is a #define
The macro expansion probably does not produce a compilable code...

#### djrm

#374
##### Jun 05, 2013, 09:59 pm
Greetings,

I am starting to use MENWIZ in an application I'm writing and have discovered a small problem in the error reporting function. I first noticed that the error numbers being found were not any of those created in the source code. I traced the problem to be because the variable MW_error is defined as type byte but is being used with values of greter than 255. changing the definition on line 46 of MENUWIZ.cpp from 'byte MW_error' to 'int MW_error' solved the problem for me.

btw, I see there are some unexpected debug messages being sent down the serial port, these are coming from statements at around lines 795 to 814 of MENWIZ.cpp

I am very happy with the operation of the library, thanks for your good work. I have managed to make it partially work with a modified LCD library using some otherwise unsupported i2c LCD devices, i2c BV4618 and a T6963 with an spi MCP23S17  port expander interface.

hth David.

Go Up