 
 }
 
+/**
+Prints out and clears the EEPROM of all existing trips.
+**/
 void recoverTrips()
 {
-  while(loadTrip())
-  {
-     reportValues(); 
+  pinMode(REPORT_ALL_PIN, INPUT);           // set pin to input
+  if(digitalRead(REPORT_ALL_PIN) == LOW)
+  {
+    Serial.print("Attach pin ");
+    Serial.print(REPORT_ALL_PIN);
+    Serial.println(" to 3V3 to print results");
+  }
+  else
+  {
+    while(loadTrip())
+    {
+       reportValues(); 
+    } 
   }
 }
 

void reportValues()
{
  Serial.println("============================================================");
  report("Speed < 30 Seconds", trip.speedBucket[0]); 
  report("Speed 30-45 Seconds", trip.speedBucket[1]); 
  report("Speed 45-55 Seconds", trip.speedBucket[2]); 
  report("Speed 55+ Seconds", trip.speedBucket[3]); 
  report("#Stops", trip.stopCount);
  report("Time (s)", trip.tripTime);
  report("Miles", trip.totalMileage);
  report("Seconds > 80mph", trip.over80Seconds);
  report("# Hard Brakes", trip.hardBrakeCount);
  report("# Hard Accel", trip.hardAccelCount);  
}


  int hardAccelCount;
};


// CONSTANTS

const float MAX_SAFE_DECEL_MPH = 3.5;
const float MAX_SAFE_ACCEL_MPH = 3.5;
const int SECONDS_BETWEEN_READS = 1;
const int REPORT_ALL_PIN = 13;
const float KPH_TO_MPH = 0.621371;
const int DISPLAY_REFRESH_TIME = 5; // the number of SECONDS_BETWEEN_READS intervals to wait for a display update


// VARIABLES

int lastVelocity;
int lastTime;
Trip trip;

#ifdef VELOCITY_OBDII
COBD obd; // uart obd2 connector
#endif

#ifdef USELCD
LCD_SSD1306 lcd; // SSD1306 OLED module
#endif




void setup() {
  // INIT all variables
  lastVelocity = 0.0;
  lastTime = 0;
  clearTrip();


  //Initialize serial and wait for port to open:
  Serial.begin(9600); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

#ifdef VELOCITY_OBDII
  // start communication with OBD-II UART adapter
  obd.begin();
  while (!obd.init()){
    ; // initiate OBD-II connection until success
  }
#endif


#ifdef USELCD
  lcd.begin();
  lcd.setFont(FONT_SIZE_SMALL);
#endif


  // print out the trips to serial if needed.
  recoverTrips();


}
