 */
 
 #include <math.h>
+#include <EEPROM.h>
 #include <LiquidCrystal.h>
 #include <Wire.h>
 #include <Adafruit_MMA8451.h>

const double WHEEL_CIRCUMFERENCE = 2 * WHEEL_RADIUS * PI;
double kph = 0.0;
double mph = 0.0;

// Hall effect sensor read pin, make it an interrupt pin so we catch all revolutions
const byte HALL_SENSOR = 2;

  if (isnan(cmps)) {
    cmps = 0.0; 
  }
  double k = cmps/10000.0 * 360.0;
  if (k > maxRecordKph) {
    noInterrupts();
    maxRecordKph = k;
    lcd.print("New Max!");
    lcd.setCursor(0,1);
    lcd.print(k);
    lcd.print("kph");
    setMaxSpeed(k);
    interrupts();
    delay(1000);
  }
  return k;
}

double calculateMPH() {
   return kphToMph(kph);
}

double kphToMph(double k) {
  return k * 1.6093;
};

void setMaxSpeed(double k) {
  EEPROM.put(MAX_RECORD_KPH_ADDRESS, k); 
}
