#include <Wire.h>
#include "storage.h"
#include "elaps.h"
#include "display.h"
#include "alert.h"
#include "batt.h"
#include "rpm.h"
#include "kph.h"
#include "gauges.h"
bool systemChecked = false;
unsigned long timerCheck = 0;
void setup()
{
Serial.begin(115200);
initElaps();
initDisplay();
initAlert();
initGauges();
initBatt();
timerCheck = millis() + 3700;
Eeprom.readChars(0, (char*)(&Storage), sizeof(Storage));
/* DATA TEMPLATE */
Storage.elaps.timeAwake = 0;
Storage.elaps.Odometer = 0;
Storage.elaps.distancePointA = 0;
Storage.elaps.distancePointB = 0;
Storage.elaps.lifeOil = 5000;
Storage.elaps.fullFuelTank = 48;
delay(700);
}
void loop()
{
if (!systemChecked) {
checkAlert(); // verificar testigos
checkGauges(); // verificar relojes
systemChecked = millis() >= timerCheck;
if (systemChecked) { // iniciar interrupciones
initControllerRPM();
initControllerKPH();
}
} else {
WatchElaps();
WatchBatt(); //vigilar voltaje
WatchRPM(); //vigilar rpm
WatchKPH(); //vigilar kph
WatchAlert(); //vigilar alertas
gaugeRPM(v_RPM);
gaugeKPH(v_KPH);
}
}