Go Down

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


Declare your variable as Float and
Code: [Select]


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

changing the variable from INT to FLOAt is ok ?

Sorry I dnon't know how many times you need telling
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?


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


Feb 04, 2013, 07:07 pm Last 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);
  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)


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() {
  _menu *r,*s1,*s2;
  menu.begin(&lcd,20,4);                  //declare lcd object and screen size to menwiz lib
  menu.setBehaviour(MW_MENU_INDEX,false); // turn off the menu index - 1/3 etc
  r=menu.addMenu(MW_ROOT,NULL,F("BC Main menu"));
    s1=menu.addMenu(MW_VAR,r, F("Set BC On/Off"));
    s1=menu.addMenu(MW_VAR,r, F("Set pump On/Off"));

The full code is attached to post #358.

Go Up