#include <Arduino.h>
#include "ConfigurationStore.h"
#include "Temperature.h"

#ifdef ENABLE_SERIAL
  #include "Serial.h"
#endif

#ifdef ENABLE_LCD
  #include "LCD.h"
#endif

unsigned long tempStartTime;
      
void setup() {
  readEEPROMSetting(true); //if no EEPROM settings, use factory (hardcoded in Configurations.h)
  
  initHeater();
  
  #ifdef ENABLE_SERIAL
    initSerial();
  #endif

  #ifdef ENABLE_LCD
    initLCD();
  #endif
}

void loop() {
  unsigned long now = millis();
  if(now - tempStartTime>100UL) {
    tempStartTime = now;
    updateTemp();
    updatePID();
  }
  
  manageHeaterSoftPWM();
  
  #ifdef ENABLE_SERIAL
    parseSerial();
  #endif

  #ifdef ENABLE_LCD
    updateLCD();
  #endif
}
