Show Posts
Pages: 1 ... 3 4 [5] 6
61  International / Megatopic / Re: MENWIZ: una libreria per creare menu su LCD on: January 17, 2013, 02:08:59 pm
Grazie Roberto,
Ora comincio a capire un pochino

Quote
Non mi tentare con il CNC. Potresti non liberarti di me ...  smiley-cool

Ho un bel giocattolino autocostruito .... bhè mica tanto giocattolo ... 2,60 metri x 1,80 circa ....
cercando su google Mechmate ti puoi rendere conto
fai un pò te ...  smiley
a me piace sdebitarmi
62  International / Megatopic / Re: MENWIZ: una libreria per creare menu su LCD on: January 17, 2013, 11:39:06 am
Ciao Roberto,
Si è come dici, qundi dopo:
Code:
s1=menu.addMenu(MW_SUBMENU,r,F("SAW"));                       //add a submenu node 1 to the root menu (control the heigh of my Saw)
    s2=menu.addMenu(MW_VAR,s1,F("ABS Height"));                   //add a terminal node in the menu tree (that is "variable"); (move at a certain mm height)
       s2->addVar(MW_AUTO_INT,&sp,0,100,1);                   //int type, fd binded variable, rage 0-100, step 1
devo mettere
Code:
s2->addVar(MW_ACTION,step);
per step intendo il movimento di un motore di n giri che ho settato  nel menu comandato dalla riga sopra ? (non sono sicuro che sia step ... magari è dostep ... poi controllo)
e "ovviamente" devo definire:
Code:
int step
e poi
Code:
void step ()
//funzione matematica che mi farà fare tanti giri o eventualmente mm
per eseguire variabile intendo esattamente quello che hai detto "userà i valori correnti delle variabili modificati tramite il menu"
Scusa se faccio 'ste domande, ma da pricipiante a volte anche se ho le risposte sotto gli occhi ... non le vedo. Ho letto il tuo manuale e cercato di osservare codici di altri .... ma è ancora dura.
Grazie
P.S.
Se hai bisogno di fare qualche taglio con CNC ricambio volentieri
63  International / Megatopic / Re: MENWIZ: una libreria per creare menu su LCD on: January 16, 2013, 06:35:56 pm
.... direi di no ... ma non capisco come faccio a eseguire la variabile scitta
64  International / Megatopic / Re: MENWIZ: una libreria per creare menu su LCD on: January 16, 2013, 06:14:29 pm
Ho un dubbio, il mio menu funziona, benissimo, solo che non sono riuscito a metterlo in azione, ovvero
in s2->addVar definisco i limiti e lo step da effettuare, e fino a qui tutto ok, sul mio display appaiono i limiti e con i pulsanti setto il valore che voglio.  Dopodichè schiaccio il pulsante confirm e mi torna indietro ...  


Code:
r=menu.addMenu(MW_ROOT,NULL,F("MAIN MENU"));                      //create a root menu at first (required)

  //---------------  
  s1=menu.addMenu(MW_SUBMENU,r,F("SAW"));                       //add a submenu node 1 to the root menu (control the heigh of my Saw)
    s2=menu.addMenu(MW_VAR,s1,F("ABS Height"));                   //add a terminal node in the menu tree (that is "variable"); (move at a certain mm height)
       s2->addVar(MW_AUTO_INT,&sp,0,100,1);                   //int type, fd binded variable, rage 0-100, step 1

ora il mio dubbio è: come faccio a fargli eseguire il comando ? ovvero far compiere allo stepper i passi richiesti ? devo scrivere una funzione tipo questa?

Code:
void ABS Height()
{
Serial.println("Sto girando zzz 10giri zzzz "); // :-)
}
Grazie
65  Using Arduino / Displays / Re: MENWIZ: yet another character lcd menu wizard library on: January 09, 2013, 04:37:59 pm
Thanks Roberto, just to know if it was possible ... so many things I don't know.
66  Using Arduino / Displays / Re: MENWIZ: yet another character lcd menu wizard library on: January 09, 2013, 04:07:39 pm
... And now a little question ...
This shows on the LCD a graphic format like that:
0 [10] 100
Code:
     s2->addVar(MW_AUTO_INT,&sp,0,100,1);                   //int type, fd binded variable, rage 0-100, step 1
Is it possible to change that format ?
I would like to display something like:
      10 mm     without the limit 0 - 100.
thanks
67  Using Arduino / Displays / Re: MENWIZ: yet another character lcd menu wizard library on: January 09, 2013, 03:59:40 pm
Ciao,
I made some progress on the Menu, and it's working very well with the Lcd Keypad shield ....  this is the code for those with the same LCD Keypad ....
Code:
// +++++++ Libaries included
#include <Wire.h>
#include <LiquidCrystal.h>
//INSERT ALL THE LIBARIES AFTER INCLUDING WIRE LIB (MENWIZ request)
//#include <LiquidCrystal_I2C.h>               //eliminato, non più necessario
#include <buttons.h>
#include <MENWIZ.h>
#include <EEPROM.h>
#include <Stepper.h>

// Create global object for menu and lcd
menwiz menu;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution for your motor
Stepper myStepper(stepsPerRevolution, 0,1,2,3);   // initialize the stepper library on pins 0 through 3:

/*                                                eliminato, non più necessario
//Addr, En, Rw, Rs, d4, d5, d6, d7, backlightpin, polarity 4 x 20 LCD
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
*/

boolean wr=0;                         // Instantiate global variables to bind to menu

const int buttonPin = A0;             // 4 button switch circuit input connected to analog pin 0
const int led13Pin = 13;              // the number of the LED output pin
int stepCount = 0;                    // number of steps the motor has taken

boolean buttonBlock = 0;
boolean buttonAct = 0;                // flag 1
boolean stopMenu = 0;                 // flag 2
byte buttonPressed = 0;               // which button was pressed
byte lastButtonPressed = 0;           // prev button pressed
int buttonValue = 0;                  // read value from analog port for the 4 navigation pushbuttons
long menuOffTime = 0;                 //used for timer

int list,sp=0;                       // sp variable has 0 as default value (ABS height)

extern byte MW_navbtn;                //needed to run the software key navigation in Menwiz



void setup()
{
  Serial.begin(9600);                  // Output to serial writing

  digitalWrite((54), HIGH);            // enable the 20k internal pullup for MEGA board for analog port A0
  // digitalWrite((A0), HIGH);         // enable the 20k internal pullup for UNO based board for analog port A0

  //++++++++++++++++++++Menu and LCD 
  char b[84];
  _menu *r,*s1,*s2;

                                      // initialize the menu object ( 4 x rows x 20 colums LCD)
  menu.begin(&lcd,16,2);              //initialize the menwiz menu object passing the lcd object and the colums and rows params
  menu.addUsrNav(navMenu,4);
  MW_navbtn=4;                        // force 4 or 6 buttons mode for menu navigation -> MW_navbtn=4; or MW_navbtn=6;

  //create the menu tree
  r=menu.addMenu(MW_ROOT,NULL,F("MAIN MENU"));                      //create a root menu at first (required)

  //--------------- 
  s1=menu.addMenu(MW_SUBMENU,r,F("SAW"));                       //add a submenu node 1 to the root menu (control the heigh of my Saw)
  s2=menu.addMenu(MW_VAR,s1,F("ABS Height"));                   //add a terminal node in the menu tree (that is "variable"); (move at a certain mm height)
     s2->addVar(MW_AUTO_INT,&sp,0,100,1);                   //int type, fd binded variable, rage 0-100, step 1
  s2=menu.addMenu(MW_VAR,s1,F("REL Move"));                     //add a terminal node in the menu tree (that is "variable"); (move of a certain mm the height)
     s2->addVar(MW_AUTO_INT,&sp,0,100,1);                   //int type, fd binded variable, rage -100 +100, step 1
  s2=menu.addMenu(MW_VAR,s1,F("Zero"));                         //add a terminal node in the menu tree (that is "variable");  (set the zero)
      s2->addVar(MW_LIST,&list);
      s2->addItem(MW_LIST, F("Option1"));
      s2->addItem(MW_LIST, F("Option2"));
      s2->addItem(MW_LIST, F("Option3"));
  s2=menu.addMenu(MW_VAR,s1,F("Setup"));                        //add a terminal node in the menu tree (that is "variable");  (set the parameters)

  //---------------
  s1=menu.addMenu(MW_SUBMENU,r,F("PLANNER"));                    //add a submenu node 2 to the root menu (control the heigh of my Planner)
  s2=menu.addMenu(MW_VAR,s1,F("ABS Height"));                         //add a terminal node in the menu tree (that is "variable"); (should move at a certain mm height)
     s2->addVar(MW_AUTO_INT,&sp,0,100,1);                   //int type, fd binded variable, rage 0-100, step 1
  s2=menu.addMenu(MW_VAR,s1,F("REL Move"));                         //add a terminal node in the menu tree (that is "variable"); (should move of a certain mm the height)
     s2->addVar(MW_AUTO_INT,&sp,-100,100,1);                   //int type, fd binded variable, rage 0-100, step 1
  s2=menu.addMenu(MW_VAR,s1,F("Zero"));                         //add a terminal node in the menu tree (that is "variable"); (should set the zero)
  s2=menu.addMenu(MW_VAR,s1,F("Setup"));                        //add a terminal node in the menu tree (that is "variable");  (set the parameters)
 
  //---------------
  s1=menu.addMenu(MW_SUBMENU,r,F("SHAPER"));                    //add a submenu node 3 to the root menu
  s2=menu.addMenu(MW_VAR,s1,F("ABS Height"));                         //add a terminal node in the menu tree (that is "variable"); (should move at a certain mm height)
  s2=menu.addMenu(MW_VAR,s1,F("REL Move"));                     //add a terminal node in the menu tree (that is "variable"); (should move of a certain mm the height)
  s2=menu.addMenu(MW_VAR,s1,F("Zero"));                     //add a terminal node in the menu tree (that is "variable"); (should set the zero)
  s2=menu.addMenu(MW_VAR,s1,F("Setup"));                        //add a terminal node in the menu tree (that is "variable");  (set the parameters)
 
  /*
  //++++++ Splash screen +++++++
 
  sprintf(menu.sbuf,"TEST minimum menu\nwith 4 or 6\nanalog push buttons\n",1);
  menu.addSplash((char *) menu.sbuf, 1000);

  //++++++ Userscreen ++++++++++
  // create an user define screen callback to activate after X secs since last button push
  menu.addUsrScreen(msc,3000);
  */
  pinMode(led13Pin, OUTPUT);                // initialize the led as a output control pin
}

void loop()   
{
// NAVIGATION MANAGEMENT & DRAWING ON LCD. NOT BLOCKING has to be the first in the void loop
  menu.draw();
/*
  put your regular code here
*/
//  ++++++ functions +++++++

void readButtons()

// ++++ Control 4 buttons ++++
{
  lastButtonPressed = buttonPressed;

  /*
  Analog values representing the pushbutton value are depending on the resitor value used.
   Test the values first with the serial.monitor
   */
  buttonValue = analogRead(buttonPin); //analog value to simulate the pushed buttons
   
  if(buttonValue >= 850)
  {
    buttonPressed = 0;
    noButtonPressed(); // is calling an extra fucntion
  }
  else  if(buttonValue >= 380 & buttonValue <= 450)
  {
    buttonPressed = 4;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 200 & buttonValue <=300)
  {   
    buttonPressed = 3;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 0 & buttonValue <=50)
  {   
    buttonPressed = 2;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 80 & buttonValue <=150)
  {   
    buttonPressed = 1;
    buttonAct = 1; // set the menu flag1
  }
}

int noButtonPressed()
{
  return MW_BTNULL;
}

int navMenu() // called from menu.draw
{
  /*
   As soon as a button is pushed the first time flag 1 is set to HIGH and if the buttonnumber is not 0 then a timer is started.
   The menu action then should only be performed once.
   After 2000 msecs the flag will be set to LOW and a new buttonpush can be processed.
   Menu action is blocked for 2000 msec even if the same button is being kept pressed for 2000 msecs by flag2.
   */

  long menublockTime = millis();

  if (buttonAct == 1 && buttonPressed != 0 && stopMenu == 0)  // we have a state were we process a menu navigation step once and block it for 2 secs
  {
    digitalWrite(led13Pin,HIGH);  // set timer led ON
    menuOffTime = menublockTime  + 400; //start the timer. You can change this blocking time to your convenience but do not make it lower aa 200 msecs
    stopMenu = 1;

    switch (buttonPressed)
    {
    case 1: // Up
      return MW_BTU;
      break;
    case 2: // Confirm
      return MW_BTC;
      break;
    case 3: // Down
      return MW_BTD;
      break;   
    case 4: // Escape
      return MW_BTE;
      break;
    }
  }

  if (menuOffTime != 0  &&  menublockTime  > menuOffTime)  //  Reset of the timer so a new menu action can be processed
  {
    buttonAct = 0; // resets the flag 1
    buttonPressed = 0;
    menuOffTime = 0;  // resets timer to zero
    stopMenu = 0;
    digitalWrite(led13Pin,LOW);  // set timer led OFF
  }
}

/*
// 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);
}*/

The stepper part is still to be implemented and also the menu code, but it's a "good" start (well there are maybe some errors but it works)
68  Using Arduino / Displays / Re: MENWIZ: yet another character lcd menu wizard library on: January 06, 2013, 03:24:21 am
Ciao Thomas,
.... always from a beginner .... the temperature sensor has some characteristic, the relation between Volt and T. As far as I know,is generally 0,01 V = 1 kelvin degree  and celsius = kelvin -273.
.... this could be a start ... it's important to understand which sensor you use because not all the sensor give the same value ... sorry if I'm obvious or wrong, as I said ... absolute beginner :-)
69  Using Arduino / Displays / Re: MENWIZ: yet another character lcd menu wizard library on: January 04, 2013, 10:27:02 am
Just a guess .... as I am an absolute beginner ..... it seems a library problem ... do you have all the necessary library included ?
70  Using Arduino / Displays / Re: MENWIZ: yet another character lcd menu wizard library on: January 02, 2013, 10:58:49 am
Roberto, it's me who apology ... if I was just a bit smarter, I could be able to understand what was missing.
Thank you very much for your work.
Sergio
71  Using Arduino / Displays / Re: MENWIZ: yet another character lcd menu wizard library on: January 02, 2013, 10:16:19 am
Ciao,
This is a "perfecly" working ( at least I hope ) start base of MENWIZ to be used with the Arduino Lcd Keypad Shield ( http://www.robotshop.com/cytron-lcd-keypad-shield-arduino.html )

Code:
// +++++++ Libaries included
#include <Wire.h>
#include <LiquidCrystal.h>
//INSERT ALL THE LIBARIES AFTER INCLUDING WIRE LIB (MENWIZ request)
#include <LiquidCrystal_I2C.h>
#include <buttons.h>
#include <MENWIZ.h>
#include <EEPROM.h>

// Create global object for menu and lcd
menwiz menu;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
/*LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlightpin, polarity 4 x 20 LCD
*/
boolean wr=0; // Instantiate global variables to bind to menu

const int buttonPin = A0;             // 4 button switch circuit input connected to analog pin 0
const int led13Pin = 13;              // the number of the LED output pin

boolean buttonBlock = 0;
boolean buttonAct = 0; // flag 1
boolean stopMenu = 0; // flag 2
byte buttonPressed = 0;  // which button was pressed
byte lastButtonPressed = 0; // prev button pressed
int buttonValue = 0;  // read value from analog port for the 4 navigation pushbuttons
long menuOffTime = 0;  //used for timer

extern byte MW_navbtn;  //needed to run the software key navigation in Menwiz



void setup()
{
  Serial.begin(9600);                       // Output to serial writing

  digitalWrite((54), HIGH);  // enable the 20k internal pullup for MEGA board for analog port A0
  // digitalWrite((A0), HIGH);  // enable the 20k internal pullup for UNO based board for analog port A0

  //++++++++++++++++++++Menu and LCD 
  char b[84];
  _menu *r,*s1,*s2;

  // initialize the menu object ( 4 x rows x 20 colums LCD)
  menu.begin(&lcd,16,2); //initialize the menwiz menu object passing the lcd object and the colums and rows params
  menu.addUsrNav(navMenu,4);
  MW_navbtn=4;  // force 4 or 6 buttons mode for menu navigation -> MW_navbtn=4; or MW_navbtn=6;

  //create the menu tree
  r=menu.addMenu(MW_ROOT,NULL,F("MAIN MENU"));                      //create a root menu at first (required)

  //--------------- 
  s1=menu.addMenu(MW_SUBMENU,r,F("SAW"));                        //add a submenu node 1 to the root menu (control the heigh of my Saw)
  s2=menu.addMenu(MW_VAR,s1,F("ABS Height"));                         //add a terminal node in the menu tree (that is "variable"); (should move at a certain mm height)
  s2=menu.addMenu(MW_VAR,s1,F("REL Move"));                         //add a terminal node in the menu tree (that is "variable"); (should move of a certain mm the height)
  s2=menu.addMenu(MW_VAR,s1,F("Zero"));                         //add a terminal node in the menu tree (that is "variable");

  //---------------
  s1=menu.addMenu(MW_SUBMENU,r,F("PLANNER"));                    //add a submenu node 2 to the root menu (control the heigh of my Planner)
  s2=menu.addMenu(MW_VAR,s1,F("ABS Height"));                         //add a terminal node in the menu tree (that is "variable"); (should move at a certain mm height)
  s2=menu.addMenu(MW_VAR,s1,F("REL Move"));                         //add a terminal node in the menu tree (that is "variable"); (should move of a certain mm the height)
  s2=menu.addMenu(MW_VAR,s1,F("Zero"));                         //add a terminal node in the menu tree (that is "variable"); (should set the zero)

  //---------------
  s1=menu.addMenu(MW_SUBMENU,r,F("SHAPER"));                    //add a submenu node 3 to the root menu
  s2=menu.addMenu(MW_VAR,s1,F("ABS Height"));                         //add a terminal node in the menu tree (that is "variable"); (should move at a certain mm height)
  s2=menu.addMenu(MW_VAR,s1,F("REL Move"));                     //add a terminal node in the menu tree (that is "variable"); (should move of a certain mm the height)
  s2=menu.addMenu(MW_VAR,s1,F("Zero"));                     //add a terminal node in the menu tree (that is "variable"); (should set the zero)

  /*
  //++++++ Splash screen +++++++
 
  sprintf(menu.sbuf,"TEST minimum menu\nwith 4 or 6\nanalog push buttons\n",1);
  menu.addSplash((char *) menu.sbuf, 1000);

  //++++++ Userscreen ++++++++++
  // create an user define screen callback to activate after X secs since last button push
  menu.addUsrScreen(msc,3000);
  */
  pinMode(led13Pin, OUTPUT);                // initialize the led as a output control pin
}

void loop()   
{
// NAVIGATION MANAGEMENT & DRAWING ON LCD. NOT BLOCKING has to be the first in the void loop
  menu.draw();
/*
  put your regular code here
   */
  readButtons();
}

//  ++++++ functions +++++++

void readButtons()

// ++++ Control 4 buttons ++++
{
  lastButtonPressed = buttonPressed;

  /*
  Analog values representing the pushbutton value are depending on the resitor value used.
   Test the values first with the serial.monitor
   */
  buttonValue = analogRead(buttonPin); //analog value to simulate the pushed buttons
 
  if(buttonValue >= 850)
  {
    buttonPressed = 0;
    noButtonPressed(); // is calling an extra fucntion
  }
  else  if(buttonValue >= 380 & buttonValue <= 450)
  {
    buttonPressed = 4;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 200 & buttonValue <=300)
  {   
    buttonPressed = 3;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 0 & buttonValue <=50)
  {   
    buttonPressed = 2;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 80 & buttonValue <=150)
  {   
    buttonPressed = 1;
    buttonAct = 1; // set the menu flag1
  }
}

int noButtonPressed()
{
  return MW_BTNULL;
}

int navMenu() // called from menu.draw
{
  /*
   As soon as a button is pushed the first time flag 1 is set to HIGH and if the buttonnumber is not 0 then a timer is started.
   The menu action then should only be performed once.
   After 2000 msecs the flag will be set to LOW and a new buttonpush can be processed.
   Menu action is blocked for 2000 msec even if the same button is being kept pressed for 2000 msecs by flag2.
   */

  long menublockTime = millis();

  if (buttonAct == 1 && buttonPressed != 0 && stopMenu == 0)  // we have a state were we process a menu navigation step once and block it for 2 secs
  {
    digitalWrite(led13Pin,HIGH);  // set timer led ON
    menuOffTime = menublockTime  + 2000; //start the timer. You can change this blocking time to your convenience but do not make it lower aa 200 msecs
    stopMenu = 1;

    switch (buttonPressed)
    {
    case 1: // Up
      return MW_BTU;
      break;
    case 2: // Confirm
      return MW_BTC;
      break;
    case 3: // Down
      return MW_BTD;
      break;   
    case 4: // Escape
      return MW_BTE;
      break;
    }
  }

  if (menuOffTime != 0  &&  menublockTime  > menuOffTime)  //  Reset of the timer so a new menu action can be processed
  {
    buttonAct = 0; // resets the flag 1
    buttonPressed = 0;
    menuOffTime = 0;  // resets timer to zero
    stopMenu = 0;
    digitalWrite(led13Pin,LOW);  // set timer led OFF
  }
}
/*
// 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);
}*/

P.S.
 /*
   As soon as a button is pushed the first time flag 1 is set to HIGH and if the buttonnumber is not 0 then a timer is started.
   The menu action then should only be performed once.
   After 2000 msecs the flag will be set to LOW and a new buttonpush can be processed.
   Menu action is blocked for 2000 msec even if the same button is being kept pressed for 2000 msecs by flag2.
   */
This is why sometimes I had to push twice a button to operate .... didn't wait enough !  smiley-red
72  Using Arduino / Displays / Re: MENWIZ: yet another character lcd menu wizard library on: January 02, 2013, 10:08:26 am
Ciao Roberto,
This is what I tried, but I got "57: error: 'bte' was not declared in this scope". I don't know what I did wrong, it was just a test I don't need it at the moment. The Menu frame it's working, I just have to think and put my variable in. (P.S. my project is to control with a stepper the height of my Saw, Planner and shaper ... http://www.bricosergio.it/combinate/Sicar/furore300i%20NEW.htm ... )

Code:
//create the menu tree
  r=menu.addMenu(MW_ROOT,NULL,F("MAIN MENU"));                      //create a root menu at first (required)

  //--------------- 
  s1=menu.addMenu(MW_SUBMENU,r,F("SAW"));                        //add a submenu node 1 to the root menu
    s2=menu.addMenu(MW_VAR,s1,F("ABS Height"));                         //add a terminal node in the menu tree (that is "variable");
      s2=menu.addMenu(MW_VAR,s1,F("REL Move"));                         //add a terminal node in the menu tree (that is "variable");
        s2=menu.addMenu(MW_VAR,s1,F("Zero"));                         //add a terminal node in the menu tree (that is "variable");
          s2=menu.addMenu(MW_VAR,s1,F("Back"));     //add a terminal node (that is "variable");
            s2->addVar(MW_ACTION,&bte);                    //create a variable of type "action"
            s2->setBehaviour(MW_ACTION_CONFIRM,false);         // you don't need action confirmation to emulate Escape button

And in the MENWIZ.h file:
Code:
class menwiz{
public:
           menwiz();
  void     begin(void *,int, int);
  void     addSplash(char *,int);
  void     addUsrScreen(void (*f)(), unsigned long);
  void     addUsrNav(int (*f)(), int);
  void     setBehaviour(MW_FLAGS,boolean);
  _menu*   addMenu(int, _menu *, MW_LABEL);
  void     draw();
  void     drawUsrScreen(char *);       //draw user screen(s)
  int      getErrorMessage(boolean); //if arg=true, err message is printed to the default Serial terminal, otherwise the function returns error code only
  int      freeRam();
  void     actBTE();
73  Using Arduino / Displays / Re: MENWIZ: yet another character lcd menu wizard library on: January 02, 2013, 07:32:54 am
..... :-) I'm starting having fun !!
Code:
/*
  Analog values representing the pushbutton value are depending on the resitor value used.
   Test the values first with the serial.monitor
   */
  buttonValue = analogRead(buttonPin); //analog value to simulate the pushed buttons
  Serial.println(buttonValue );
 
 
  if(buttonValue >= 850)
  {
    buttonPressed = 0;
    noButtonPressed(); // is calling an extra fucntion
  }
  else  if(buttonValue >= 380 & buttonValue <= 450)
  {
    buttonPressed = 4;
    buttonAct = 1; // set the menu flag1
    Serial.println("Escape");
  }
  else if(buttonValue >= 200 & buttonValue <=300)
  {   
    buttonPressed = 3;
    buttonAct = 1; // set the menu flag1
    Serial.println("DOWN");
  }
  else if(buttonValue >= 0 & buttonValue <=50)
  {   
    buttonPressed = 2;
    buttonAct = 1; // set the menu flag1
    Serial.println("Confirm");
  }
  else if(buttonValue >= 80 & buttonValue <=150)
  {   
    buttonPressed = 1;
    buttonAct = 1; // set the menu flag1
    Serial.println("Up");
  }
}

Thanks Khalid
74  Using Arduino / Displays / Re: MENWIZ: yet another character lcd menu wizard library on: January 02, 2013, 05:53:00 am
Kalid, thank you a great help !! ( and exacly what a "dummy" like me need ! explanation and example ! thanks !! )


This is my solution for the Lcd Keypad Shield with the anologic buttons !
I think something like a delay has to be put somewhere because sometimes I have to push the button twice ... let give me a bit more time to fix it :-)  (or help :-) )
Code:
/*
  Analog values representing the pushbutton value are depending on the resitor value used.
   Test the values first with the serial.monitor
   */
  buttonValue = analogRead(buttonPin); //analog value to simulate the pushed buttons
  Serial.println(buttonValue );
 
  if(buttonValue >= 850)
  {
    buttonPressed = 0;
    noButtonPressed(); // is calling an extra fucntion
  }
  else  if(buttonValue >= 380 & buttonValue <= 450)
  {
    buttonPressed = 4;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 200 & buttonValue <=300)
  {   
    buttonPressed = 3;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 0 & buttonValue <=50)
  {   
    buttonPressed = 2;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 80 & buttonValue <=150)
  {   
    buttonPressed = 1;
    buttonAct = 1; // set the menu flag1
  }
}

int noButtonPressed()
{
  return MW_BTNULL;
}

As soon I do my homework ...
Quote
(from the Master Brunialti)
at a first glance I see some point to check:
- the following line is not necessary: MW_navbtn=4;
- when you use  addusernav the declared callback should be in charge with button checking and code returning. The call to readButtons() should be therefore inside the callback funcion , not in the loop. the code works the same, but is more polite
- you defined the menu framework, but after each  creation of menu nodes of type MW_VAR you need to create the variable with addVar in order to let the menu working.
I will post the complete code
Thanks
75  Using Arduino / Displays / Re: MENWIZ: yet another character lcd menu wizard library on: January 02, 2013, 03:12:16 am
First of all, thanks for the help and ... Happy new year !
In my humble opinion the 5 option button (analog) option will be great, because it would allow all the users of the lcd shield (which is very common) to benefit of the Menwiz. The 5 buttons menu control is widely used (I have it on my Nikon camera, on the onkyo AVR ampli ecc.) you move "up" and "down" on the menus/options you enter in the sub menus with the "right" button or with "ok" (select) you choose the option by pressing "ok" (select) and the left button is for "exit" (go back).
the 3 button menus the visual back solution.

Now for my particular case .... It Works !! (well quite works ... -:) )
two of the button are working  and two are nor, in any case the menu is working so I just have to trick around the values of the buttons

Code:
  /*
  Analog values representing the pushbutton value are depending on the resitor value used.
   Test the values first with the serial.monitor
   */
  buttonValue = analogRead(buttonPin); //analog value to simulate the pushed buttons

  if(buttonValue >= 700)
  {
    buttonPressed = 0;
    noButtonPressed(); // is calling an extra fucntion
  }
  else  if(buttonValue >= 470 & buttonValue <= 600)
  {
    buttonPressed = 4;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 300 & buttonValue <=420)
  {   
    buttonPressed = 3;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 100 & buttonValue <=200)
  {   
    buttonPressed = 1;
    buttonAct = 1; // set the menu flag1
  }
  else if(buttonValue >= 10 & buttonValue <=50)
  {   
    buttonPressed = 2;
    buttonAct = 1; // set the menu flag1
  }
}
Up is working corectly and down is working but it's the left button which should be "esc".
Code:
switch (buttonPressed)
    {
    case 1: // Up
      return MW_BTU;
      break;
    case 2: // Confirm
      return MW_BTC;
      break;
    case 3: // Down
      return MW_BTD;
      break;   
    case 4: // Escape
      return MW_BTE;
      break;
    }
  }


the working test line is:
Code:
int adc_key_val[5] ={30, 150, 360, 535, 760 };
so in some ways I'll find the solution.

.... Grazie Brunialti, for the particular attention to my stupid problems, I apreciate that and I will do my best to understand and follow your advices.
As soon I get the solution to the buttons problem I'll post it. I think can help those are starting like me.
ciao
Pages: 1 ... 3 4 [5] 6