Problem Using the EEPROMEX library

#include <EEPROMex.h>

void setup() {
  EEPROM.setMemPool(0, EEPROMSizeUno);
  EEPROM.setMaxAllowedWrites(EEPROMSizeUno * 2);  // I don't understand why *2 (it was just trial and error) but if it doesn't report errors. I think the library has "unpolished" details.
  // clear_eeprom
  for (int i = 0 ; i < EEPROMSizeUno ; i++) {
    EEPROM.write(i, 0);
  }
}

void loop() {

}

All 0xFF is the "erased" state of the EEPROM. If you execute an EEPROM erase as part of an upload, that is the value all EEPROM locations will be set to.

No different from using 0x00 - how do you tell if that is your "erased" state or whether 0x00 happens to be saved in the cell? There is no way to tell, regardless of what value you choose to represent "erased".

Here are the equivalent functions in the EEPROM library.
Note that get() and put() will read/write the appropriate number of bytes needed for the data type of the variable. This also works for structures and arrays. Additionally, put() uses the EEPROM update() function, reading the value from each EEPROM location and only writing data if it is different.

traveled_distance = EEPROM.readFloat(0); //EEPROMEx
EEPROM.get(0, traveled_distance);        //EEPROM

EEPROM.writeFloat (0, traveled_distance); //EEPROMEx
EEPROM.put(0, traveled_distance);         //EEPROM
1 Like

That is exactly what I said

So how does writing 0xFF to all locations, as espoused by @GolamMostafa, count as erased ? Initialised, maybe, but not erased

Unless it is the result of the physical construction of EEPROM, it is likely a hold-over from the early UV-erasable EPROM, where exposure to UV light would result in all bits being set to 1.

1 Like

Excerpt from net:

There are two common methods for erasure:

a. UV Erasure (older technology): In older EEPROMs, erasure was achieved by exposing the memory chip to ultraviolet (UV) light. The UV light causes the charge trapped in the memory cells to dissipate, resetting them to their erased state.

b. Electric Field-Based Erasure (modern technology): In modern EEPROMs, electric field-based erasure is used. High voltage (typically in the range of 10-20V) is applied across the memory cells, which creates an electric field that allows electrons to tunnel through the thin oxide layer that separates the floating gate (where data is stored) from the control gate. This process removes the stored charge, effectively erasing the memory cell.

I have this error when using and verify sketch

exit status 1
no matching function for call to 'EEPROMClass::get(int)'

Please post complete code that demonstrates the error.

Did you include the header file for the EEPROM library?

OK .I POST


#include "PinChangeInterrupt.h" // enables the interrupts at the other pin except the ones at the digital pins 2 and 3 
#include <avr/sleep.h>          // enables the sleep function
#include <avr/power.h>          // power management
#include <EEPROMex.h>           // enables some special functions for writing to and reading from EEPROM 
#include <EEPROMVar.h>
#include <Wire.h>               // IIC LIBRARY
#include "RTClib.h"             // Real Time Clock Library
#include <math.h>               // enables complex math functions
#include <Adafruit_SSD1306.h>   // library for the OLED and graphics
#include <Adafruit_GFX.h>      

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

RTC_DS3231 rtc;

// variables declaration
volatile static float vss_pulse_distance = 1260;  
volatile float LLG_injector_flow;                         
volatile static float unleadedFlow = 173e-11;            

byte LLG1, LLG2, LLG3, LLG4, digitLLG, pos = 0;
volatile unsigned long vss_pulses;
volatile float traveled_distance, traveled_distance2, traveled_distance3, seconds_passed, speed, avg_speed, distance_to_LLGstation;
volatile float used_LLG, used_LLG2, instant_LLG_consumption, avg_LLG_consumption, LLG_in_tank, Full_tank = 49;
volatile float used_Unleaded, used_Unleaded2;
volatile float average_L_100km_Unlead;

volatile unsigned long unleadTime1=0, unleadTime2=0, unleadinj_Open_Duration=0;
volatile unsigned long LLG_injector_open_duration = 0, injTime1=0, injTime2=0;
int postemp;
int vss_pin = 2; // VSS signal input at digital pin 2 (INT0)
int LLG_pin = 3; // LLG injector signal input at digital pin 3 (INT1)
int ignition_pin = 19; // ignition signal input
int unleaded_pin = 12; // Unleaded injector signal input


boolean buttonState, buttonState2;
boolean lastButtonState2 = HIGH; 
long lastDebounceTime = 0, logohold, counter, counter2;
volatile boolean ignition = false;
boolean ignoreRelease = false;
boolean inst_disp = true;
byte menunumber = 0,  menunumbermax = 10;
int h=0, m=0, s, m1;
boolean timeRead = false, displaychange = true;
float thermReading, steinhart;
boolean dots = true;

//Below are the variables declaration for the thermistor -- you can find more info at: https://learn.adafruit.com/thermistor/using-a-thermistor
#define THERMISTORPIN A0
#define THERMISTORNOMINAL 10000
#define TEMPERATURENOMINAL 25   

#define NUMSAMPLES 5
#define BCOEFFICIENT 3630
#define SERIESRESISTOR 10000
int samples[NUMSAMPLES];
int i=0;

const unsigned char leaf [] PROGMEM= {
0x00, 0x00, 0x07, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x07, 0xFF, 0xFF, 0x00, 0x3F, 0xFC, 0x1E,
0x00, 0xFF, 0x80, 0x1C, 0x01, 0xFC, 0x00, 0x3C, 0x07, 0xF0, 0x00, 0x38, 0x0F, 0xC0, 0x00, 0x38,
0x1F, 0x00, 0x00, 0x70, 0x1E, 0x00, 0x00, 0x70, 0x3C, 0x00, 0x80, 0x70, 0x38, 0x03, 0xC0, 0x70,
0x70, 0x07, 0xC0, 0x70, 0xF0, 0x1F, 0x80, 0x70, 0xF0, 0x1E, 0x00, 0x70, 0xE0, 0x3E, 0x00, 0x70,
0xE0, 0x78, 0x00, 0x70, 0xE0, 0xF0, 0x00, 0xF0, 0xE1, 0xE0, 0x00, 0xF0, 0xE3, 0xE0, 0x00, 0xE0,
0xE3, 0x80, 0x00, 0xE0, 0xE7, 0x80, 0x01, 0xE0, 0xEF, 0x00, 0x03, 0xE0, 0xEE, 0x00, 0x03, 0xC0,
0xFE, 0x00, 0x07, 0x80, 0x7C, 0x00, 0x1F, 0x00, 0x7C, 0x00, 0xFE, 0x00, 0x3D, 0xFF, 0xFC, 0x00,
0x39, 0xFF, 0xF0, 0x00, 0x70, 0xFE, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00
};

const unsigned char  dist_to_LLG [] PROGMEM= {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00,


};

const unsigned char  average [] PROGMEM= {
0x00, 0x00, 0x07, 0xCE, 0x1F, 0xFE, 0x3F, 0xFE, 0x7C, 0x7C, 0x70, 0xFC, 0xF1, 0xFE, 0xE3, 0xEE,
0xE7, 0xCE, 0xEF, 0x8E, 0xFF, 0x1E, 0x7E, 0x1C, 0x7C, 0x7C, 0xFF, 0xF8, 0xFF, 0xF0, 0xE7, 0xC0
};

const unsigned char averagecons [] PROGMEM= {
0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x07, 0xCE, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00,
0x1F, 0xFE, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x3F, 0xFE, 0x01, 0xC0, 0x0E, 0x20, 0x00, 0x00,
0x7C, 0x7C, 0x01, 0xC0, 0x0E, 0x70, 0x00, 0x00, 0x70, 0xFC, 0x01, 0xC0, 0x0E, 0x38, 0x00, 0x00,
0xF1, 0xFE, 0x01, 0xC0, 0x0E, 0x1C, 0x00, 0x00, 0xE3, 0xEE, 0x01, 0xC0, 0x0E, 0x0C, 0x00, 0x00,
0xE7, 0xCE, 0x01, 0xC0, 0x0F, 0x8C, 0x00, 0x00, 0xEF, 0x8E, 0x01, 0xC0, 0x0F, 0x8C, 0x00, 0x00,
0xFF, 0x1E, 0x01, 0xC0, 0x0F, 0x8C, 0x00, 0x00, 0x7E, 0x1C, 0x01, 0xFF, 0xFF, 0x8C, 0x00, 0x00,

};

void setup()
{ 
  pinMode(5, INPUT); // Button 2
  pinMode(6, INPUT); // Button 1
  
  pinMode(vss_pin, INPUT);
  pinMode(LLG_pin, INPUT);
  pinMode(ignition_pin, INPUT);
  pinMode(unleaded_pin, INPUT);

  // below recalls the values stored in case of power loss 
  traveled_distance = EEPROM.readFloat(0);
  traveled_distance2 = EEPROM.readFloat (5);
  used_LLG = EEPROM.readFloat (10);
  used_LLG2 = EEPROM.readFloat(15);
  LLG_in_tank = EEPROM.readFloat(20);
  seconds_passed = EEPROM.readFloat(25);
  used_Unleaded = EEPROM.readFloat(30);
  traveled_distance3 = EEPROM.readFloat (35);
  used_Unleaded2 = EEPROM.readFloat(45);
  LLG1 = EEPROM.readByte (40);
  LLG2 = EEPROM.readByte (41);
  LLG3 = EEPROM.readByte (42);
  LLG4 = EEPROM.readByte (43);
  LLG_injector_flow = (LLG1 * 1000 + LLG2 * 100 + LLG3 * 10 + LLG4) * 1e-11;

  noInterrupts(); 
  // set and initialize the TIMER1 
    TCCR1A = 0; // set entire TCCR1A register to 0
    TCCR1B = 0; // set entire TCCR1B register to 0 
    TCCR1B |= (1 << CS12);
    TIMSK1 |= (1 << TOIE1); 
    TCNT1 = 3036; 

  attachPCINT(digitalPinToPinChangeInterrupt(ignition_pin), ignitionSignal, CHANGE);

  interrupts();
  delay(10);
}

void loop()
{// When the ignition switch is turned, executes the next two ifs 
  if (ignition == false && digitalRead(19) == LOW) 
  { 
      detachInterrupt(digitalPinToInterrupt(vss_pin)); 
      detachInterrupt(digitalPinToInterrupt(LLG_pin));
      detachPCINT(digitalPinToPinChangeInterrupt(unleaded_pin));
      delay(50);
      ignition = true; 
      if (menunumber == 11) 
      {   
            EEPROM.writeByte(40, LLG1); //stores the new LLG coef.
            EEPROM.writeByte(41, LLG2);
            EEPROM.writeByte(42, LLG3);
            EEPROM.writeByte(43, LLG4);
         LLG_injector_flow = (LLG1 * 1000 + LLG2 * 100 + LLG3 * 10 + LLG4) * 1e-11; 
         inst_disp = false;
         menunumber = 0; 
      }
      if (menunumber == 12) // same as previous for "Time Set" menu
      {
        DateTime dt = rtc.now();
        s = dt.second();
        if (m != m1) s = (((millis() - counter)/1000))%60; 
        else s = dt.second(), m = dt.minute(); 
        rtc.adjust(DateTime(dt.year(), dt.month(), dt.day(), h, m, s)); 
        ignoreRelease = true;
        lastButtonState2 = LOW;
        menunumber = 8;
      }
      // when the ignition switched off it stores the values to the EEPROM
      EEPROM.writeFloat (0, traveled_distance);
      EEPROM.writeFloat (5, traveled_distance2);
      EEPROM.writeFloat (10, used_LLG);
      EEPROM.writeFloat (15, used_LLG2);
      EEPROM.writeFloat (20, LLG_in_tank);
      EEPROM.writeFloat (25, seconds_passed);
      EEPROM.writeFloat (30, used_Unleaded);
      EEPROM.writeFloat (35, traveled_distance3);
      EEPROM.writeFloat (45, used_Unleaded2);

      display.ssd1306_command(SSD1306_DISPLAYOFF); 
      
      sleep_enable(); // enables the sleep mode
      set_sleep_mode(SLEEP_MODE_PWR_DOWN); // set the sleep mode
      cli();
      sleep_disable(); // disables the brown out detector to consume less power while sleeping
      sei();
      sleep_mode(); // microcontroller goes to sleep  
  }
  // when it wakes up continues from here -- also the first time we turn the ignition key to ON starts from here
  if (ignition == false && digitalRead(9) == LOW) 
  { 
      ignition = true;    // this variable is needed in order to run once the code inside this if
      logohold = millis(); // hold the LOGO screen on, for 2 sec
      inst_disp = false;
      display.begin(SSD1306_SWITCHCAPVCC, 0x3C);           
      display.clearDisplay();                              
      display.drawBitmap(0, 0,  average, 128, 64, WHITE);     
      display.display();                                   

      attachInterrupt(digitalPinToInterrupt(vss_pin), distance, RISING); // attaches the interrupt which related to the VSS signal
      attachInterrupt(digitalPinToInterrupt(LLG_pin), LLG_injector_time, CHANGE); // interrupt for LLG injector signal
      attachPCINT(digitalPinToPinChangeInterrupt(unleaded_pin), UnleadedTime, CHANGE); // petrol injector signal input and interrupt 
      while (millis() - logohold < 2000) ; 
                                           

  }

    // every 5sec calculates average LLG consumption, remaining distance accordingly to the calculated remaining fuel in tank, average speed and average Unleaded cons.
  if(millis()%88000 < 50)
    {
    avg_LLG_consumption = 100 * used_LLG2/traveled_distance2; 
    distance_to_LLGstation = 100 * LLG_in_tank/avg_LLG_consumption;   
    avg_speed = (traveled_distance3 / seconds_passed)*3600;           
    average_L_100km_Unlead = 100 * used_Unleaded2/traveled_distance2; 
    }

// For the short and long press function I consulted: http://jmsarduino.blogspot.gr/2009/05/click-for-press-and-hold-for-b.html
// There are many differences though
// "button 1" -- only  SHORT PRESS function -- changes occur on press, because there is no LONG PRESS function
    if (digitalRead(6) != buttonState) { 
      buttonState = digitalRead(6);      
      if (buttonState == HIGH)             
      {                        
      if (menunumber <= menunumbermax){ // changes the display indications forwards
      if (menunumber == menunumbermax) menunumber =0;
      else menunumber += 1;
      }
      if (menunumber == 12) //if we are at the "Time Set" menu it changes the Hour
      { 
        if (h < 23) h += 1, counter = millis();
        else h = 0, counter = millis();
      }
      // if we are at the "LLG Coef." menu it changes the LLG_injector_flow digits
        if (menunumber == 11 && digitLLG == 1){ 
          if (LLG1 < 9) LLG1 += 1, counter = millis();
          else LLG1 = 0, counter = millis();
        }
        if (menunumber == 11 && digitLLG == 2){ 
          if (LLG2 < 9) LLG2 += 1, counter = millis();
          else LLG2 = 0, counter = millis();
        }
        if (menunumber == 11 && digitLLG == 3){
          if (LLG3 < 9) LLG3 += 1, counter = millis();
          else LLG3 = 0, counter = millis();
        }
        if (menunumber == 11 && digitLLG == 4){
          if (LLG4 < 9) LLG4 += 1,  counter = millis();
          else LLG4 = 0, counter = millis();
        }
      }
    }

////////// "button 2" functions /////////////////
buttonState2 = digitalRead(5);
if (buttonState2 == LOW && lastButtonState2 == HIGH) lastDebounceTime = millis(); //keeps the time that button2 pressed

if (buttonState2 == HIGH && lastButtonState2 == LOW) 
{ 
if (ignoreRelease == false) // "button 2" SHORT PRESS functions -- on release
  { 
  if (menunumber <= menunumbermax) 
      {   if (menunumber == 0) menunumber = menunumbermax;
          else menunumber = menunumber - 1;
      }
  if (menunumber == 12)  
      {  if (m < 59) m=m+1, counter = millis();
         else m = 11, counter = millis();
      }
  if (menunumber == 11) // LLG coef. setting menu -- "button 2" short press changes the position of the cursor
      { pos += 18; 
        digitLLG += 1;
        counter = millis();
        if (digitLLG == 5)
          { pos = 0;
            digitLLG = 1;
          }
      }
  }
else ignoreRelease = false;
}
//////////////////// "button 2" LONG PRESS functions /////////////////////////////////////////////////////
if (digitalRead(5) == HIGH) displaychange = true;   
if (buttonState2 == LOW && (millis() - lastDebounceTime) > 3000 && displaychange == true) // below are the long press functions for button 2
{
      if (menunumber == 0) menunumber = 11, counter = millis(), counter2 = millis(), displaychange = false, digitLLG = 1; //goes to the "LLG Coef." menu
      if (menunumber == 1) traveled_distance2 = 0, used_LLG2 = 0, avg_LLG_consumption = 0, used_Unleaded2 = 0;// average LLG consumption and average Unleaeded cons. reset
      if (menunumber == 3) traveled_distance3 = 0, seconds_passed = 0, avg_speed = 0; // average speed reset
      if (menunumber == 4) traveled_distance = 0; //traveled Distance = 0
      if (menunumber == 6) used_LLG = 0; // total LLG litres = 0
      if (menunumber == 7) LLG_in_tank = Full_tank; // LLG tank reset to full
      if (menunumber == 8) menunumber = 12, counter = millis(), counter2 = millis(), timeRead = true, displaychange = false; //goes to the "Time Setting" menu
      if (menunumber == 9) traveled_distance2 = 0, used_LLG2 = 0, avg_LLG_consumption = 0, used_Unleaded2 = 0; // same with menunumber = 1
      if (menunumber == 10) used_Unleaded = 0; // total unleaded fuel reset
  
ignoreRelease = true; 
}
lastButtonState2 = buttonState2;

// below are the misc screens
switch (menunumber) 
{
    case 0: 
cons1:  display.clearDisplay();
        if(inst_disp == true) displaychange = false, inst_disp = false, digitLLG = 0, pos = 0; 
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  average, 32, 32, WHITE);
        display.setCursor(40, 0);
        display.setTextSize(1);
        display.print(F("LLG"));
        display.setCursor(40,12);
        display.setTextSize(2);
        if (speed > 2) display.print(F("l/100km"));
        else display.print(F("l/h")); //when the car is stopped displays the instant consumption in l/h
        display.setCursor(0,36);
        display.setTextSize(4);
        if(instant_LLG_consumption > 99.9) display.print(F("--.-"));
        else display.print(instant_LLG_consumption,1);
        display.display();
    break;

    case 1: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  averagecons, 64, 32, WHITE); 
        display.setCursor(54, 0);
        display.setTextSize(1);
        display.print(F("LLG"));
        display.setCursor(54,15);
        display.setTextSize(2);
        display.print(F("l/100"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        if(isnan(avg_LLG_consumption)|| isinf(avg_LLG_consumption)) display.print(F("---")); 
        else display.print(avg_LLG_consumption, 1);
        display.display();
    break;

    case 2: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(49, 1,  average, 32, 32, WHITE);
        display.setCursor(0,36);
        display.setTextSize(4);
        display.print(speed, 0);
        display.setCursor(84, 34);
        display.setTextSize(2);
        display.print(F("km"));
        display.setCursor(104, 37);
        display.setTextSize(3);
        display.print(F("/"));
        display.setCursor(115, 48);
        display.setTextSize(2);
        display.print(F("h"));
        display.display();
    break;
    
    case 3:  
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(31, 0,  average, 64, 32, WHITE);
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(avg_speed, 0);
        display.setCursor(84, 34);
        display.setTextSize(2);
        display.print(F("km"));
        display.setCursor(104, 37);
        display.setTextSize(3);
        display.print(F("/"));
        display.setCursor(115, 48);
        display.setTextSize(2);
        display.print(F("h"));
        display.display();
    break;
      
    case 4:          
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(48, 0,  average, 32, 32, WHITE); 
        display.setCursor(88,18);
        display.setTextSize(2);
        display.print(F("km"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(traveled_distance, 1);
        display.display();
    break;
      
    case 5:  
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  dist_to_LLG, 128, 32, WHITE); 
        display.setCursor(0, 36);
        display.setTextSize(4);
        if(distance_to_LLGstation < 10 ||  isnan(distance_to_LLGstation) || isinf(distance_to_LLGstation) ) display.print(F("---"));
        else display.print(distance_to_LLGstation,0);
        display.setTextSize(2);
        display.setCursor(90,48);
        display.print(F("km"));
        display.display();
    break;
      
    case 6:
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  leaf, 32, 32, WHITE); 
        display.setCursor(40, 2);
        display.setTextSize(1);
        display.print(F("Total"));
        display.setCursor(40, 12);
        display.setTextSize(2);
        display.print(F("LLG"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(used_LLG,1);
        display.print(F("l"));
        display.display();
    break;

    case 7: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(31, 0,  average, 64, 32, WHITE); 
        display.setCursor(0, 36);
        display.setTextSize(4);
        if (LLG_in_tank <= 0 ) display.print(F("0.0"));
        else display.print(LLG_in_tank,1);
        display.setTextSize(3);
        display.setCursor(105,43);
        display.print(F("l"));
        display.display();
    break;

    case 8: 
 temp1:     if(inst_disp == true) displaychange = false, inst_disp = false;
            display.clearDisplay();
            display.setTextColor(WHITE);
            printTemperature();
            display.drawFastHLine(0, 28, 128, WHITE);
            display.drawFastHLine(0, 29, 128, WHITE);
            display.setCursor(7, 36);
            display.setTextSize(4);
            printTime();
        if(steinhart < 3.5)
          {
          display.drawBitmap(0, 3,  average, 16, 16, WHITE); 
          }
        display.display();
    break;
    
    case 9: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 8,  average, 16, 16, WHITE);
        display.drawBitmap(17, 0,  average, 32, 32, WHITE); 
        display.setCursor(54,13);
        display.setTextSize(2);
        display.print(F("l/100"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        if(isnan(average_L_100km_Unlead)|| isinf(average_L_100km_Unlead)) display.print(F("---"));
        else display.print(average_L_100km_Unlead, 1);
        display.display();
    break;

    case 10: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(96, 0,  average, 32, 32, WHITE); //(x,y, name, DX, DY, color)
        display.setTextSize(1);
        display.setCursor(0, 0);
        display.print(F("Total"));
        display.setTextSize(2);
        display.setCursor(0, 10);
        display.print(F("Unleaded"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(used_Unleaded,1);
        display.setTextSize(3);
        display.setCursor(105,43);
        display.print(F("l"));
        display.display();
      break;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// the following are secondary displays and activated only in case we want to set the LLG Coef.(case 11) or the Time (case 12) 
      
    case 11: // LLG Coef. Setting menu
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.setCursor(0,9);
        display.setTextSize(2);
        display.print(F("LLG Coef."));
        display.drawFastHLine(0, 28, 128, WHITE);
        display.drawFastHLine(0, 29, 128, WHITE);
        display.setCursor(0,36);
        display.setTextSize(3);

        display.print(LLG1);
        display.print(LLG2);
        display.print(LLG3);
        display.print(LLG4);
       
        display.setCursor(pos,42);
        display.print(F("_")); 
        if (digitalRead(5) == HIGH) counter2 = millis(), displaychange = true; //we must release "button 2" at least once in order to be able to go back to instant LLG consuption
        if ((digitalRead(5) == LOW && millis() - counter2 > 3000 && displaychange == true) || millis() - counter > 10000){ 
            EEPROM.writeByte(40, LLG1); //stores the new LLG coef.
            EEPROM.writeByte(41, LLG2);
            EEPROM.writeByte(42, LLG3);
            EEPROM.writeByte(43, LLG4);
         LLG_injector_flow = (LLG1 * 1000 + LLG2 * 100 + LLG3 * 10 + LLG4) * 1e-11; 
         ignoreRelease = true; 
         inst_disp = true;
         lastButtonState2 = LOW;
         menunumber = 0;  
         goto cons1;       
        }
        display.display();
    break;

    case 12: //RTC set
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.setCursor(0,9);
        display.setTextSize(2);
        display.print(F("Time Set"));
        display.drawFastHLine(0, 28, 128, WHITE);
        display.drawFastHLine(0, 29, 128, WHITE);

        if (timeRead == true){ 
        DateTime dt = rtc.now();
        h = dt.hour();
        m = dt.minute();
        m1 = dt.minute(); 
        timeRead = false;
        }
        display.setCursor(7, 36);
        display.setTextSize(4);
        char sdt[15];
        sprintf(sdt, "%02d:%02d", h, m);
        display.print(sdt); 
        display.display();
        
        if(digitalRead(5) == HIGH) counter2 = millis(), displaychange = true; //we must release the button 2 at least once in order to be able to go back to Temp and Time screen
        if((digitalRead(5) == LOW && millis() - counter2 > 3000 && displaychange == true) || millis() - counter > 59000){
        DateTime dt = rtc.now();
        s = dt.second();
        if (m != m1) s = (((millis() - counter)/1000))%60; 
        else s = dt.second(), m = dt.minute(); 
        rtc.adjust(DateTime(dt.year(), dt.month(), dt.day(), h, m, s)); 
        inst_disp = true;
        ignoreRelease = true;
        lastButtonState2 = LOW;
        menunumber = 8;
        }
    break;
      }
  }

ISR(TIMER1_OVF_vect) //TIMER1 overflow interrupt -- occurs every 1sec -- 
{
    instantSpeed();
    
    LLG_Consumption();
    LLG_injector_open_duration = 0;
    
    unleadedConsumption();
    unleadinj_Open_Duration = 0;
    
    seconds_passed++;
    vss_pulses = 0;
   
TCNT1 = 3036;
}

void distance()
{
  vss_pulses++;
  traveled_distance += vss_pulse_distance;  
  traveled_distance2 += vss_pulse_distance; 
  traveled_distance3 += vss_pulse_distance; 
                                            // we calculate 3 times the same thing in order to reset the distance, the average cons. and average speed independently
}

void instantSpeed() 
{
  speed = (vss_pulse_distance * vss_pulses * 3600);  
}

// The following routine is giving the way to calculate the total time that LLG injector open during the 1sec interval
void LLG_injector_time() 
{ 
  injTime2 = micros();
    if ((injTime2 - injTime1)<5400 && (injTime2 - injTime1)> 4) 
    {
    LLG_injector_open_duration = LLG_injector_open_duration + injTime2 - injTime1; 
    }   
  injTime1 = injTime2;
}


void LLG_Consumption()
{
if (speed > 2 ) instant_LLG_consumption = (100*((LLG_injector_open_duration * LLG_injector_flow)*3600))/speed; 
                                                                                                       
else  instant_LLG_consumption = LLG_injector_open_duration * LLG_injector_flow * 3600; // when the car stops calculates the instant consumption in l/h

used_LLG = used_LLG + (LLG_injector_open_duration * LLG_injector_flow);       
used_LLG2 = used_LLG2 + (LLG_injector_open_duration * LLG_injector_flow);     
LLG_in_tank = LLG_in_tank - (LLG_injector_open_duration * LLG_injector_flow); 
}

void UnleadedTime() // it is called every time a change occurs at the gasoline injector signal and calculates gasoline injector opening time, during the 1sec interval

  {
  if (digitalRead(12) == HIGH)
      {
        unleadTime1 = micros();
      }
  if (digitalRead(12) == LOW)
      {
        unleadTime2 = micros();
      }
  if (unleadTime2 > unleadTime1)
      {if ((unleadTime2 - unleadTime1) > 500 && (unleadTime2 - unleadTime1) < 12000) // some conditions to avoid false readings because of noise
                                                                                  
        { 
        unleadinj_Open_Duration = unleadinj_Open_Duration + (unleadTime2 - unleadTime1); //total useconds that the gasoline injector opens throughout 1sec                                                                                
        } 
      }  
  }

void unleadedConsumption()
{
  used_Unleaded = used_Unleaded + (unleadinj_Open_Duration * unleadedFlow);   
  used_Unleaded2 = used_Unleaded2 + (unleadinj_Open_Duration * unleadedFlow); 
}


void ignitionSignal() // this is called everytime the ingintion signal changes -- if the microcontroller is in sleep mode, it will wake up
{
    ignition = !ignition;
}

void printTime() 
{
  DateTime dt = rtc.now();
  char sdt[15]; 
  sprintf(sdt, "%02d:%02d", dt.hour(), dt.minute()); 
  display.print(sdt);          
}

void printTemperature() 
{
            for (i=0; i< NUMSAMPLES; i++) {
             samples[i] = analogRead(THERMISTORPIN);
             delay(10);
            }
        // average all the samples out
              
              thermReading = 0;
              for (i=0; i< NUMSAMPLES; i++) {
                 thermReading += samples[i];
              }
              thermReading /= NUMSAMPLES;

        // convert the value to resistance
        
        thermReading = 1023 / thermReading - 1;
        thermReading = SERIESRESISTOR / thermReading;
       
        steinhart = thermReading / THERMISTORNOMINAL;     // (R/Ro)
        steinhart = log(steinhart);                       // ln(R/Ro)
       
        steinhart /= BCOEFFICIENT;                        // 1/B * ln(R/Ro)
        steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
        steinhart = 1.0 / steinhart;                      // Invert
        steinhart -= 273.15;                              // convert to C
        //steinhart = (steinhart * 9.0)/ 5.0 + 32.0;      // Uncomment if you want to convert Celcius to Fahrenheit

        if (steinhart <0 && steinhart > -0.6){ //this is in order not to display "-0"
          steinhart = 0;
          }
        if(steinhart >= 9.5 || (steinhart <= -0.6 && steinhart > -9.6)) postemp = 62; //postemp: the x position of the cursor is depended on how many characters the temp has (1, 2 or 3)
        if(steinhart < 9.5 && steinhart > -0.6) postemp = 80;
        if(steinhart <= -9.6) postemp = 44;
        display.setCursor(postemp,0);
        display.setTextSize(3);
        display.print(steinhart, 0);
        display.setCursor(100, -2);
        display.setTextSize(1);
        display.print(F("o"));
        display.setCursor(108, 0);
        display.setTextSize(3);
        display.print(F("C"));
}

Now please post the full error message. using code tags when you do

The posted code makes not attempt to convert to EEPROM.h.

You said that you were going to convert, so please post your best effort to do so.

ok this frist try


#include "PinChangeInterrupt.h" // enables the interrupts at the other pin except the ones at the digital pins 2 and 3 
#include <avr/sleep.h>          // enables the sleep function
#include <avr/power.h>          // power management
#include <EEPROM.h>           // enables some special functions for writing to and reading from EEPROM 
#include <Wire.h>               // IIC LIBRARY
#include "RTClib.h"             // Real Time Clock Library
#include <math.h>               // enables complex math functions
#include <Adafruit_SSD1306.h>   // library for the OLED and graphics
#include <Adafruit_GFX.h>      

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

RTC_DS3231 rtc;

// variables declaration
volatile static float vss_pulse_distance = 1260;  
volatile float LLG_injector_flow;                         
volatile static float unleadedFlow = 173e-11;            

byte LLG1, LLG2, LLG3, LLG4, digitLLG, pos = 0;
volatile unsigned long vss_pulses;
volatile float traveled_distance, traveled_distance2, traveled_distance3, seconds_passed, speed, avg_speed, distance_to_LLGstation;
volatile float used_LLG, used_LLG2, instant_LLG_consumption, avg_LLG_consumption, LLG_in_tank, Full_tank = 49;
volatile float used_Unleaded, used_Unleaded2;
volatile float average_L_100km_Unlead;

volatile unsigned long unleadTime1=0, unleadTime2=0, unleadinj_Open_Duration=0;
volatile unsigned long LLG_injector_open_duration = 0, injTime1=0, injTime2=0;
int postemp;
int vss_pin = 2; // VSS signal input at digital pin 2 (INT0)
int LLG_pin = 3; // LLG injector signal input at digital pin 3 (INT1)
int ignition_pin = 19; // ignition signal input
int unleaded_pin = 12; // Unleaded injector signal input


boolean buttonState, buttonState2;
boolean lastButtonState2 = HIGH; 
long lastDebounceTime = 0, logohold, counter, counter2;
volatile boolean ignition = false;
boolean ignoreRelease = false;
boolean inst_disp = true;
byte menunumber = 0,  menunumbermax = 10;
int h=0, m=0, s, m1;
boolean timeRead = false, displaychange = true;
float thermReading, steinhart;
boolean dots = true;

//Below are the variables declaration for the thermistor -- you can find more info at: https://learn.adafruit.com/thermistor/using-a-thermistor
#define THERMISTORPIN A0
#define THERMISTORNOMINAL 10000
#define TEMPERATURENOMINAL 25   

#define NUMSAMPLES 5
#define BCOEFFICIENT 3630
#define SERIESRESISTOR 10000
int samples[NUMSAMPLES];
int i=0;

const unsigned char leaf [] PROGMEM= {
0x00, 0x00, 0x07, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x07, 0xFF, 0xFF, 0x00, 0x3F, 0xFC, 0x1E,
0x00, 0xFF, 0x80, 0x1C, 0x01, 0xFC, 0x00, 0x3C, 0x07, 0xF0, 0x00, 0x38, 0x0F, 0xC0, 0x00, 0x38,
0x1F, 0x00, 0x00, 0x70, 0x1E, 0x00, 0x00, 0x70, 0x3C, 0x00, 0x80, 0x70, 0x38, 0x03, 0xC0, 0x70,
0x70, 0x07, 0xC0, 0x70, 0xF0, 0x1F, 0x80, 0x70, 0xF0, 0x1E, 0x00, 0x70, 0xE0, 0x3E, 0x00, 0x70,
0xE0, 0x78, 0x00, 0x70, 0xE0, 0xF0, 0x00, 0xF0, 0xE1, 0xE0, 0x00, 0xF0, 0xE3, 0xE0, 0x00, 0xE0,
0xE3, 0x80, 0x00, 0xE0, 0xE7, 0x80, 0x01, 0xE0, 0xEF, 0x00, 0x03, 0xE0, 0xEE, 0x00, 0x03, 0xC0,
0xFE, 0x00, 0x07, 0x80, 0x7C, 0x00, 0x1F, 0x00, 0x7C, 0x00, 0xFE, 0x00, 0x3D, 0xFF, 0xFC, 0x00,
0x39, 0xFF, 0xF0, 0x00, 0x70, 0xFE, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00
};

const unsigned char  dist_to_LLG [] PROGMEM= {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00,


};

const unsigned char  average [] PROGMEM= {
0x00, 0x00, 0x07, 0xCE, 0x1F, 0xFE, 0x3F, 0xFE, 0x7C, 0x7C, 0x70, 0xFC, 0xF1, 0xFE, 0xE3, 0xEE,
0xE7, 0xCE, 0xEF, 0x8E, 0xFF, 0x1E, 0x7E, 0x1C, 0x7C, 0x7C, 0xFF, 0xF8, 0xFF, 0xF0, 0xE7, 0xC0
};

const unsigned char averagecons [] PROGMEM= {
0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x07, 0xCE, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00,
0x1F, 0xFE, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x3F, 0xFE, 0x01, 0xC0, 0x0E, 0x20, 0x00, 0x00,
0x7C, 0x7C, 0x01, 0xC0, 0x0E, 0x70, 0x00, 0x00, 0x70, 0xFC, 0x01, 0xC0, 0x0E, 0x38, 0x00, 0x00,
0xF1, 0xFE, 0x01, 0xC0, 0x0E, 0x1C, 0x00, 0x00, 0xE3, 0xEE, 0x01, 0xC0, 0x0E, 0x0C, 0x00, 0x00,
0xE7, 0xCE, 0x01, 0xC0, 0x0F, 0x8C, 0x00, 0x00, 0xEF, 0x8E, 0x01, 0xC0, 0x0F, 0x8C, 0x00, 0x00,
0xFF, 0x1E, 0x01, 0xC0, 0x0F, 0x8C, 0x00, 0x00, 0x7E, 0x1C, 0x01, 0xFF, 0xFF, 0x8C, 0x00, 0x00,

};

void setup()
{ 
  pinMode(5, INPUT); // Button 2
  pinMode(6, INPUT); // Button 1
  
  pinMode(vss_pin, INPUT);
  pinMode(LLG_pin, INPUT);
  pinMode(ignition_pin, INPUT);
  pinMode(unleaded_pin, INPUT);

  // below recalls the values stored in case of power loss 
  traveled_distance = EEPROM.read (0);
  traveled_distance2 = EEPROM.read (5);
  used_LLG = EEPROM.read (10);
  used_LLG2 = EEPROM.read( 15);
  LLG_in_tank = EEPROM.read (20);
  seconds_passed = EEPROM.read (25);
  used_Unleaded = EEPROM.read (30);
  traveled_distance3 = EEPROM.read (35);
  used_Unleaded2 = EEPROM.read (45);
  LLG1 = EEPROM.read (40);
  LLG2 = EEPROM.read (41);
  LLG3 = EEPROM.read (42);
  LLG4 = EEPROM.read (43);
  LLG_injector_flow = (LLG1 * 1000 + LLG2 * 100 + LLG3 * 10 + LLG4) * 1e-11;

  noInterrupts(); 
  // set and initialize the TIMER1 
    TCCR1A = 0; // set entire TCCR1A register to 0
    TCCR1B = 0; // set entire TCCR1B register to 0 
    TCCR1B |= (1 << CS12);
    TIMSK1 |= (1 << TOIE1); 
    TCNT1 = 3036; 

  attachPCINT(digitalPinToPinChangeInterrupt(ignition_pin), ignitionSignal, CHANGE);

  interrupts();
  delay(10);
}

void loop()
{// When the ignition switch is turned, executes the next two ifs 
  if (ignition == false && digitalRead(19) == LOW) 
  { 
      detachInterrupt(digitalPinToInterrupt(vss_pin)); 
      detachInterrupt(digitalPinToInterrupt(LLG_pin));
      detachPCINT(digitalPinToPinChangeInterrupt(unleaded_pin));
      delay(50);
      ignition = true; 
      if (menunumber == 11) 
      {   
            EEPROM.write(40, LLG1); //stores the new LLG coef.
            EEPROM.write(41, LLG2);
            EEPROM.write(42, LLG3);
            EEPROM.write(43, LLG4);
         LLG_injector_flow = (LLG1 * 1000 + LLG2 * 100 + LLG3 * 10 + LLG4) * 1e-11; 
         inst_disp = false;
         menunumber = 0; 
      }
      if (menunumber == 12) // same as previous for "Time Set" menu
      {
        DateTime dt = rtc.now();
        s = dt.second();
        if (m != m1) s = (((millis() - counter)/1000))%60; 
        else s = dt.second(), m = dt.minute(); 
        rtc.adjust(DateTime(dt.year(), dt.month(), dt.day(), h, m, s)); 
        ignoreRelease = true;
        lastButtonState2 = LOW;
        menunumber = 8;
      }
      // when the ignition switched off it stores the values to the EEPROM
      EEPROM.put (0, traveled_distance);
      EEPROM.put (5, traveled_distance2);
      EEPROM.put (10, used_LLG);
      EEPROM.put (15, used_LLG2);
      EEPROM.put (20, LLG_in_tank);
      EEPROM.put (25, seconds_passed);
      EEPROM.put (30, used_Unleaded);
      EEPROM.put (35, traveled_distance3);
      EEPROM.put (45, used_Unleaded2);

      display.ssd1306_command(SSD1306_DISPLAYOFF); 
      
      sleep_enable(); // enables the sleep mode
      set_sleep_mode(SLEEP_MODE_PWR_DOWN); // set the sleep mode
      cli();
      sleep_disable(); // disables the brown out detector to consume less power while sleeping
      sei();
      sleep_mode(); // microcontroller goes to sleep  
  }
  // when it wakes up continues from here -- also the first time we turn the ignition key to ON starts from here
  if (ignition == false && digitalRead(9) == LOW) 
  { 
      ignition = true;    // this variable is needed in order to run once the code inside this if
      logohold = millis(); // hold the LOGO screen on, for 2 sec
      inst_disp = false;
      display.begin(SSD1306_SWITCHCAPVCC, 0x3C);           
      display.clearDisplay();                              
      display.drawBitmap(0, 0,  average, 128, 64, WHITE);     
      display.display();                                   

      attachInterrupt(digitalPinToInterrupt(vss_pin), distance, RISING); // attaches the interrupt which related to the VSS signal
      attachInterrupt(digitalPinToInterrupt(LLG_pin), LLG_injector_time, CHANGE); // interrupt for LLG injector signal
      attachPCINT(digitalPinToPinChangeInterrupt(unleaded_pin), UnleadedTime, CHANGE); // petrol injector signal input and interrupt 
      while (millis() - logohold < 2000) ; 
                                           

  }

    // every 5sec calculates average LLG consumption, remaining distance accordingly to the calculated remaining fuel in tank, average speed and average Unleaded cons.
  if(millis()%88000 < 50)
    {
    avg_LLG_consumption = 100 * used_LLG2/traveled_distance2; 
    distance_to_LLGstation = 100 * LLG_in_tank/avg_LLG_consumption;   
    avg_speed = (traveled_distance3 / seconds_passed)*3600;           
    average_L_100km_Unlead = 100 * used_Unleaded2/traveled_distance2; 
    }

// For the short and long press function I consulted: http://jmsarduino.blogspot.gr/2009/05/click-for-press-and-hold-for-b.html
// There are many differences though
// "button 1" -- only  SHORT PRESS function -- changes occur on press, because there is no LONG PRESS function
    if (digitalRead(6) != buttonState) { 
      buttonState = digitalRead(6);      
      if (buttonState == HIGH)             
      {                        
      if (menunumber <= menunumbermax){ // changes the display indications forwards
      if (menunumber == menunumbermax) menunumber =0;
      else menunumber += 1;
      }
      if (menunumber == 12) //if we are at the "Time Set" menu it changes the Hour
      { 
        if (h < 23) h += 1, counter = millis();
        else h = 0, counter = millis();
      }
      // if we are at the "LLG Coef." menu it changes the LLG_injector_flow digits
        if (menunumber == 11 && digitLLG == 1){ 
          if (LLG1 < 9) LLG1 += 1, counter = millis();
          else LLG1 = 0, counter = millis();
        }
        if (menunumber == 11 && digitLLG == 2){ 
          if (LLG2 < 9) LLG2 += 1, counter = millis();
          else LLG2 = 0, counter = millis();
        }
        if (menunumber == 11 && digitLLG == 3){
          if (LLG3 < 9) LLG3 += 1, counter = millis();
          else LLG3 = 0, counter = millis();
        }
        if (menunumber == 11 && digitLLG == 4){
          if (LLG4 < 9) LLG4 += 1,  counter = millis();
          else LLG4 = 0, counter = millis();
        }
      }
    }

////////// "button 2" functions /////////////////
buttonState2 = digitalRead(5);
if (buttonState2 == LOW && lastButtonState2 == HIGH) lastDebounceTime = millis(); //keeps the time that button2 pressed

if (buttonState2 == HIGH && lastButtonState2 == LOW) 
{ 
if (ignoreRelease == false) // "button 2" SHORT PRESS functions -- on release
  { 
  if (menunumber <= menunumbermax) 
      {   if (menunumber == 0) menunumber = menunumbermax;
          else menunumber = menunumber - 1;
      }
  if (menunumber == 12)  
      {  if (m < 59) m=m+1, counter = millis();
         else m = 11, counter = millis();
      }
  if (menunumber == 11) // LLG coef. setting menu -- "button 2" short press changes the position of the cursor
      { pos += 18; 
        digitLLG += 1;
        counter = millis();
        if (digitLLG == 5)
          { pos = 0;
            digitLLG = 1;
          }
      }
  }
else ignoreRelease = false;
}
//////////////////// "button 2" LONG PRESS functions /////////////////////////////////////////////////////
if (digitalRead(5) == HIGH) displaychange = true;   
if (buttonState2 == LOW && (millis() - lastDebounceTime) > 3000 && displaychange == true) // below are the long press functions for button 2
{
      if (menunumber == 0) menunumber = 11, counter = millis(), counter2 = millis(), displaychange = false, digitLLG = 1; //goes to the "LLG Coef." menu
      if (menunumber == 1) traveled_distance2 = 0, used_LLG2 = 0, avg_LLG_consumption = 0, used_Unleaded2 = 0;// average LLG consumption and average Unleaeded cons. reset
      if (menunumber == 3) traveled_distance3 = 0, seconds_passed = 0, avg_speed = 0; // average speed reset
      if (menunumber == 4) traveled_distance = 0; //traveled Distance = 0
      if (menunumber == 6) used_LLG = 0; // total LLG litres = 0
      if (menunumber == 7) LLG_in_tank = Full_tank; // LLG tank reset to full
      if (menunumber == 8) menunumber = 12, counter = millis(), counter2 = millis(), timeRead = true, displaychange = false; //goes to the "Time Setting" menu
      if (menunumber == 9) traveled_distance2 = 0, used_LLG2 = 0, avg_LLG_consumption = 0, used_Unleaded2 = 0; // same with menunumber = 1
      if (menunumber == 10) used_Unleaded = 0; // total unleaded fuel reset
  
ignoreRelease = true; 
}
lastButtonState2 = buttonState2;

// below are the misc screens
switch (menunumber) 
{
    case 0: 
cons1:  display.clearDisplay();
        if(inst_disp == true) displaychange = false, inst_disp = false, digitLLG = 0, pos = 0; 
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  average, 32, 32, WHITE);
        display.setCursor(40, 0);
        display.setTextSize(1);
        display.print(F("LLG"));
        display.setCursor(40,12);
        display.setTextSize(2);
        if (speed > 2) display.print(F("l/100km"));
        else display.print(F("l/h")); //when the car is stopped displays the instant consumption in l/h
        display.setCursor(0,36);
        display.setTextSize(4);
        if(instant_LLG_consumption > 99.9) display.print(F("--.-"));
        else display.print(instant_LLG_consumption,1);
        display.display();
    break;

    case 1: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  averagecons, 64, 32, WHITE); 
        display.setCursor(54, 0);
        display.setTextSize(1);
        display.print(F("LLG"));
        display.setCursor(54,15);
        display.setTextSize(2);
        display.print(F("l/100"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        if(isnan(avg_LLG_consumption)|| isinf(avg_LLG_consumption)) display.print(F("---")); 
        else display.print(avg_LLG_consumption, 1);
        display.display();
    break;

    case 2: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(49, 1,  average, 32, 32, WHITE);
        display.setCursor(0,36);
        display.setTextSize(4);
        display.print(speed, 0);
        display.setCursor(84, 34);
        display.setTextSize(2);
        display.print(F("km"));
        display.setCursor(104, 37);
        display.setTextSize(3);
        display.print(F("/"));
        display.setCursor(115, 48);
        display.setTextSize(2);
        display.print(F("h"));
        display.display();
    break;
    
    case 3:  
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(31, 0,  average, 64, 32, WHITE);
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(avg_speed, 0);
        display.setCursor(84, 34);
        display.setTextSize(2);
        display.print(F("km"));
        display.setCursor(104, 37);
        display.setTextSize(3);
        display.print(F("/"));
        display.setCursor(115, 48);
        display.setTextSize(2);
        display.print(F("h"));
        display.display();
    break;
      
    case 4:          
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(48, 0,  average, 32, 32, WHITE); 
        display.setCursor(88,18);
        display.setTextSize(2);
        display.print(F("km"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(traveled_distance, 1);
        display.display();
    break;
      
    case 5:  
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  dist_to_LLG, 128, 32, WHITE); 
        display.setCursor(0, 36);
        display.setTextSize(4);
        if(distance_to_LLGstation < 10 ||  isnan(distance_to_LLGstation) || isinf(distance_to_LLGstation) ) display.print(F("---"));
        else display.print(distance_to_LLGstation,0);
        display.setTextSize(2);
        display.setCursor(90,48);
        display.print(F("km"));
        display.display();
    break;
      
    case 6:
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  leaf, 32, 32, WHITE); 
        display.setCursor(40, 2);
        display.setTextSize(1);
        display.print(F("Total"));
        display.setCursor(40, 12);
        display.setTextSize(2);
        display.print(F("LLG"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(used_LLG,1);
        display.print(F("l"));
        display.display();
    break;

    case 7: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(31, 0,  average, 64, 32, WHITE); 
        display.setCursor(0, 36);
        display.setTextSize(4);
        if (LLG_in_tank <= 0 ) display.print(F("0.0"));
        else display.print(LLG_in_tank,1);
        display.setTextSize(3);
        display.setCursor(105,43);
        display.print(F("l"));
        display.display();
    break;

    case 8: 
 temp1:     if(inst_disp == true) displaychange = false, inst_disp = false;
            display.clearDisplay();
            display.setTextColor(WHITE);
            printTemperature();
            display.drawFastHLine(0, 28, 128, WHITE);
            display.drawFastHLine(0, 29, 128, WHITE);
            display.setCursor(7, 36);
            display.setTextSize(4);
            printTime();
        if(steinhart < 3.5)
          {
          display.drawBitmap(0, 3,  average, 16, 16, WHITE); 
          }
        display.display();
    break;
    
    case 9: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 8,  average, 16, 16, WHITE);
        display.drawBitmap(17, 0,  average, 32, 32, WHITE); 
        display.setCursor(54,13);
        display.setTextSize(2);
        display.print(F("l/100"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        if(isnan(average_L_100km_Unlead)|| isinf(average_L_100km_Unlead)) display.print(F("---"));
        else display.print(average_L_100km_Unlead, 1);
        display.display();
    break;

    case 10: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(96, 0,  average, 32, 32, WHITE); //(x,y, name, DX, DY, color)
        display.setTextSize(1);
        display.setCursor(0, 0);
        display.print(F("Total"));
        display.setTextSize(2);
        display.setCursor(0, 10);
        display.print(F("Unleaded"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(used_Unleaded,1);
        display.setTextSize(3);
        display.setCursor(105,43);
        display.print(F("l"));
        display.display();
      break;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// the following are secondary displays and activated only in case we want to set the LLG Coef.(case 11) or the Time (case 12) 
      
    case 11: // LLG Coef. Setting menu
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.setCursor(0,9);
        display.setTextSize(2);
        display.print(F("LLG Coef."));
        display.drawFastHLine(0, 28, 128, WHITE);
        display.drawFastHLine(0, 29, 128, WHITE);
        display.setCursor(0,36);
        display.setTextSize(3);

        display.print(LLG1);
        display.print(LLG2);
        display.print(LLG3);
        display.print(LLG4);
       
        display.setCursor(pos,42);
        display.print(F("_")); 
        if (digitalRead(5) == HIGH) counter2 = millis(), displaychange = true; //we must release "button 2" at least once in order to be able to go back to instant LLG consuption
        if ((digitalRead(5) == LOW && millis() - counter2 > 3000 && displaychange == true) || millis() - counter > 10000){ 
            EEPROM.update(40, LLG1); //stores the new LLG coef.
            EEPROM.update(41, LLG2);
            EEPROM.update(42, LLG3);
            EEPROM.update(43, LLG4);
         LLG_injector_flow = (LLG1 * 1000 + LLG2 * 100 + LLG3 * 10 + LLG4) * 1e-11; 
         ignoreRelease = true; 
         inst_disp = true;
         lastButtonState2 = LOW;
         menunumber = 0;  
         goto cons1;       
        }
        display.display();
    break;

    case 12: //RTC set
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.setCursor(0,9);
        display.setTextSize(2);
        display.print(F("Time Set"));
        display.drawFastHLine(0, 28, 128, WHITE);
        display.drawFastHLine(0, 29, 128, WHITE);

        if (timeRead == true){ 
        DateTime dt = rtc.now();
        h = dt.hour();
        m = dt.minute();
        m1 = dt.minute(); 
        timeRead = false;
        }
        display.setCursor(7, 36);
        display.setTextSize(4);
        char sdt[15];
        sprintf(sdt, "%02d:%02d", h, m);
        display.print(sdt); 
        display.display();
        
        if(digitalRead(5) == HIGH) counter2 = millis(), displaychange = true; //we must release the button 2 at least once in order to be able to go back to Temp and Time screen
        if((digitalRead(5) == LOW && millis() - counter2 > 3000 && displaychange == true) || millis() - counter > 59000){
        DateTime dt = rtc.now();
        s = dt.second();
        if (m != m1) s = (((millis() - counter)/1000))%60; 
        else s = dt.second(), m = dt.minute(); 
        rtc.adjust(DateTime(dt.year(), dt.month(), dt.day(), h, m, s)); 
        inst_disp = true;
        ignoreRelease = true;
        lastButtonState2 = LOW;
        menunumber = 8;
        }
    break;
      }
  }

ISR(TIMER1_OVF_vect) //TIMER1 overflow interrupt -- occurs every 1sec -- 
{
    instantSpeed();
    
    LLG_Consumption();
    LLG_injector_open_duration = 0;
    
    unleadedConsumption();
    unleadinj_Open_Duration = 0;
    
    seconds_passed++;
    vss_pulses = 0;
   
TCNT1 = 3036;
}

void distance()
{
  vss_pulses++;
  traveled_distance += vss_pulse_distance;  
  traveled_distance2 += vss_pulse_distance; 
  traveled_distance3 += vss_pulse_distance; 
                                            // we calculate 3 times the same thing in order to reset the distance, the average cons. and average speed independently
}

void instantSpeed() 
{
  speed = (vss_pulse_distance * vss_pulses * 3600);  
}

// The following routine is giving the way to calculate the total time that LLG injector open during the 1sec interval
void LLG_injector_time() 
{ 
  injTime2 = micros();
    if ((injTime2 - injTime1)<5400 && (injTime2 - injTime1)> 4) 
    {
    LLG_injector_open_duration = LLG_injector_open_duration + injTime2 - injTime1; 
    }   
  injTime1 = injTime2;
}


void LLG_Consumption()
{
if (speed > 2 ) instant_LLG_consumption = (100*((LLG_injector_open_duration * LLG_injector_flow)*3600))/speed; 
                                                                                                       
else  instant_LLG_consumption = LLG_injector_open_duration * LLG_injector_flow * 3600; // when the car stops calculates the instant consumption in l/h

used_LLG = used_LLG + (LLG_injector_open_duration * LLG_injector_flow);       
used_LLG2 = used_LLG2 + (LLG_injector_open_duration * LLG_injector_flow);     
LLG_in_tank = LLG_in_tank - (LLG_injector_open_duration * LLG_injector_flow); 
}

void UnleadedTime() // it is called every time a change occurs at the gasoline injector signal and calculates gasoline injector opening time, during the 1sec interval

  {
  if (digitalRead(12) == HIGH)
      {
        unleadTime1 = micros();
      }
  if (digitalRead(12) == LOW)
      {
        unleadTime2 = micros();
      }
  if (unleadTime2 > unleadTime1)
      {if ((unleadTime2 - unleadTime1) > 500 && (unleadTime2 - unleadTime1) < 12000) // some conditions to avoid false readings because of noise
                                                                                  
        { 
        unleadinj_Open_Duration = unleadinj_Open_Duration + (unleadTime2 - unleadTime1); //total useconds that the gasoline injector opens throughout 1sec                                                                                
        } 
      }  
  }

void unleadedConsumption()
{
  used_Unleaded = used_Unleaded + (unleadinj_Open_Duration * unleadedFlow);   
  used_Unleaded2 = used_Unleaded2 + (unleadinj_Open_Duration * unleadedFlow); 
}


void ignitionSignal() // this is called everytime the ingintion signal changes -- if the microcontroller is in sleep mode, it will wake up
{
    ignition = !ignition;
}

void printTime() 
{
  DateTime dt = rtc.now();
  char sdt[15]; 
  sprintf(sdt, "%02d:%02d", dt.hour(), dt.minute()); 
  display.print(sdt);          
}

void printTemperature() 
{
            for (i=0; i< NUMSAMPLES; i++) {
             samples[i] = analogRead(THERMISTORPIN);
             delay(10);
            }
        // average all the samples out
              
              thermReading = 0;
              for (i=0; i< NUMSAMPLES; i++) {
                 thermReading += samples[i];
              }
              thermReading /= NUMSAMPLES;

        // convert the value to resistance
        
        thermReading = 1023 / thermReading - 1;
        thermReading = SERIESRESISTOR / thermReading;
       
        steinhart = thermReading / THERMISTORNOMINAL;     // (R/Ro)
        steinhart = log(steinhart);                       // ln(R/Ro)
       
        steinhart /= BCOEFFICIENT;                        // 1/B * ln(R/Ro)
        steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
        steinhart = 1.0 / steinhart;                      // Invert
        steinhart -= 273.15;                              // convert to C
        //steinhart = (steinhart * 9.0)/ 5.0 + 32.0;      // Uncomment if you want to convert Celcius to Fahrenheit

        if (steinhart <0 && steinhart > -0.6){ //this is in order not to display "-0"
          steinhart = 0;
          }
        if(steinhart >= 9.5 || (steinhart <= -0.6 && steinhart > -9.6)) postemp = 62; //postemp: the x position of the cursor is depended on how many characters the temp has (1, 2 or 3)
        if(steinhart < 9.5 && steinhart > -0.6) postemp = 80;
        if(steinhart <= -9.6) postemp = 44;
        display.setCursor(postemp,0);
        display.setTextSize(3);
        display.print(steinhart, 0);
        display.setCursor(100, -2);
        display.setTextSize(1);
        display.print(F("o"));
        display.setCursor(108, 0);
        display.setTextSize(3);
        display.print(F("C"));
}

and now i have this log
Have I replaced the library correctly?

E:\trip visitor\BASE_SH1106_1.3_UNO___NON_INGINITION\BASE_SH1106_1.3_UNO___NON_INGINITION.ino: In function 'void loop()':
E:\trip visitor\BASE_SH1106_1.3_UNO___NON_INGINITION\BASE_SH1106_1.3_UNO___NON_INGINITION.ino:166:18: warning: implicit dereference will not access object of type 'const volatile float' in statement
EEPROM.put (0, traveled_distance);
~^~~~~~~~~~~~
E:\trip visitor\BASE_SH1106_1.3_UNO___NON_INGINITION\BASE_SH1106_1.3_UNO___NON_INGINITION.ino:167:18: warning: implicit dereference will not access object of type 'const volatile float' in statement
EEPROM.put (5, traveled_distance2);
~^~~~~~~~~~~~~
E:\trip visitor\BASE_SH1106_1.3_UNO___NON_INGINITION\BASE_SH1106_1.3_UNO___NON_INGINITION.ino:168:18: warning: implicit dereference will not access object of type 'const volatile float' in statement
EEPROM.put (10, used_LLG);
~^~~~
E:\mega_2560.ino:169:18: warning: implicit dereference will not access object of type 'const volatile float' in statement
EEPROM.put (15, used_LLG2);
~^~~~~
E:\mega_2560.ino:170:18: warning: implicit dereference will not access object of type 'const volatile float' in statement
EEPROM.put (20, LLG_in_tank);
~^~~~~~~
E:\mega_2560.ino:171:18: warning: implicit dereference will not access object of type 'const volatile float' in statement
EEPROM.put (25, seconds_passed);
~^~~~~~~~~~
E:\mega_2560.ino:172:18: warning: implicit dereference will not access object of type 'const volatile float' in statement
EEPROM.put (30, used_Unleaded);
~^~~~~~~~~
E:\mega_2560.ino:173:18: warning: implicit dereference will not access object of type 'const volatile float' in statement
EEPROM.put (35, traveled_distance3);
~^~~~~~~~~~~~~~
E:\mega_2560.ino:174:18: warning: implicit dereference will not access object of type 'const volatile float' in statement
EEPROM.put (45, used_Unleaded2);
~^~~~~~~~~~
Sketch uses 29768 bytes (11%) of program storage space. Maximum is 253952 bytes.
Global variables use 586 bytes (7%) of dynamic memory, leaving 7606 bytes for local variables. Maximum is 8192 bytes.

You are using variables declared as 'volatile', make a local copy of the variable (with interrupts temporarily disabled since you are using floats), then save the local copy to EEPROM. Accessing any 'volatile' variable larger than a single byte without disabling interrupts risks an interrupt occuring and changing the value between individual bytes.

        goto cons1;
    case 0:
cons1:  display.clearDisplay();
      if (inst_disp == true) displaychange = false, inst_disp = false, digitLLG = 0, pos = 0;
      display.setTextColor(WHITE);
      display.drawBitmap(0, 0,  average, 32, 32, WHITE);
      display.setCursor(40, 0);
      display.setTextSize(1);
      display.print(F("LLG"));
      display.setCursor(40, 12);
      display.setTextSize(2);
      if (speed > 2) display.print(F("l/100km"));
      else display.print(F("l/h")); //when the car is stopped displays the instant consumption in l/h
      display.setCursor(0, 36);
      display.setTextSize(4);
      if (instant_LLG_consumption > 99.9) display.print(F("--.-"));
      else display.print(instant_LLG_consumption, 1);
      display.display();
      break;

Please no. Using a goto to jump from one case to another in a switch/case makes the code terribly convoluted. Just make the entire case 0 contents (except the break; ) into a functions, and call that in the two places it is needed.

The compiler does not like the use of volatile variables being passed to the .put() and .get() functions. I think it is related to the use of pointers here in the templates.

//Functionality to 'get' and 'put' objects to and from EEPROM.
    template< typename T > T &get( int idx, T &t ){
        EEPtr e = idx;
        uint8_t *ptr = (uint8_t*) &t;
        for( int count = sizeof(T) ; count ; --count, ++e )  *ptr++ = *e;
        return t;
    }
    
    template< typename T > const T &put( int idx, const T &t ){
        EEPtr e = idx;
        const uint8_t *ptr = (const uint8_t*) &t;
        for( int count = sizeof(T) ; count ; --count, ++e )  (*e).update( *ptr++ );
        return t;
    }

I think that one way to deal with this issue is to use a non volatile transfer variable to pass to .put() and .get().

This little piece of code gives the warning, but not for the transfered variable.

#include <EEPROM.h>

volatile float value = 123.45;
float transfer_value;

void setup() {
  transfer_value = value;
  EEPROM.put(0,value);
  EEPROM.put(5, transfer_value);
}

void loop() {}

What happens if I use EEPROM.write or EEPROM.update instead of EEPROM.put?

You can't use .write() or .update() with multi byte variables like floats, ints, or longs.

When using .write() with a volatile byte variable, there is no compiler warning.

This is a very bad idea, but if you insist on not making a local copy of the volatile variable, you can cast it to a non-volatile float

    noInterrupts();
    EEPROM.put (0, (float)traveled_distance);
    EEPROM.put (5, (float)traveled_distance2);
    interrupts();

There is no guarantee the compiler will not treat this improperly and ignore the changes made in the interrupt routine, and it will be disabling interrupts for a long time, so if your interrupts are occurring too frequently you risk missing some. (it can take 3mS or more for an EEPROM write, so the millis count will be corrupted). ( < edit > this likely will not work at all, I can find some reference to the EEPROM library using interrupts itself)

You need to be using local copies of the volatile variables anyway, otherwise you risk getting corrupt values.

hi dear
I just want to replace the EEPROM library in the sketch with the EEPROMEX library, but I don't know what replacement command to use

This is my frist try


#include "PinChangeInterrupt.h" // enables the interrupts at the other pin except the ones at the digital pins 2 and 3 
#include <avr/sleep.h>          // enables the sleep function
#include <avr/power.h>          // power management
#include <EEPROM.h>           // enables some special functions for writing to and reading from EEPROM 
#include <Wire.h>               // IIC LIBRARY
#include "RTClib.h"             // Real Time Clock Library
#include <math.h>               // enables complex math functions
#include <Adafruit_SSD1306.h>   // library for the OLED and graphics
#include <Adafruit_GFX.h>      

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

RTC_DS3231 rtc;

// variables declaration
volatile static float vss_pulse_distance = 1260;  
volatile float LLG_injector_flow;                         
volatile static float unleadedFlow = 173e-11;            

byte LLG1, LLG2, LLG3, LLG4, digitLLG, pos = 0;
volatile unsigned long vss_pulses;
volatile float traveled_distance, traveled_distance2, traveled_distance3, seconds_passed, speed, avg_speed, distance_to_LLGstation;
volatile float used_LLG, used_LLG2, instant_LLG_consumption, avg_LLG_consumption, LLG_in_tank, Full_tank = 49;
volatile float used_Unleaded, used_Unleaded2;
volatile float average_L_100km_Unlead;

volatile unsigned long unleadTime1=0, unleadTime2=0, unleadinj_Open_Duration=0;
volatile unsigned long LLG_injector_open_duration = 0, injTime1=0, injTime2=0;
int postemp;
int vss_pin = 2; // VSS signal input at digital pin 2 (INT0)
int LLG_pin = 3; // LLG injector signal input at digital pin 3 (INT1)
int ignition_pin = 19; // ignition signal input
int unleaded_pin = 12; // Unleaded injector signal input


boolean buttonState, buttonState2;
boolean lastButtonState2 = HIGH; 
long lastDebounceTime = 0, logohold, counter, counter2;
volatile boolean ignition = false;
boolean ignoreRelease = false;
boolean inst_disp = true;
byte menunumber = 0,  menunumbermax = 10;
int h=0, m=0, s, m1;
boolean timeRead = false, displaychange = true;
float thermReading, steinhart;
boolean dots = true;

//Below are the variables declaration for the thermistor -- you can find more info at: https://learn.adafruit.com/thermistor/using-a-thermistor
#define THERMISTORPIN A0
#define THERMISTORNOMINAL 10000
#define TEMPERATURENOMINAL 25   

#define NUMSAMPLES 5
#define BCOEFFICIENT 3630
#define SERIESRESISTOR 10000
int samples[NUMSAMPLES];
int i=0;

const unsigned char leaf [] PROGMEM= {
0x00, 0x00, 0x07, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x07, 0xFF, 0xFF, 0x00, 0x3F, 0xFC, 0x1E,
0x00, 0xFF, 0x80, 0x1C, 0x01, 0xFC, 0x00, 0x3C, 0x07, 0xF0, 0x00, 0x38, 0x0F, 0xC0, 0x00, 0x38,
0x1F, 0x00, 0x00, 0x70, 0x1E, 0x00, 0x00, 0x70, 0x3C, 0x00, 0x80, 0x70, 0x38, 0x03, 0xC0, 0x70,
0x70, 0x07, 0xC0, 0x70, 0xF0, 0x1F, 0x80, 0x70, 0xF0, 0x1E, 0x00, 0x70, 0xE0, 0x3E, 0x00, 0x70,
0xE0, 0x78, 0x00, 0x70, 0xE0, 0xF0, 0x00, 0xF0, 0xE1, 0xE0, 0x00, 0xF0, 0xE3, 0xE0, 0x00, 0xE0,
0xE3, 0x80, 0x00, 0xE0, 0xE7, 0x80, 0x01, 0xE0, 0xEF, 0x00, 0x03, 0xE0, 0xEE, 0x00, 0x03, 0xC0,
0xFE, 0x00, 0x07, 0x80, 0x7C, 0x00, 0x1F, 0x00, 0x7C, 0x00, 0xFE, 0x00, 0x3D, 0xFF, 0xFC, 0x00,
0x39, 0xFF, 0xF0, 0x00, 0x70, 0xFE, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00
};

const unsigned char  dist_to_LLG [] PROGMEM= {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00,


};

const unsigned char  average [] PROGMEM= {
0x00, 0x00, 0x07, 0xCE, 0x1F, 0xFE, 0x3F, 0xFE, 0x7C, 0x7C, 0x70, 0xFC, 0xF1, 0xFE, 0xE3, 0xEE,
0xE7, 0xCE, 0xEF, 0x8E, 0xFF, 0x1E, 0x7E, 0x1C, 0x7C, 0x7C, 0xFF, 0xF8, 0xFF, 0xF0, 0xE7, 0xC0
};

const unsigned char averagecons [] PROGMEM= {
0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x07, 0xCE, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00,
0x1F, 0xFE, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x3F, 0xFE, 0x01, 0xC0, 0x0E, 0x20, 0x00, 0x00,
0x7C, 0x7C, 0x01, 0xC0, 0x0E, 0x70, 0x00, 0x00, 0x70, 0xFC, 0x01, 0xC0, 0x0E, 0x38, 0x00, 0x00,
0xF1, 0xFE, 0x01, 0xC0, 0x0E, 0x1C, 0x00, 0x00, 0xE3, 0xEE, 0x01, 0xC0, 0x0E, 0x0C, 0x00, 0x00,
0xE7, 0xCE, 0x01, 0xC0, 0x0F, 0x8C, 0x00, 0x00, 0xEF, 0x8E, 0x01, 0xC0, 0x0F, 0x8C, 0x00, 0x00,
0xFF, 0x1E, 0x01, 0xC0, 0x0F, 0x8C, 0x00, 0x00, 0x7E, 0x1C, 0x01, 0xFF, 0xFF, 0x8C, 0x00, 0x00,

};

void setup()
{ 
  pinMode(5, INPUT); // Button 2
  pinMode(6, INPUT); // Button 1
  
  pinMode(vss_pin, INPUT);
  pinMode(LLG_pin, INPUT);
  pinMode(ignition_pin, INPUT);
  pinMode(unleaded_pin, INPUT);

  // below recalls the values stored in case of power loss 
  traveled_distance = EEPROM.read (0);
  traveled_distance2 = EEPROM.read (5);
  used_LLG = EEPROM.read (10);
  used_LLG2 = EEPROM.read( 15);
  LLG_in_tank = EEPROM.read (20);
  seconds_passed = EEPROM.read (25);
  used_Unleaded = EEPROM.read (30);
  traveled_distance3 = EEPROM.read (35);
  used_Unleaded2 = EEPROM.read (45);
  LLG1 = EEPROM.read (40);
  LLG2 = EEPROM.read (41);
  LLG3 = EEPROM.read (42);
  LLG4 = EEPROM.read (43);
  LLG_injector_flow = (LLG1 * 1000 + LLG2 * 100 + LLG3 * 10 + LLG4) * 1e-11;

  noInterrupts(); 
  // set and initialize the TIMER1 
    TCCR1A = 0; // set entire TCCR1A register to 0
    TCCR1B = 0; // set entire TCCR1B register to 0 
    TCCR1B |= (1 << CS12);
    TIMSK1 |= (1 << TOIE1); 
    TCNT1 = 3036; 

  attachPCINT(digitalPinToPinChangeInterrupt(ignition_pin), ignitionSignal, CHANGE);

  interrupts();
  delay(10);
}

void loop()
{// When the ignition switch is turned, executes the next two ifs 
  if (ignition == false && digitalRead(19) == LOW) 
  { 
      detachInterrupt(digitalPinToInterrupt(vss_pin)); 
      detachInterrupt(digitalPinToInterrupt(LLG_pin));
      detachPCINT(digitalPinToPinChangeInterrupt(unleaded_pin));
      delay(50);
      ignition = true; 
      if (menunumber == 11) 
      {   
            EEPROM.write(40, LLG1); //stores the new LLG coef.
            EEPROM.write(41, LLG2);
            EEPROM.write(42, LLG3);
            EEPROM.write(43, LLG4);
         LLG_injector_flow = (LLG1 * 1000 + LLG2 * 100 + LLG3 * 10 + LLG4) * 1e-11; 
         inst_disp = false;
         menunumber = 0; 
      }
      if (menunumber == 12) // same as previous for "Time Set" menu
      {
        DateTime dt = rtc.now();
        s = dt.second();
        if (m != m1) s = (((millis() - counter)/1000))%60; 
        else s = dt.second(), m = dt.minute(); 
        rtc.adjust(DateTime(dt.year(), dt.month(), dt.day(), h, m, s)); 
        ignoreRelease = true;
        lastButtonState2 = LOW;
        menunumber = 8;
      }
      // when the ignition switched off it stores the values to the EEPROM
      EEPROM.put (0, traveled_distance);
      EEPROM.put (5, traveled_distance2);
      EEPROM.put (10, used_LLG);
      EEPROM.put (15, used_LLG2);
      EEPROM.put (20, LLG_in_tank);
      EEPROM.put (25, seconds_passed);
      EEPROM.put (30, used_Unleaded);
      EEPROM.put (35, traveled_distance3);
      EEPROM.put (45, used_Unleaded2);

      display.ssd1306_command(SSD1306_DISPLAYOFF); 
      
      sleep_enable(); // enables the sleep mode
      set_sleep_mode(SLEEP_MODE_PWR_DOWN); // set the sleep mode
      cli();
      sleep_disable(); // disables the brown out detector to consume less power while sleeping
      sei();
      sleep_mode(); // microcontroller goes to sleep  
  }
  // when it wakes up continues from here -- also the first time we turn the ignition key to ON starts from here
  if (ignition == false && digitalRead(9) == LOW) 
  { 
      ignition = true;    // this variable is needed in order to run once the code inside this if
      logohold = millis(); // hold the LOGO screen on, for 2 sec
      inst_disp = false;
      display.begin(SSD1306_SWITCHCAPVCC, 0x3C);           
      display.clearDisplay();                              
      display.drawBitmap(0, 0,  average, 128, 64, WHITE);     
      display.display();                                   

      attachInterrupt(digitalPinToInterrupt(vss_pin), distance, RISING); // attaches the interrupt which related to the VSS signal
      attachInterrupt(digitalPinToInterrupt(LLG_pin), LLG_injector_time, CHANGE); // interrupt for LLG injector signal
      attachPCINT(digitalPinToPinChangeInterrupt(unleaded_pin), UnleadedTime, CHANGE); // petrol injector signal input and interrupt 
      while (millis() - logohold < 2000) ; 
                                           

  }

    // every 5sec calculates average LLG consumption, remaining distance accordingly to the calculated remaining fuel in tank, average speed and average Unleaded cons.
  if(millis()%88000 < 50)
    {
    avg_LLG_consumption = 100 * used_LLG2/traveled_distance2; 
    distance_to_LLGstation = 100 * LLG_in_tank/avg_LLG_consumption;   
    avg_speed = (traveled_distance3 / seconds_passed)*3600;           
    average_L_100km_Unlead = 100 * used_Unleaded2/traveled_distance2; 
    }

// For the short and long press function I consulted: http://jmsarduino.blogspot.gr/2009/05/click-for-press-and-hold-for-b.html
// There are many differences though
// "button 1" -- only  SHORT PRESS function -- changes occur on press, because there is no LONG PRESS function
    if (digitalRead(6) != buttonState) { 
      buttonState = digitalRead(6);      
      if (buttonState == HIGH)             
      {                        
      if (menunumber <= menunumbermax){ // changes the display indications forwards
      if (menunumber == menunumbermax) menunumber =0;
      else menunumber += 1;
      }
      if (menunumber == 12) //if we are at the "Time Set" menu it changes the Hour
      { 
        if (h < 23) h += 1, counter = millis();
        else h = 0, counter = millis();
      }
      // if we are at the "LLG Coef." menu it changes the LLG_injector_flow digits
        if (menunumber == 11 && digitLLG == 1){ 
          if (LLG1 < 9) LLG1 += 1, counter = millis();
          else LLG1 = 0, counter = millis();
        }
        if (menunumber == 11 && digitLLG == 2){ 
          if (LLG2 < 9) LLG2 += 1, counter = millis();
          else LLG2 = 0, counter = millis();
        }
        if (menunumber == 11 && digitLLG == 3){
          if (LLG3 < 9) LLG3 += 1, counter = millis();
          else LLG3 = 0, counter = millis();
        }
        if (menunumber == 11 && digitLLG == 4){
          if (LLG4 < 9) LLG4 += 1,  counter = millis();
          else LLG4 = 0, counter = millis();
        }
      }
    }

////////// "button 2" functions /////////////////
buttonState2 = digitalRead(5);
if (buttonState2 == LOW && lastButtonState2 == HIGH) lastDebounceTime = millis(); //keeps the time that button2 pressed

if (buttonState2 == HIGH && lastButtonState2 == LOW) 
{ 
if (ignoreRelease == false) // "button 2" SHORT PRESS functions -- on release
  { 
  if (menunumber <= menunumbermax) 
      {   if (menunumber == 0) menunumber = menunumbermax;
          else menunumber = menunumber - 1;
      }
  if (menunumber == 12)  
      {  if (m < 59) m=m+1, counter = millis();
         else m = 11, counter = millis();
      }
  if (menunumber == 11) // LLG coef. setting menu -- "button 2" short press changes the position of the cursor
      { pos += 18; 
        digitLLG += 1;
        counter = millis();
        if (digitLLG == 5)
          { pos = 0;
            digitLLG = 1;
          }
      }
  }
else ignoreRelease = false;
}
//////////////////// "button 2" LONG PRESS functions /////////////////////////////////////////////////////
if (digitalRead(5) == HIGH) displaychange = true;   
if (buttonState2 == LOW && (millis() - lastDebounceTime) > 3000 && displaychange == true) // below are the long press functions for button 2
{
      if (menunumber == 0) menunumber = 11, counter = millis(), counter2 = millis(), displaychange = false, digitLLG = 1; //goes to the "LLG Coef." menu
      if (menunumber == 1) traveled_distance2 = 0, used_LLG2 = 0, avg_LLG_consumption = 0, used_Unleaded2 = 0;// average LLG consumption and average Unleaeded cons. reset
      if (menunumber == 3) traveled_distance3 = 0, seconds_passed = 0, avg_speed = 0; // average speed reset
      if (menunumber == 4) traveled_distance = 0; //traveled Distance = 0
      if (menunumber == 6) used_LLG = 0; // total LLG litres = 0
      if (menunumber == 7) LLG_in_tank = Full_tank; // LLG tank reset to full
      if (menunumber == 8) menunumber = 12, counter = millis(), counter2 = millis(), timeRead = true, displaychange = false; //goes to the "Time Setting" menu
      if (menunumber == 9) traveled_distance2 = 0, used_LLG2 = 0, avg_LLG_consumption = 0, used_Unleaded2 = 0; // same with menunumber = 1
      if (menunumber == 10) used_Unleaded = 0; // total unleaded fuel reset
  
ignoreRelease = true; 
}
lastButtonState2 = buttonState2;

// below are the misc screens
switch (menunumber) 
{
    case 0: 
cons1:  display.clearDisplay();
        if(inst_disp == true) displaychange = false, inst_disp = false, digitLLG = 0, pos = 0; 
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  average, 32, 32, WHITE);
        display.setCursor(40, 0);
        display.setTextSize(1);
        display.print(F("LLG"));
        display.setCursor(40,12);
        display.setTextSize(2);
        if (speed > 2) display.print(F("l/100km"));
        else display.print(F("l/h")); //when the car is stopped displays the instant consumption in l/h
        display.setCursor(0,36);
        display.setTextSize(4);
        if(instant_LLG_consumption > 99.9) display.print(F("--.-"));
        else display.print(instant_LLG_consumption,1);
        display.display();
    break;

    case 1: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  averagecons, 64, 32, WHITE); 
        display.setCursor(54, 0);
        display.setTextSize(1);
        display.print(F("LLG"));
        display.setCursor(54,15);
        display.setTextSize(2);
        display.print(F("l/100"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        if(isnan(avg_LLG_consumption)|| isinf(avg_LLG_consumption)) display.print(F("---")); 
        else display.print(avg_LLG_consumption, 1);
        display.display();
    break;

    case 2: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(49, 1,  average, 32, 32, WHITE);
        display.setCursor(0,36);
        display.setTextSize(4);
        display.print(speed, 0);
        display.setCursor(84, 34);
        display.setTextSize(2);
        display.print(F("km"));
        display.setCursor(104, 37);
        display.setTextSize(3);
        display.print(F("/"));
        display.setCursor(115, 48);
        display.setTextSize(2);
        display.print(F("h"));
        display.display();
    break;
    
    case 3:  
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(31, 0,  average, 64, 32, WHITE);
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(avg_speed, 0);
        display.setCursor(84, 34);
        display.setTextSize(2);
        display.print(F("km"));
        display.setCursor(104, 37);
        display.setTextSize(3);
        display.print(F("/"));
        display.setCursor(115, 48);
        display.setTextSize(2);
        display.print(F("h"));
        display.display();
    break;
      
    case 4:          
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(48, 0,  average, 32, 32, WHITE); 
        display.setCursor(88,18);
        display.setTextSize(2);
        display.print(F("km"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(traveled_distance, 1);
        display.display();
    break;
      
    case 5:  
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  dist_to_LLG, 128, 32, WHITE); 
        display.setCursor(0, 36);
        display.setTextSize(4);
        if(distance_to_LLGstation < 10 ||  isnan(distance_to_LLGstation) || isinf(distance_to_LLGstation) ) display.print(F("---"));
        else display.print(distance_to_LLGstation,0);
        display.setTextSize(2);
        display.setCursor(90,48);
        display.print(F("km"));
        display.display();
    break;
      
    case 6:
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 0,  leaf, 32, 32, WHITE); 
        display.setCursor(40, 2);
        display.setTextSize(1);
        display.print(F("Total"));
        display.setCursor(40, 12);
        display.setTextSize(2);
        display.print(F("LLG"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(used_LLG,1);
        display.print(F("l"));
        display.display();
    break;

    case 7: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(31, 0,  average, 64, 32, WHITE); 
        display.setCursor(0, 36);
        display.setTextSize(4);
        if (LLG_in_tank <= 0 ) display.print(F("0.0"));
        else display.print(LLG_in_tank,1);
        display.setTextSize(3);
        display.setCursor(105,43);
        display.print(F("l"));
        display.display();
    break;

    case 8: 
 temp1:     if(inst_disp == true) displaychange = false, inst_disp = false;
            display.clearDisplay();
            display.setTextColor(WHITE);
            printTemperature();
            display.drawFastHLine(0, 28, 128, WHITE);
            display.drawFastHLine(0, 29, 128, WHITE);
            display.setCursor(7, 36);
            display.setTextSize(4);
            printTime();
        if(steinhart < 3.5)
          {
          display.drawBitmap(0, 3,  average, 16, 16, WHITE); 
          }
        display.display();
    break;
    
    case 9: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(0, 8,  average, 16, 16, WHITE);
        display.drawBitmap(17, 0,  average, 32, 32, WHITE); 
        display.setCursor(54,13);
        display.setTextSize(2);
        display.print(F("l/100"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        if(isnan(average_L_100km_Unlead)|| isinf(average_L_100km_Unlead)) display.print(F("---"));
        else display.print(average_L_100km_Unlead, 1);
        display.display();
    break;

    case 10: 
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.drawBitmap(96, 0,  average, 32, 32, WHITE); //(x,y, name, DX, DY, color)
        display.setTextSize(1);
        display.setCursor(0, 0);
        display.print(F("Total"));
        display.setTextSize(2);
        display.setCursor(0, 10);
        display.print(F("Unleaded"));
        display.setCursor(0, 36);
        display.setTextSize(4);
        display.print(used_Unleaded,1);
        display.setTextSize(3);
        display.setCursor(105,43);
        display.print(F("l"));
        display.display();
      break;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// the following are secondary displays and activated only in case we want to set the LLG Coef.(case 11) or the Time (case 12) 
      
    case 11: // LLG Coef. Setting menu
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.setCursor(0,9);
        display.setTextSize(2);
        display.print(F("LLG Coef."));
        display.drawFastHLine(0, 28, 128, WHITE);
        display.drawFastHLine(0, 29, 128, WHITE);
        display.setCursor(0,36);
        display.setTextSize(3);

        display.print(LLG1);
        display.print(LLG2);
        display.print(LLG3);
        display.print(LLG4);
       
        display.setCursor(pos,42);
        display.print(F("_")); 
        if (digitalRead(5) == HIGH) counter2 = millis(), displaychange = true; //we must release "button 2" at least once in order to be able to go back to instant LLG consuption
        if ((digitalRead(5) == LOW && millis() - counter2 > 3000 && displaychange == true) || millis() - counter > 10000){ 
            EEPROM.update(40, LLG1); //stores the new LLG coef.
            EEPROM.update(41, LLG2);
            EEPROM.update(42, LLG3);
            EEPROM.update(43, LLG4);
         LLG_injector_flow = (LLG1 * 1000 + LLG2 * 100 + LLG3 * 10 + LLG4) * 1e-11; 
         ignoreRelease = true; 
         inst_disp = true;
         lastButtonState2 = LOW;
         menunumber = 0;  
         goto cons1;       
        }
        display.display();
    break;

    case 12: //RTC set
        display.clearDisplay();
        display.setTextColor(WHITE);
        display.setCursor(0,9);
        display.setTextSize(2);
        display.print(F("Time Set"));
        display.drawFastHLine(0, 28, 128, WHITE);
        display.drawFastHLine(0, 29, 128, WHITE);

        if (timeRead == true){ 
        DateTime dt = rtc.now();
        h = dt.hour();
        m = dt.minute();
        m1 = dt.minute(); 
        timeRead = false;
        }
        display.setCursor(7, 36);
        display.setTextSize(4);
        char sdt[15];
        sprintf(sdt, "%02d:%02d", h, m);
        display.print(sdt); 
        display.display();
        
        if(digitalRead(5) == HIGH) counter2 = millis(), displaychange = true; //we must release the button 2 at least once in order to be able to go back to Temp and Time screen
        if((digitalRead(5) == LOW && millis() - counter2 > 3000 && displaychange == true) || millis() - counter > 59000){
        DateTime dt = rtc.now();
        s = dt.second();
        if (m != m1) s = (((millis() - counter)/1000))%60; 
        else s = dt.second(), m = dt.minute(); 
        rtc.adjust(DateTime(dt.year(), dt.month(), dt.day(), h, m, s)); 
        inst_disp = true;
        ignoreRelease = true;
        lastButtonState2 = LOW;
        menunumber = 8;
        }
    break;
      }
  }

ISR(TIMER1_OVF_vect) //TIMER1 overflow interrupt -- occurs every 1sec -- 
{
    instantSpeed();
    
    LLG_Consumption();
    LLG_injector_open_duration = 0;
    
    unleadedConsumption();
    unleadinj_Open_Duration = 0;
    
    seconds_passed++;
    vss_pulses = 0;
   
TCNT1 = 3036;
}

void distance()
{
  vss_pulses++;
  traveled_distance += vss_pulse_distance;  
  traveled_distance2 += vss_pulse_distance; 
  traveled_distance3 += vss_pulse_distance; 
                                            // we calculate 3 times the same thing in order to reset the distance, the average cons. and average speed independently
}

void instantSpeed() 
{
  speed = (vss_pulse_distance * vss_pulses * 3600);  
}

// The following routine is giving the way to calculate the total time that LLG injector open during the 1sec interval
void LLG_injector_time() 
{ 
  injTime2 = micros();
    if ((injTime2 - injTime1)<5400 && (injTime2 - injTime1)> 4) 
    {
    LLG_injector_open_duration = LLG_injector_open_duration + injTime2 - injTime1; 
    }   
  injTime1 = injTime2;
}


void LLG_Consumption()
{
if (speed > 2 ) instant_LLG_consumption = (100*((LLG_injector_open_duration * LLG_injector_flow)*3600))/speed; 
                                                                                                       
else  instant_LLG_consumption = LLG_injector_open_duration * LLG_injector_flow * 3600; // when the car stops calculates the instant consumption in l/h

used_LLG = used_LLG + (LLG_injector_open_duration * LLG_injector_flow);       
used_LLG2 = used_LLG2 + (LLG_injector_open_duration * LLG_injector_flow);     
LLG_in_tank = LLG_in_tank - (LLG_injector_open_duration * LLG_injector_flow); 
}

void UnleadedTime() // it is called every time a change occurs at the gasoline injector signal and calculates gasoline injector opening time, during the 1sec interval

  {
  if (digitalRead(12) == HIGH)
      {
        unleadTime1 = micros();
      }
  if (digitalRead(12) == LOW)
      {
        unleadTime2 = micros();
      }
  if (unleadTime2 > unleadTime1)
      {if ((unleadTime2 - unleadTime1) > 500 && (unleadTime2 - unleadTime1) < 12000) // some conditions to avoid false readings because of noise
                                                                                  
        { 
        unleadinj_Open_Duration = unleadinj_Open_Duration + (unleadTime2 - unleadTime1); //total useconds that the gasoline injector opens throughout 1sec                                                                                
        } 
      }  
  }

void unleadedConsumption()
{
  used_Unleaded = used_Unleaded + (unleadinj_Open_Duration * unleadedFlow);   
  used_Unleaded2 = used_Unleaded2 + (unleadinj_Open_Duration * unleadedFlow); 
}


void ignitionSignal() // this is called everytime the ingintion signal changes -- if the microcontroller is in sleep mode, it will wake up
{
    ignition = !ignition;
}

void printTime() 
{
  DateTime dt = rtc.now();
  char sdt[15]; 
  sprintf(sdt, "%02d:%02d", dt.hour(), dt.minute()); 
  display.print(sdt);          
}

void printTemperature() 
{
            for (i=0; i< NUMSAMPLES; i++) {
             samples[i] = analogRead(THERMISTORPIN);
             delay(10);
            }
        // average all the samples out
              
              thermReading = 0;
              for (i=0; i< NUMSAMPLES; i++) {
                 thermReading += samples[i];
              }
              thermReading /= NUMSAMPLES;

        // convert the value to resistance
        
        thermReading = 1023 / thermReading - 1;
        thermReading = SERIESRESISTOR / thermReading;
       
        steinhart = thermReading / THERMISTORNOMINAL;     // (R/Ro)
        steinhart = log(steinhart);                       // ln(R/Ro)
       
        steinhart /= BCOEFFICIENT;                        // 1/B * ln(R/Ro)
        steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
        steinhart = 1.0 / steinhart;                      // Invert
        steinhart -= 273.15;                              // convert to C
        //steinhart = (steinhart * 9.0)/ 5.0 + 32.0;      // Uncomment if you want to convert Celcius to Fahrenheit

        if (steinhart <0 && steinhart > -0.6){ //this is in order not to display "-0"
          steinhart = 0;
          }
        if(steinhart >= 9.5 || (steinhart <= -0.6 && steinhart > -9.6)) postemp = 62; //postemp: the x position of the cursor is depended on how many characters the temp has (1, 2 or 3)
        if(steinhart < 9.5 && steinhart > -0.6) postemp = 80;
        if(steinhart <= -9.6) postemp = 44;
        display.setCursor(postemp,0);
        display.setTextSize(3);
        display.print(steinhart, 0);
        display.setCursor(100, -2);
        display.setTextSize(1);
        display.print(F("o"));
        display.setCursor(108, 0);
        display.setTextSize(3);
        display.print(F("C"));
}

I just want to replace the EEPROM library in the sketch with the EEPROMEX library, but I don't know what replacement command to use

You first posted that you had written a sketch using eepromex. What is preventing you from going back to it? Does the eepromex template for storing multibyte values like .write(address, float) not produce compiler warnings about volatile variables?

I would recommend that you continue to use eeprom.h and use transfer variables to deal with the compiler issues.

I do not think the the syntax for an if conditional with multiple comma separated statements on one line will work as you intend.

if (buttonState2 == LOW && (millis() - lastDebounceTime) > 3000 && displaychange == true) // below are the long press functions for button 2
{
      if (menunumber == 0) menunumber = 11, counter = millis(), counter2 = millis(), displaychange = false, digitLLG = 1; //goes to the "LLG Coef." menu
      if (menunumber == 1) traveled_distance2 = 0, used_LLG2 = 0, avg_LLG_consumption = 0, used_Unleaded2 = 0;// average LLG consumption and average Unleaeded cons. reset
      if (menunumber == 3) traveled_distance3 = 0, seconds_passed = 0, avg_speed = 0; // average speed reset

Did you write this program. How does it function? Your original question was about erasing the eeprom. What problem were you trying to solve?