RISOLTO: Messaggi di errore come: "error variable or field declared void"

Buongiorno a tutti,
sto scrivendo uno sketch per fare l'impianto di irrigazione del mio orto.
Dal menu devo poter cambiare alcuni parametri così ho scaricato la libreria menubackend da

e dopo vari tentativi sono riuscito a capire come funziona.
Man mano che vado avanti a programmare salvo uno sketch di modo che se combino qualche casino cancello tutto e ricomincio dallo step precedente. Ieri sera avevo due sketch funzionanti e testati su arduino, stamattina mi rimetto al lavoro e mi escono errori che ieri sera non mi dava!! :astonished:
Anzi, direi solo un errore in tutta la pagina: error variable or field declared void
Questo succede in più di uno sketch salvato (provato e funzionante)

Se posto il codice mi dice che ho superato i 9500 caratteri:

Gli errori che invece mi da sono i seguenti:

menu_con_attuazione:7: error: variable or field 'menuChanged' declared void
menu_con_attuazione:7: error: 'MenuChangeEvent' was not declared in this scope
menu_con_attuazione:8: error: variable or field 'menuUsed' declared void
menu_con_attuazione:8: error: 'MenuUseEvent' was not declared in this scope
menu_con_attuazione:31: error: 'MenuBackend' does not name a type
menu_con_attuazione:33: error: 'MenuItem' does not name a type
menu_con_attuazione:34: error: 'MenuItem' does not name a type
menu_con_attuazione:35: error: 'MenuItem' does not name a type
menu_con_attuazione:36: error: 'MenuItem' does not name a type
menu_con_attuazione:37: error: 'MenuItem' does not name a type
menu_con_attuazione:38: error: 'MenuItem' does not name a type
menu_con_attuazione:39: error: 'MenuItem' does not name a type
menu_con_attuazione:40: error: 'MenuItem' does not name a type
menu_con_attuazione:41: error: 'MenuItem' does not name a type
menu_con_attuazione:42: error: 'MenuItem' does not name a type
menu_con_attuazione.ino: In function 'void setup()':
menu_con_attuazione:56: error: 'menu' was not declared in this scope
menu_con_attuazione:56: error: 'menu1Item1' was not declared in this scope
menu_con_attuazione:57: error: 'menu1Item2' was not declared in this scope
menu_con_attuazione:57: error: 'menu1Item3' was not declared in this scope
menu_con_attuazione:58: error: 'menuaggiunto1' was not declared in this scope
menu_con_attuazione:58: error: 'menuaggiunto2' was not declared in this scope
menu_con_attuazione:59: error: 'tempi1' was not declared in this scope
menu_con_attuazione:59: error: 'tempi2' was not declared in this scope
menu_con_attuazione:59: error: 'tempi3' was not declared in this scope
menu_con_attuazione:59: error: 'tempi4' was not declared in this scope
menu_con_attuazione:59: error: 'tempi5' was not declared in this scope
menu_con_attuazione.ino: At global scope:
menu_con_attuazione:76: error: variable or field 'menuChanged' declared void
menu_con_attuazione:76: error: 'MenuChangeEvent' was not declared in this scope

Che cosa significa? e perché fino a ieri funzionava tutto? Poi dopo aver salvato ho riscontrato questi errori...
Grazie a tutti! :slight_smile:

ecco il codice:

#include <Menu.h>    //MenuBackend library - copyright by Alexander Brevig
#include <LiquidCrystal.h>  //this library is included in the Arduino IDE

const int buttonPinLeft = 8;      // pin for the Up button
const int buttonPinRight = 9;    // pin for the Down button
const int buttonPinEsc = 10;     // pin for the Esc button
const int buttonPinEnter = 11;   // pin for the Enter button

int lastButtonPushed = 0;

int lastButtonEnterState = LOW;   // the previous reading from the Enter input pin
int lastButtonEscState = LOW;   // the previous reading from the Esc input pin
int lastButtonLeftState = LOW;   // the previous reading from the Left input pin
int lastButtonRightState = LOW;   // the previous reading from the Right input pin


long lastEnterDebounceTime = 0;  // the last time the output pin was toggled
long lastEscDebounceTime = 0;  // the last time the output pin was toggled
long lastLeftDebounceTime = 0;  // the last time the output pin was toggled
long lastRightDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 500;    // the debounce time

// LiquidCrystal display with:
// rs on pin 2
// rw on 3
// enable on pin 6
// d4, d5, d6, d7 on pins 4, 5, 6, 7
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

//Menu variables
MenuBackend menu = MenuBackend(menuUsed,menuChanged);
//initialize menuitems
    MenuItem menu1Item1 = MenuItem("Soglialuce");
    MenuItem menu1Item2 = MenuItem("Cicli irrigaz");
    MenuItem menu1Item3 = MenuItem("Elettr");
      MenuItem menuaggiunto1 = MenuItem("numero elettrov");
      MenuItem menuaggiunto2 = MenuItem("tempi elettrov");
        MenuItem tempi1 = MenuItem("tempi 1 elet");
        MenuItem tempi2 = MenuItem("tempi 2 elet");
        MenuItem tempi3 = MenuItem("tempi 3 elet");
        MenuItem tempi4 = MenuItem("tempi 4 elet");
        MenuItem tempi5 = MenuItem("tempi 5 elet");


void setup()
{
  Serial.begin(9600);
  pinMode(buttonPinLeft, INPUT);
  pinMode(buttonPinRight, INPUT);
  pinMode(buttonPinEnter, INPUT);
  pinMode(buttonPinEsc, INPUT);
  
  lcd.begin(16, 2);

  //configure menu
  menu.getRoot().add(menu1Item1);
  menu1Item1.addRight(menu1Item2).addRight(menu1Item3);
  menu1Item3.add(menuaggiunto1).addRight(menuaggiunto2);
  menuaggiunto2.add(tempi1).addRight(tempi2).addRight(tempi3).addRight(tempi4).addRight(tempi5);
  menu.toRoot();
  lcd.setCursor(0,0);  
  Serial.println("Menu irrigazione");

}  // setup()...


void loop()
{

  readButtons();  //I splitted button reading and navigation in two procedures because 
  navigateMenus();  //in some situations I want to use the button for other purpose (eg. to change some settings)
                  
} //loop()... 


void menuChanged(MenuChangeEvent changed){
  
  MenuItem newMenuItem=changed.to; //get the destination menu
  
  lcd.setCursor(0,1); //set the start position for lcd printing to the second row
  
  if(newMenuItem.getName()==menu.getRoot()){
      Serial.println("Menu principale ");
  }else if(newMenuItem.getName()=="Soglialuce"){
      Serial.println("soglia luce     ");
  }else if(newMenuItem.getName()=="Cicli irrigaz"){
      Serial.println("Cicli irrigazion");
  }else if(newMenuItem.getName()=="Elettr"){
      Serial.println("Elettrovalvole  ");
  }else if(newMenuItem.getName()=="numero elettrov"){
      Serial.println("numero elettrov ");
  }else if(newMenuItem.getName()=="tempi elettrov"){
      Serial.println("tempi elettrov  ");
  }else if(newMenuItem.getName()=="tempi 1 elet"){
      Serial.println("tempi 1 elet    ");
  }else if(newMenuItem.getName()=="tempi 2 elet"){
      Serial.println("tempi 2 elet    ");
  }else if(newMenuItem.getName()=="tempi 3 elet"){
      Serial.println("tempi 3 elet    ");
  }else if(newMenuItem.getName()=="tempi 4 elet"){
      Serial.println("tempi 4 elet    ");
  }else if(newMenuItem.getName()=="tempi 5 elet"){
      Serial.println("tempi 5 elet    ");
  }
}

void menuUsed(MenuUseEvent used){
  
  if(used.item.getName()=="Soglialuce"){
      Serial.println("soglia luce     ");
  }else if(used.item.getName()=="Cicli irrigaz"){
      Serial.println("Cicli irrigazion");
  }else if(used.item.getName()=="Elettr"){
      Serial.println("Elettrovalvole  ");
  }else if(used.item.getName()=="numero elettrov"){
      Serial.println("numero elettrov ");
  }else if(used.item.getName()=="tempi elettrov"){
      Serial.println("tempi elettrov  ");
  }else if(used.item.getName()=="tempi 1 elet"){
      Serial.println("tempi 1 elet    ");
  }else if(used.item.getName()=="tempi 2 elet"){
      Serial.println("tempi 2 elet    ");
  }else if(used.item.getName()=="tempi 3 elet"){
      Serial.println("tempi 3 elet    ");
  }else if(used.item.getName()=="tempi 4 elet"){
      Serial.println("tempi 4 elet    ");
  }else if(used.item.getName()=="tempi 5 elet"){
      Serial.println("tempi 5 elet    ");
  }
  
  delay(3000);  //delay to allow message reading
  lcd.setCursor(0,0);  
  Serial.println("IRRIGAZIONE");
  menu.toRoot();  //back to Main
}


void  readButtons(){  //read buttons status
  int reading;
  int buttonEnterState=LOW;             // the current reading from the Enter input pin
  int buttonEscState=LOW;             // the current reading from the input pin
  int buttonLeftState=LOW;             // the current reading from the input pin
  int buttonRightState=LOW;             // the current reading from the input pin
  //Enter button
                  // read the state of the switch into a local variable:
                  reading = digitalRead(buttonPinEnter);

                  // check to see if you just pressed the enter button 
                  // (i.e. the input went from LOW to HIGH),  and you've waited 
                  // long enough since the last press to ignore any noise:  
                
                  // If the switch changed, due to noise or pressing:
                  if (reading != lastButtonEnterState) {
                    // reset the debouncing timer
                    lastEnterDebounceTime = millis();
                  } 
                  
                  if ((millis() - lastEnterDebounceTime) > debounceDelay) {
                    // whatever the reading is at, it's been there for longer
                    // than the debounce delay, so take it as the actual current state:
                    buttonEnterState=reading;
                    lastEnterDebounceTime=millis();
                  }
                  
                  // save the reading.  Next time through the loop,
                  // it'll be the lastButtonState:
                  lastButtonEnterState = reading;
                  

    //Esc button               
                  // read the state of the switch into a local variable:
                  reading = digitalRead(buttonPinEsc);

                  // check to see if you just pressed the Down button 
                  // (i.e. the input went from LOW to HIGH),  and you've waited 
                  // long enough since the last press to ignore any noise:  
                
                  // If the switch changed, due to noise or pressing:
                  if (reading != lastButtonEscState) {
                    // reset the debouncing timer
                    lastEscDebounceTime = millis();
                  } 
                  
                  if ((millis() - lastEscDebounceTime) > debounceDelay) {
                    // whatever the reading is at, it's been there for longer
                    // than the debounce delay, so take it as the actual current state:
                    buttonEscState = reading;
                    lastEscDebounceTime=millis();
                  }
                  
                  // save the reading.  Next time through the loop,
                  // it'll be the lastButtonState:
                  lastButtonEscState = reading; 
                  
                     
   //Down button               
                  // read the state of the switch into a local variable:
                  reading = digitalRead(buttonPinRight);

                  // check to see if you just pressed the Down button 
                  // (i.e. the input went from LOW to HIGH),  and you've waited 
                  // long enough since the last press to ignore any noise:  
                
                  // If the switch changed, due to noise or pressing:
                  if (reading != lastButtonRightState) {
                    // reset the debouncing timer
                    lastRightDebounceTime = millis();
                  } 
                  
                  if ((millis() - lastRightDebounceTime) > debounceDelay) {
                    // whatever the reading is at, it's been there for longer
                    // than the debounce delay, so take it as the actual current state:
                    buttonRightState = reading;
                   lastRightDebounceTime =millis();
                  }
                  
                  // save the reading.  Next time through the loop,
                  // it'll be the lastButtonState:
                  lastButtonRightState = reading;                  
                  
                  
    //Up button               
                  // read the state of the switch into a local variable:
                  reading = digitalRead(buttonPinLeft);

                  // check to see if you just pressed the Down button 
                  // (i.e. the input went from LOW to HIGH),  and you've waited 
                  // long enough since the last press to ignore any noise:  
                
                  // If the switch changed, due to noise or pressing:
                  if (reading != lastButtonLeftState) {
                    // reset the debouncing timer
                    lastLeftDebounceTime = millis();
                  } 
                  
                  if ((millis() - lastLeftDebounceTime) > debounceDelay) {
                    // whatever the reading is at, it's been there for longer
                    // than the debounce delay, so take it as the actual current state:
                    buttonLeftState = reading;
                    lastLeftDebounceTime=millis();;
                  }
                  
                  // save the reading.  Next time through the loop,
                  // it'll be the lastButtonState:
                  lastButtonLeftState = reading;  

                  //records which button has been pressed
                  if (buttonEnterState==HIGH){
                    lastButtonPushed=buttonPinEnter;

                  }else if(buttonEscState==HIGH){
                    lastButtonPushed=buttonPinEsc;

                  }else if(buttonRightState==HIGH){
                    lastButtonPushed=buttonPinRight;

                  }else if(buttonLeftState==HIGH){
                    lastButtonPushed=buttonPinLeft;

                  }else{
                    lastButtonPushed=0;
                  }                  
}

void navigateMenus() {
  MenuItem currentMenu=menu.getCurrent();
  
  switch (lastButtonPushed){
    case buttonPinEnter:
      if(!(currentMenu.moveDown())){  //if the current menu has a child and has been pressed enter then menu navigate to item below
        menu.use();
      }else{  //otherwise, if menu has no child and has been pressed enter the current menu is used
        menu.moveDown();
       } 
      break;
    case buttonPinEsc:
      menu.toRoot();  //back to main
      break;
    case buttonPinRight:
      menu.moveRight();
      break;      
    case buttonPinLeft:
      menu.moveLeft();
      break;      
  }
  
  lastButtonPushed=0; //reset the lastButtonPushed variable
}

La libreria usata è MenuBackend e non Menu.

#include <MenuBackend.h>

Trovato il problema! Stamattina ho cancellato la cartella Arduino contenuta nella cartella Home (che conteneva la libreria che avevo aggiunto Menubackend) :disappointed_relieved:
Grazie a tutti lo stesso!