     openSides();
   }
 //Programme fournaise1
-  if (greenhouseTemperature < (TEMP_CHAUFFAGE1-(HYST_CHAUFFAGE1/2))){
+  if (greenhouseTemperature < (TEMP_FOURNAISE1-(HYST_FOURNAISE1/2))){
     setHeater1(ON);
     digitalWrite(CHAUFFAGE1, ON);
-  }else if(greenhouseTemperature > (TEMP_CHAUFFAGE1+(HYST_CHAUFFAGE1/2))){
+  }else if(greenhouseTemperature > (TEMP_FOURNAISE1+(HYST_FOURNAISE1/2))){
     setHeater1(OFF);
     digitalWrite(CHAUFFAGE1, OFF);
   }
 //Programme fournaise2
-  if (greenhouseTemperature < (TEMP_CHAUFFAGE2-(HYST_CHAUFFAGE2/2))){
+  if (greenhouseTemperature < (TEMP_FOURNAISE2-(HYST_FOURNAISE2/2))){
     setHeater2(ON);
     digitalWrite(CHAUFFAGE2, ON);
-  }else if(greenhouseTemperature > (TEMP_CHAUFFAGE2+(HYST_CHAUFFAGE2/2))){
+  }else if(greenhouseTemperature > (TEMP_FOURNAISE2+(HYST_FOURNAISE2/2))){
     setHeater2(OFF);
     digitalWrite(CHAUFFAGE2, OFF);
   }
 //Programme ventilation forcée
-   if (greenhouseTemperature > (TEMP_VENT - (HYST_VENT/2))){
+   if (greenhouseTemperature > (TEMP_VENTILATION - (HYST_VENT/2))){
     setFan(ON);
     digitalWrite(FAN, ON);
-  }else if(greenhouseTemperature < (TEMP_VENT + (HYST_VENT/2))){
+  }else if(greenhouseTemperature < (TEMP_VENTILATION + (HYST_VENT/2))){
     setFan(OFF);
     digitalWrite(FAN, OFF);
   }
 //--------------Affichage sériel--------------------
-    Serial.println("");
-    Serial.println("-----------------------");
+    Serial.println(F(""));
+    Serial.println(F("-----------------------"));
     Serial.print(rtc.getDOWStr());
-    Serial.print(",  ");
+    Serial.print(F(",  "));
     // Send date
     Serial.print(rtc.getDateStr());
-    Serial.print(" - ");
+    Serial.print(F(" - "));
     // Send time
     Serial.println(rtc.getTimeStr());
-    Serial.print("PROGRAMME : ");
+    Serial.print(F("PROGRAMME : "));
     Serial.println(PROGRAMME);
   
-    Serial.println("-----------------------");    
-    Serial.print("Temperature cible :");
+    Serial.println(F("-----------------------"));    
+    Serial.print(F("Temperature cible :"));
     Serial.print(TEMP_CIBLE);
-    Serial.println(" C");
-
-    Serial.print("Temperature actuelle: ");
+    Serial.println(F(" C"));
+
+    Serial.print(F("Temperature actuelle: "));
     Serial.print(greenhouseTemperature);
     Serial.println(" C");
-    Serial.print("Humidite: ");
+    Serial.print(F("Humidite: "));
     Serial.print(greenhouseHumidity);
-    Serial.println("%");
-    Serial.println("-----------------------"); 
+    Serial.println(F("%"));
+    Serial.println(F("-----------------------")); 
     if(fan == false){
-    Serial.println("FAN: OFF");}
+    Serial.println(F("FAN: OFF"));}
     else if(fan == true){
-    Serial.println("FAN: ON");}
+    Serial.println(F("FAN: ON"));}
     if(heating1 == false){
-    Serial.println("HEATING1: OFF");}
+    Serial.println(F("HEATING1: OFF"));}
     else if(heating1 == true){
-    Serial.println("HEATING1: ON");}
+    Serial.println(F("HEATING1: ON"));}
     if(heating2 == false){
-    Serial.println("HEATING2 : OFF");}
+    Serial.println(F("HEATING2 : OFF"));}
     else if(heating2 == true){
-    Serial.println("HEATING2 : ON");}
+    Serial.println(F("HEATING2 : ON"));}
 //--------------Affichage LCD--------------------
   lcd.setCursor(0, 0);
-  lcd.print("T: ");
-  lcd.print(greenhouseTemperature);
-  lcd.print("C  ");
-  lcd.setCursor(10,0);
-  lcd.print("HR: ");
-  lcd.print(greenhouseHumidity);
-  lcd.print("%"); 
-  if(fan == false){
-      lcd.setCursor(0, 2);             
-      lcd.print("FAN:");
-      lcd.setCursor(16,2);
-      lcd.print("OFF");}
-  else if(fan == true){
-      lcd.setCursor(0,2);
-      lcd.print("FAN:");
-      lcd.setCursor(16,2);
-      lcd.print("ON ");}
-  if(heating1 == false){
-      lcd.setCursor(0, 3);             
-      lcd.print("HEATING:");
-      lcd.setCursor(16,3);
-      lcd.print("OFF");}
-  else if(heating1 == true){
-      lcd.setCursor(0,3);
-      lcd.print("HEATING: ");
-      lcd.setCursor(16,3);
-      lcd.print("ON ");}
-//--------------fin du cycle--------------------
-  delay(SLEEPTIME);
-}
-
-//--------------SOUS-PROGRAMMES--------------------
+  if((greenhouseTemperature!= last_greenhouseTemperature)||(greenhouseHumidity != last_greenhouseHumidity)){
+  displayTempHRStatus();
+  }
+  if(opened != last_opened){
+  displayRollupStatus();
+  }
+  if((fan != last_fan)||(heating1 != last_heating1)){
+  displayFanHeaterStatus();
+  }
+  
+last_greenhouseTemperature = greenhouseTemperature;
+last_greenhouseHumidity = greenhouseHumidity;
+last_opened = opened;
+last_fan = fan;
+last_heating1 = heating1;
+last_heating2 = heating2;
+}
+
 //Affichage du % d'ouverture des rollup
 void setOpenedStatus(int pctIncrease){
   opened += pctIncrease;

//État de la deuxième fournaise
void setHeater2(int heaterCommand2){
  if ((heaterCommand2 == ON) && (heating2 == false)){
    Serial.println("");  
    Serial.println("  Start heating2");
    heating2 = true;
  }else if ((heaterCommand2 == OFF) && (heating2 == true)){
    Serial.println("");  
    Serial.println("  Stop heating2");
    heating2 = false;    
    }
  }

//État de la ventilation
void setFan(int fanCommand){
  if ((fanCommand == ON) && (fan == false)){
    Serial.println(F(""));  
    Serial.println(F("  Start fan"));

    fan = true;
  }else if ((fanCommand == OFF) && (fan == true)){
    Serial.println(F(""));  
    Serial.println(F("  Stop fan"));
    fan = false;
  }
}
void displayTempHRStatus(){
  lcd.setCursor(0,0);
  lcd.print(F("                    "));
  lcd.setCursor(0,0);
  lcd.print(F("T: "));
  lcd.print(greenhouseTemperature);
  lcd.print(F("C  "));
  lcd.setCursor(10,0);
  lcd.print(F("HR: "));
  lcd.print(greenhouseHumidity);
  lcd.print("%"); 
}
void displayRollupStatus(){
  lcd.setCursor(0,1);
  lcd.print(F("                    "));
  lcd.setCursor(0, 1);
  lcd.print(F("ROLLUPS:     "));
  lcd.setCursor(16, 1);
  lcd.print(opened);    
  lcd.print(F("% "));
}
void displayFanHeaterStatus(){
  lcd.setCursor(0,2);
  lcd.print(F("                    "));
  lcd.setCursor(0,3);
  lcd.print(F("                    "));
  if(fan == false){
      lcd.setCursor(0, 2);             
      lcd.print(F("FAN:"));
      lcd.setCursor(16,2);
      lcd.print(F("OFF"));}
  else if(fan == true){
      lcd.setCursor(0,2);
      lcd.print(F("FAN:"));
      lcd.setCursor(16,2);
      lcd.print(F("ON "));}
  if(heating1 == false){
      lcd.setCursor(0, 3);             
      lcd.print(F("HEATING:"));
      lcd.setCursor(16,3);
      lcd.print(F("OFF"));}
  else if(heating1 == true){
      lcd.setCursor(0,3);
      lcd.print(F("HEATING: "));
      lcd.setCursor(16,3);
      lcd.print(F("ON "));}  
}
//*******************************************EEPROM***********************************************
void newDefaultSettings(){
 EEPROM.write(0,HYST_ROLLUP); 
 EEPROM.write(1,HYST_VENT); 
 EEPROM.write(2,HYST_FOURNAISE1); 
 EEPROM.write(3,HYST_FOURNAISE2); 
 EEPROM.write(4,HP1); 
 EEPROM.write(5,MP1); 
 EEPROM.write(6,TEMP_CIBLEP1); 
 EEPROM.write(7,HP2);  
 EEPROM.write(8,MP2);  
 EEPROM.write(9,TEMP_CIBLEP2);  
 EEPROM.write(10,HP3);  
 EEPROM.write(11,MP3);  
 EEPROM.write(12,TEMP_CIBLEP3); 
 EEPROM.write(13,rotation);
 EEPROM.write(14,pause);
 EEPROM.write(15,rmodE);
 EEPROM.write(16,vmodE);
 EEPROM.write(17, f1modE);
 EEPROM.write(18, f2modE);
}

void loadPreviousSettings(){
 HYST_ROLLUP = EEPROM.read(0); 
 HYST_VENT = EEPROM.read(1); 
 HYST_FOURNAISE1 = EEPROM.read(2); 
 HYST_FOURNAISE2 = EEPROM.read(3); 
 HP1 = EEPROM.read(4); 
 MP1 = EEPROM.read(5); 
 TEMP_CIBLEP1 = EEPROM.read(6); 
 HP2 = EEPROM.read(7);  
 MP2 = EEPROM.read(8);  
 TEMP_CIBLEP2 = EEPROM.read(9);  
 HP3 = EEPROM.read(10);  
 MP3 = EEPROM.read(11);  
 TEMP_CIBLEP3 = EEPROM.read(12); 
 rotation = EEPROM.read(13);
 pause = EEPROM.read(14);
 rmodE = EEPROM.read(15);
 vmodE = EEPROM.read(16);
 f1modE = EEPROM.read(17);
 f2modE = EEPROM.read(18);
 }
 


//**************************************MENU****************************************************
void Menu(int x){
  int a = analogRead(0);
  buttonState(a);
  
  if ((state == 1) && (state != laststate)){
      currentMenuItem = currentMenuItem + 1;
      real_currentMenuItem(Nbitems);
      displayMenu(x);
  } else if ((state == 2) && (state != laststate)){
      currentMenuItem = currentMenuItem - 1;
      real_currentMenuItem(Nbitems);
      displayMenu(x);
  } else if ((state == 3) && (state != laststate)){
      real_currentMenuItem(Nbitems);
      selectMenu(x, currentMenuItem);
  }
  laststate = state;
}

void buttonState(int x){
  if(x < 800){state = 0;} 
  else if(x < 900){state = 1;} 
  else if (x < 950){state = 2;}
  else if (x < 1000){state = 3;}
}
 
void real_currentMenuItem(int x){
  if(currentMenuItem < 1){
  currentMenuItem = 1;
  }
  else if(currentMenuItem > x){
  currentMenuItem = x;
  }
}

void Scrollingmenu (int x, const char a[20] PROGMEM, const char b[20] PROGMEM, const char c[20] PROGMEM, const char d[20] PROGMEM, const char e[20] PROGMEM, const char f[20] PROGMEM, const char g[20] PROGMEM, const char h[20] PROGMEM, const char i[20] PROGMEM, const char j[20] PROGMEM, int y){
  const int numLcdRows = 3;
  byte scrollPos = 0;
  Nbitems = x;
  const char* menuitems[] PROGMEM = {a,b,c,d,e,f,g,h,i,j};
  
        if (y > numLcdRows){scrollPos = y - numLcdRows;
      } else {scrollPos = 0;
      }
      clearPrintTitle();
      for (int i=0; i < numLcdRows; ++i) {
            lcd.setCursor(0, i+1); 
            lcd.print(menuitems[i + scrollPos]);
            }
      lcd.setCursor(19, (y - scrollPos));
      lcd.blink();
}

void Scrollingnumbers(int x, int y, int z, int a){
  const int numLcdRows = 3;
  int scrollPos = 0;
  Nbitems = x;
  
      if (y > numLcdRows){scrollPos = y - numLcdRows;
      } else {scrollPos = 0;
      }
      clearPrintTitle();
      for (int i=0; i < numLcdRows; ++i) {
            lcd.setCursor(0, i+1);
            if(y < 4){
            lcd.print((z-a)+(i*a)+(a));}
            else if(y < x){
            lcd.print((z-a)+(i*a)+((y-2)*a));}
            else if (y == x){
            lcd.print("back");}
            else{}
            }
      lcd.setCursor(19, (y - scrollPos));
      lcd.blink();
}
void clearPrintTitle(){
  lcd.noBlink();
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("**ROBOT-SERRE**V.1**");
}
//***********************************DISPLAY****************************************************
//Scrollingmenu(Nbitems, Item1, item2, item3, item4, item5, Item6, item7, item8, item9, item10, currentMenuItem); //leave variable "Itemx" blank if it doesnt exist
//Scrollingnumbers(Nbitems, currentMenuItem, starting number, multiplicator);

void displayMenu(int x){
  switch (x){
  case 0: Scrollingmenu(6, "Temperature/humidex","Date/time","Rollups","Ventilation","Chauffage","Programmes","","","","", currentMenuItem);break;
  case 1: Scrollingmenu(6, "Date","Time", "SetDOW", "Set date","Set time","back","","","","", currentMenuItem);break; 
  case 11: Scrollingmenu(8, "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "back","","", currentMenuItem);break; 
  case 12:Scrollingnumbers(11, currentMenuItem, 2016, 1);  break;
  case 121: Scrollingnumbers(13, currentMenuItem, 1 ,1);  break;
  case 1211: Scrollingnumbers(32, currentMenuItem, 1, 1); break;
  case 13: Scrollingnumbers(25, currentMenuItem, 1, 1);break;
  case 131: Scrollingnumbers(62, currentMenuItem, 0 , 1); break;
  case 1311: Scrollingnumbers(62, currentMenuItem, 0, 1);break;
  case 2: Scrollingmenu(6, "Etat", "Programme", "Set hysteresis", "Set rotation time(s)", "Set pause time(s)", "back","","","","", currentMenuItem);break; 
  case 21: Scrollingnumbers(6, currentMenuItem, 2, 2);break; 
  case 22: Scrollingnumbers(21, currentMenuItem, 1, 1);break; 
  case 23: Scrollingmenu(10, "5", "15", "20", "30", "45", "60", "75", "90", "120", "back", currentMenuItem);break; 
  case 3: Scrollingmenu(3, "Etat", "Set hysteresis", "back", "", "", "", "", "", "", "", currentMenuItem);break; 
  case 31: Scrollingnumbers(6, currentMenuItem, 2, 2);break; 
  case 4: Scrollingmenu(5, "(F1)Etat", "(F2)Etat","(F1)Set hysteresis", "(F2)Set hysteresis", "back", "", "", "", "", "", currentMenuItem);break; 
  case 41: Scrollingnumbers(6, currentMenuItem, 2, 2);break;  
  case 42: Scrollingnumbers(6, currentMenuItem, 2, 2);break;
  case 5: Scrollingmenu(9, "Programme 1", "Programme 2", "Programme 3", "Modificateurs", "Set Programme 1", "Set Programme 2", "Set Programme 3", "Set Modificateurs", "back","",currentMenuItem);break; 
  case 51:Scrollingmenu(3, "Set Heure", "Set Temp. cible", "back","","","","","","","", currentMenuItem);break; 
  case 511: Scrollingnumbers(25, currentMenuItem, 1 , 1); break;
  case 5111: Scrollingnumbers(62, currentMenuItem, 0, 1);break;
  case 512: Scrollingnumbers(51, currentMenuItem, 0 , 1); break;
  case 52: Scrollingmenu(3, "Set Heure", "Set Temp. cible", "back","","","","","","","", currentMenuItem);break; 
  case 521: Scrollingnumbers(25, currentMenuItem, 1, 1); break;
  case 5211: Scrollingnumbers(62, currentMenuItem, 0, 1);break;
  case 522: Scrollingnumbers(51, currentMenuItem, 0, 1); break;
  case 53: Scrollingmenu(3, "Set Heure", "Set Temp. cible", "back","","","","","","","", currentMenuItem);break; 
  case 531: Scrollingnumbers(25, currentMenuItem, 1 , 1); break;
  case 5311: Scrollingnumbers(62, currentMenuItem, 0, 1);break;
  case 532: Scrollingnumbers(51, currentMenuItem, 0, 1); break;
  case 54: Scrollingmenu(3, "Mod. rollups", "Mod. ventilation", "Mod. fournaise1", "Mod. fournaise2", "back","","","","","", currentMenuItem);break; 
  case 541: Scrollingnumbers(22, currentMenuItem, -10, 1);break;
  case 542: Scrollingnumbers(22, currentMenuItem, -10, 1);break;
  case 543: Scrollingnumbers(22, currentMenuItem, -10, 1);break;
  case 544: Scrollingnumbers(22, currentMenuItem, -10, 1);break;
  }
}
//*****************************************SELECT**********************************************

void switchmenu(int x){
  delay(1000);
  menu = x;
  currentMenuItem = 1;
  Nbitems = 3;
  displayMenu(menu);
}

void selectMenu(int x, int y){
  switch (x){
  //------------------------------SelectrootMenu-------------------------------------
  //"Temperature/humidex","Date/time","Rollups","Ventilation","Chauffage"
  case 0:
    switch (y){
    case 1:
         lcd.noBlink();
         clearPrintTitle();
         lcd.setCursor(0,1);lcd.print(F("Temperature : "));lcd.print(dht.readTemperature());lcd.print(F("C"));
         lcd.setCursor(0,2);lcd.print(F("HR : "));lcd.print(dht.readHumidity());lcd.print(F("%"));
    break;
    case 2:switchmenu(1);break;      
    case 3:switchmenu(2);break;
    case 4:switchmenu(3);break; 
    case 5:switchmenu(4);break; 
    case 6:switchmenu(5);break;
     }
  break;
  //-------------------------------SelectMenu1-----------------------------------------
  //"Date","Time","Set DOW" "Set date", "Set time","back"
  case 1 : 
    switch (y){
    case 1:
         lcd.noBlink();
         clearPrintTitle();
         lcd.setCursor(0,1);lcd.print(rtc.getDOWStr());
         lcd.setCursor(0,2);lcd.print(F("Date : "));lcd.print(rtc.getDateStr());
    break;
    case 2:
         lcd.noBlink();
         clearPrintTitle();
         lcd.setCursor(0,1);lcd.print(F("Time : "));lcd.print(rtc.getTimeStr());
    break;
    case 3:switchmenu(11);break;
    case 4:switchmenu(12);break;
    case 5:switchmenu(13);break;
    case 6:switchmenu(0);break;
    }
  break;
  //-------------------------------SelectMenu12-----------------------------------------
  //SET DAY OF THE WEEK
  case 11 :
    switch(y){
    case 1:rtc.setDOW(MONDAY);switchmenu(1);break;
    case 2:rtc.setDOW(TUESDAY);switchmenu(1);break;
    case 3:rtc.setDOW(WEDNESDAY);switchmenu(1);break;
    case 4:rtc.setDOW(THURSDAY);switchmenu(1);break;
    case 5:rtc.setDOW(FRIDAY);switchmenu(1);break;
    case 6:rtc.setDOW(SATURDAY);switchmenu(1);break;
    case 7:rtc.setDOW(SUNDAY);switchmenu(1);break;
    case 8:switchmenu(1);break;
    }
  break;
  //-------------------------------SelectMenu12-----------------------------------------
  //SET YEAR
  case 12 :   
    if(y<Nbitems){yr = (2015+y);switchmenu(121);}
    else{switchmenu(1);}
  break;
  //-------------------------------SelectMenu131-----------------------------------------
  //SET MONTH
  case 121 :    
    if(y<Nbitems){mt = y;switchmenu(1211);}
    else{switchmenu(1);}
  break;
  //-------------------------------SelectMenu1311-----------------------------------------
  //SET DAY
  case 1211 :   
    if(y<Nbitems){dy = y;rtc.setDate(dy,mt,yr);switchmenu(1);}
    else{switchmenu(1);}
  break;
  //-------------------------------SelectMenu14-----------------------------------------
  //SET HOUR
  case 13 :    
    if(y<Nbitems){hr = y;switchmenu(131);}
    else{switchmenu(1);}
  break;
  //-------------------------------SelectMenu141-----------------------------------------
  //SET MINUTES
  case 131 :    
    if(y<Nbitems){mn = y;switchmenu(1311);}
    else{switchmenu(1);}
  break;
  //-------------------------------SelectMenu1411-----------------------------------------
  //SET SECONDS
  case 1311 :    
    if(y<Nbitems){sc = y;rtc.setTime(hr,mn,sc);switchmenu(1);}
    else{switchmenu(1);}
  break;
  //-------------------------------SelectMenu2-----------------------------------------
  //"Etat", "Programme", "Set hysteresis", "Set rotation time(s)", "Set pause time(m)", "back"
  case 2 : 
    switch (y){
    case 1:
         lcd.noBlink();
         clearPrintTitle();
         lcd.setCursor(0,1);lcd.print(F("Ouverture : "));lcd.print(opened);lcd.print(F("%"));
         lcd.setCursor(0,2);lcd.print(F("TP : "));lcd.print(pause);lcd.print(F("s | TR :"));lcd.print(rotation);lcd.print(F("s"));
         lcd.setCursor(0,3);lcd.print(F("Hysteresis : "));lcd.print(HYST_ROLLUP);lcd.print(F("C"));
    break;
    case 2:
         lcd.noBlink();
         clearPrintTitle();
         lcd.setCursor(0,1);lcd.print(F("Programme : "));lcd.print(PROGRAMME);
         lcd.setCursor(0,2);lcd.print(F("Temp. cible : "));lcd.print(TEMP_CIBLE);lcd.print(F("C"));
         lcd.setCursor(0,3);lcd.print(F("Temp. rollup : "));lcd.print(TEMP_ROLLUP);lcd.print(F("C"));
    break;
    case 3:switchmenu(21);break;
    case 4:switchmenu(22);break;
    case 5:switchmenu(23);break;
    case 6:switchmenu(0);break;
    }
  break;
  //-------------------------------SelectMenu21-----------------------------------------
  //SET HYSTERESIS
  case 21 : 
    if(y<Nbitems){HYST_ROLLUP = (y*2);switchmenu(2);EEPROM.write(0,HYST_ROLLUP);}
    else{switchmenu(2);}
  break;
  //-------------------------------SelectMenu22-----------------------------------------
  //SET ROTATION TIME
  case 22 :  
    if(y<Nbitems){rotation = y;switchmenu(2);EEPROM.write(13, rotation);}
    else{switchmenu(2);}
  break;
  //-------------------------------SelectMenu23-----------------------------------------
  //"5", "15", "20", "30", "45", "60", "75", "90", "120", "back"
  case 23 :
  switch(y){
    case 1:pause = 5;switchmenu(2);EEPROM.write(14, pause);break;
    case 2:pause = 15;switchmenu(2);EEPROM.write(14, pause);break;
    case 3:pause = 20;switchmenu(2);EEPROM.write(14, pause);break;
    case 4:pause = 30;switchmenu(2);EEPROM.write(14, pause);break;
    case 5:pause = 45;switchmenu(2);EEPROM.write(14, pause);break;
    case 6:pause = 60;switchmenu(2);EEPROM.write(14, pause);break;
    case 7:pause = 75;switchmenu(2);EEPROM.write(14, pause);break;
    case 8:pause = 90;switchmenu(2);EEPROM.write(14, pause);break;
    case 9:pause = 120;switchmenu(2);EEPROM.write(14, pause);break;
    case 10:switchmenu(2);break;
  }
  break;

  //-------------------------------SelectMenu3-----------------------------------------
  case 3 : 
    switch (y){
    case 1:
         lcd.noBlink();
         clearPrintTitle();
         lcd.setCursor(0,1);lcd.print(F("FAN : "));
             if(fan == false){ lcd.print(F("OFF"));}
             else {lcd.print(F("ON"));}
         lcd.setCursor(0,2);lcd.print(F("Temp. cible : "));lcd.print(TEMP_VENTILATION);lcd.print(F("C"));
         lcd.setCursor(0,3);lcd.print(F("Hysteresis : "));lcd.print(HYST_VENT);lcd.print(F("C"));
    break;
    case 2:switchmenu(31);break;
    case 3:switchmenu(0);break;
    }
  break;
  //-------------------------------SelectMenu31-----------------------------------------
  //SET HYSTERESIS
  case 31 :   
    if(y<Nbitems){HYST_VENT = (y*2);switchmenu(3); EEPROM.write(1, HYST_VENT);}
    else{switchmenu(3);}
  break;
  //-------------------------------SelectMenu4-----------------------------------------
  case 4 : 
    switch (y){
    case 1:
         lcd.noBlink();
         clearPrintTitle();
         lcd.setCursor(0,1);lcd.print(F("FOURNAISE(1) : "));
             if(heating1 == false){lcd.print(F("OFF"));}
             else {lcd.print(F("ON"));}
         lcd.setCursor(0,2);lcd.print(F("Temp. cible : "));lcd.print(TEMP_FOURNAISE1);lcd.print(F("C"));
         lcd.setCursor(0,3);lcd.print(F("Hysteresis : "));lcd.print(HYST_FOURNAISE1);lcd.print(F("C"));
    break;
    case 2:
         lcd.noBlink();
         clearPrintTitle();
         lcd.setCursor(0,1);lcd.print(F("FOURNAISE(2) : "));
             if(heating1 == false){lcd.print(F("OFF"));} 
             else {lcd.print(F("ON"));}
         lcd.setCursor(0,2);lcd.print(F("Temp. cible : "));lcd.print(TEMP_FOURNAISE2);lcd.print(F("C"));
         lcd.setCursor(0,3);lcd.print(F("Hysteresis : "));lcd.print(HYST_FOURNAISE2);lcd.print(F("C"));
    break;
    case 3:switchmenu(41);break;
    case 4:switchmenu(42);break;
    case 5:switchmenu(0);break;
    }
  break;
  //-------------------------------SelectMenu41-----------------------------------------
  //SET HYSTERESIS
  case 41 :   
    if(y<Nbitems){HYST_FOURNAISE1 = (y*2);switchmenu(4);EEPROM.write(2, HYST_FOURNAISE1);}
    else{switchmenu(4);}
  break;
  //-------------------------------SelectMenu42-----------------------------------------
  //SET HYSTERESIS
  case 42 :   
    if(y<Nbitems){HYST_FOURNAISE2 = (y*2);switchmenu(4);EEPROM.write(3,HYST_FOURNAISE2);}
    else{switchmenu(4);}
  break;
  //-------------------------------SelectMenu5-----------------------------------------
  //"Programme 1", "Programme 2", "Programme 3", "Modificateurs" "Set Programme 1", "Set Programme 2", "Set Programme 3", "Set Modificateurs", "back"
  case 5 : 
    switch (y){
    case 1:
         lcd.noBlink();
         clearPrintTitle();
         lcd.setCursor(0,1);lcd.print(F("HD: "));lcd.print(HP1);lcd.print(F(":"));lcd.print(MP1);lcd.print(F(" | HF: "));lcd.print(HP2);lcd.print(F(":"));lcd.print(MP2);
         lcd.setCursor(0,2);lcd.print(F("TEMP.CIBLE : "));lcd.print(TEMP_CIBLEP1);lcd.print(F("C"));
    break;
    case 2:
         lcd.noBlink();
         clearPrintTitle();
         lcd.setCursor(0,1);lcd.print(F("HD: "));lcd.print(HP2);lcd.print(F(":"));lcd.print(MP2);lcd.print(F(" | HF: "));lcd.print(HP3);lcd.print(F(":"));lcd.print(MP3);
         lcd.setCursor(0,2);lcd.print(F("TEMP.CIBLE : "));lcd.print(TEMP_CIBLEP2);lcd.print(F("C"));
    break;
    case 3:
         lcd.noBlink();
         clearPrintTitle();
         lcd.setCursor(0,1);lcd.print(F("HD: "));lcd.print(HP3);lcd.print(F(":"));lcd.print(MP3);lcd.print(F(" | HF: "));lcd.print(HP1);lcd.print(F(":"));lcd.print(MP1);
         lcd.setCursor(0,2);lcd.print(F("TEMP.CIBLE : "));lcd.print(TEMP_CIBLEP3);lcd.print(F("C"));
    break;
    case 4:
          lcd.noBlink();
          clearPrintTitle();
          lcd.setCursor(0,1);lcd.print(F("TEMP.CIBLE : "));lcd.print(TEMP_CIBLE);
          lcd.setCursor(0,2);lcd.print(F("RMod:"));lcd.print(rmod);
          lcd.setCursor(8,2);lcd.print(F("| f1mod:"));lcd.print(f1mod);
          lcd.setCursor(0,3);lcd.print(F("VMod:"));lcd.print(vmod);
          lcd.setCursor(8,3);lcd.print(F("| f2mod:"));lcd.print(f2mod);
    break;
    case 5:switchmenu(51);break;
    case 6:switchmenu(52);break;
    case 7:switchmenu(53);break;
    case 8:switchmenu(54);break;
    case 9:switchmenu(0);break;
    }
  break;
  //-------------------------------SelectMenu51-----------------------------------------
  case 51:
  switch(y){
    case 1:switchmenu(511);break;
    case 2:switchmenu(512);break;
    case 3:switchmenu(5);break;
  }
  break;
  //-------------------------------SelectMenu511-----------------------------------------
  //SET HOUR
  case 511 :    
    if(y<Nbitems){HP1 = y;switchmenu(5111);EEPROM.write(4,HP1);}
    else{switchmenu(51);}
  break;
  //-------------------------------SelectMenu5111-----------------------------------------
  //SET MINUTES
  case 5111 :    
    if(y<Nbitems){MP1 = (y-1);switchmenu(51);EEPROM.write(5,MP1);}
    else{switchmenu(51);}
  break;
  //-------------------------------SelectMenu512-----------------------------------------
  //SET TEMP_CIBLE
  case 512 :    
    if(y<Nbitems){TEMP_CIBLEP1 = y;switchmenu(51);EEPROM.write(6,TEMP_CIBLEP1);}
    else{switchmenu(51);}
  break;
  //-------------------------------SelectMenu52-----------------------------------------
  case 52:
  switch(y){
    case 1: switchmenu(521);break;
    case 2:switchmenu(522);break;
    case 3:switchmenu(5);break;
  }
  break;
  //-------------------------------SelectMenu521-----------------------------------------
  //SET HOUR
  case 521 :    
    if(y<Nbitems){HP2 = y;switchmenu(5211);EEPROM.write(7,HP2);}
    else{switchmenu(51);}
  break;
  //-------------------------------SelectMenu5211-----------------------------------------
  //SET MINUTES
  case 5211 :    
    if(y<Nbitems){MP2 = (y-1);switchmenu(51);EEPROM.write(8,MP2);}
    else{switchmenu(51);}
  break;
  //-------------------------------SelectMenu522-----------------------------------------
  //SET TEMP_CIBLE
  case 522 :    
    if(y<Nbitems){TEMP_CIBLEP2 = y;switchmenu(52);EEPROM.write(9,TEMP_CIBLEP2);}
    else{switchmenu(51);}
  break;
  //-------------------------------SelectMenu53-----------------------------------------
  //"Heure", "Tempcible", "back"
  case 53:
  switch(y){
    case 1: switchmenu(531);break;
    case 2:switchmenu(532);break;
    case 3:switchmenu(5);break;
  }
  break;
  //-------------------------------SelectMenu531-----------------------------------------
  //SET HOUR
  case 531 :    
    if(y<25){HP3 = y;switchmenu(5311);EEPROM.write(10,HP3);}
    else{switchmenu(51);}
  break;
  //-------------------------------SelectMenu5311-----------------------------------------
  //SET MINUTES
  case 5311 :    
    if(y<61){MP3 = (y-1);switchmenu(51);EEPROM.write(11,MP3);}
    else{switchmenu(51);}
  break;
  //-------------------------------SelectMenu532-----------------------------------------
  //SET TEMP_CIBLE
  case 532 :    
    if(y<51){TEMP_CIBLEP3 = y;switchmenu(53);EEPROM.write(12,TEMP_CIBLEP3);}
    else{switchmenu(53);}
  break;
  //-------------------------------SelectMenu54-----------------------------------------
  //"Heure", "Tempcible", "back"
  case 54:
  switch(y){
    case 1:switchmenu(541);break;
    case 2:switchmenu(542);break;
    case 3:switchmenu(543);break;
    case 4:switchmenu(544);break;
    case 5:switchmenu(5);break;
  }
  break;
  //-------------------------------SelectMenu541-----------------------------------------
  //SET MOD
  case 541 :    
    if(y<Nbitems){rmodE = y;switchmenu(54);EEPROM.write(15,rmodE);}
    else{switchmenu(54);}
  break;
  //-------------------------------SelectMenu541-----------------------------------------
  //SET MOD
  case 542 :    
    if(y<Nbitems){vmodE = y;switchmenu(54);EEPROM.write(16,vmodE);}
    else{switchmenu(54);}
  break;
  //-------------------------------SelectMenu541-----------------------------------------
  //SET MOD
  case 543 :    
    if(y<Nbitems){f1modE = y;switchmenu(54);EEPROM.write(17,f1modE);}
    else{switchmenu(54);}
  break;
  //-------------------------------SelectMenu541-----------------------------------------
  //SET MOD
  case 544 :    
    if(y<Nbitems){f2modE = y;switchmenu(54);EEPROM.write(18,f2modE);}
    else{switchmenu(54);}
  break;
  }
}






