 
 void pinValT2()
 {
+  T2.previousFlowing = T2.flowing;
   if(digitalRead(T2.flowPin) == HIGH)
   {
     if(flowTapPin2Value == 0)

      if(T1.previousPulseCount != T1.pulseCount)
      {
        T1.flowing = 1;
        Particle.publish("start-flow-T1", String(T1.maxPulseCount) + "," + String(T1.pulseCount) + "," + String(T1.percentFull));
      }
      else
      {
        T1.flowing = 0;
        // Particle.publish("stop-flow-T1", String(T1.maxPulseCount) + "," + String(T1.pulseCount) + "," + String(T1.percentFull));
      }
      T1.previousPulseCount = T1.pulseCount;
      T1.previousSecond = T1.currentSecond;

  {
    if(T2.pulseCount > T2.maxPulseCount)
      T2.pulseCount = T2.maxPulseCount;
    recalculateTapColor(2);
  }
}

void publishFlowingEvents()
{
  if(T0.flowing != T0.previousFlowing)
  {
    if(T0.flowing)
    {
      //publish a start event
      Particle.publish("start-flow-T0", String(T0.maxPulseCount) + 
                       "," + String(T0.pulseCount) + "," + String(T0.percentFull));
    }
    else
    {
      //publish a stop event
      Particle.publish("stop-flow-T0", String(T0.maxPulseCount) + 
                       "," + String(T0.pulseCount) + "," + String(T0.percentFull));
    }
  }

  if(T1.flowing != T1.previousFlowing)
  {
    if(T1.flowing)
    {
      //publish a start event
      Particle.publish("start-flow-T1", String(T1.maxPulseCount) + 
                       "," + String(T1.pulseCount) + "," + String(T1.percentFull));
    }
    else
    {
      //publish a stop event
      Particle.publish("stop-flow-T1", String(T1.maxPulseCount) + 
                       "," + String(T1.pulseCount) + "," + String(T1.percentFull));
    }
  }

  if(T2.flowing != T2.previousFlowing)
  {
    if(T2.flowing)
    {
      //publish a start event
      Particle.publish("start-flow-T2", String(T2.maxPulseCount) + 
                       "," + String(T2.pulseCount) + "," + String(T2.percentFull));
    }
    else
    {
      //publish a stop event
      Particle.publish("stop-flow-T2", String(T2.maxPulseCount) + 
                       "," + String(T2.pulseCount) + "," + String(T2.percentFull));
    }
  }
}

int resetPulseCount(int tap)
{
  if(tap == 0)
  {
    T0.pulseCount = T0.maxPulseCount;
  }
  else if(tap == 1)
  {
    T1.pulseCount = T1.maxPulseCount;
  }
  else if(tap == 2)
  {
    T2.pulseCount = T2.maxPulseCount;
  }
  writeToEEPROM();
  return 1;
}

