 // #include "neopixel/neopixel.h"
 #include "neopixel.h"
 
-#define EEPROM_ADDR_T0 0
-#define EEPROM_ADDR_T1 20
-#define EEPROM_ADDR_T2 40
+//photon has 2048 bytes of emulated EEPROM
+#define EEPROM_ADDR_T0 0 //400 bytes per tap
+#define EEPROM_ADDR_T1 400
+#define EEPROM_ADDR_T2 800
 
 #define PIXEL_TYPE WS2812B
 #define PIXEL_COUNT 14

  T0.percentFull = (int)(percentT0 * 100.0f);
  if(T0.percentFull > 100)
    T0.percentFull = 100;
  // EEPROM.update(EEPROM_ADDR_PERCENT_FULL, percentFull);

  float percentT1 = (float)T1.pulseCount / (float)T1.maxPulseCount;
  T1.percentFull = (int)(percentT1 * 100.0f);
  if(T1.percentFull > 100)
    T1.percentFull = 100;
  // EEPROM.update(EEPROM_ADDR_PERCENT_FULL, percentFull);  

  float percentT2 = (float)T2.pulseCount / (float)T2.maxPulseCount;
  T2.percentFull = (int)(percentT2 * 100.0f);
  if(T2.percentFull > 100)
    T2.percentFull = 100;
  // EEPROM.update(EEPROM_ADDR_PERCENT_FULL, percentFull);

  Serial.println("flowingT0: " + String(T0.flowing));
  Serial.println("flowingT1: " + String(T1.flowing));

  {
    if(T2.pulseCount > T2.maxPulseCount)
      T2.pulseCount = T2.maxPulseCount;
    EEPROM.put(EEPROM_ADDR_T1, T1);
    recalculateTapColor(2);
  }
}

int resetPulseCount(int tap)
{
  if(tap == 0)
  {
    T0.pulseCount = T0.maxPulseCount;
    EEPROM.put(EEPROM_ADDR_T0, T0);
  }
  else if(tap == 1)
  {
    T1.pulseCount = T1.maxPulseCount;
    EEPROM.put(EEPROM_ADDR_T1, T1);
  }
  else if(tap == 2)
  {
    T2.pulseCount = T2.maxPulseCount;
    EEPROM.put(EEPROM_ADDR_T2, T2); 
  }
  
  return 1;
}

int setCalibration(int tap, int val)
{
  if(tap == 0)
  {
    T0.maxPulseCount = val;
    EEPROM.put(EEPROM_ADDR_T0, T0);
  }
  else if(tap == 1)
  {
    T1.maxPulseCount = val;
    EEPROM.put(EEPROM_ADDR_T1, T1);
  }
  else if(tap == 2)
  {
    T2.maxPulseCount = val;
    EEPROM.put(EEPROM_ADDR_T2, T2);
  }
  return 1;
}

