           }
         }
 
-        snprintf(message, sizeof(message), "level:%d", cm);
+#if SUBMIT_TO_ST
+#if DEBUG_ENABLED
+        Serial.print("Update ST...");
+#endif
+        
+        snprintf(message, sizeof(message), "level:%d", (int)cm);
         smartthing.send(message);
-
-        measurements.invalidate();
+#endif        
       }        
     }
     


    if (measurements.valid()) 
    {
      int cm = round((float)measurements.average() / US_ROUNDTRIP_CM);
      
#ifdef DEBUG_RAW_ENABLED
      Serial.print("Raw: ");
      Serial.print((float)measurements.average() / US_ROUNDTRIP_CM);
      Serial.print("  ::  ");
      for (int i = 0; i < measurements.size(); ++i) 
      {
        Serial.print(measurements._sorted[i]);
        Serial.print(" ");
      }
      Serial.println("");
#endif  

      if (abs(lastDistance - cm) > 1) {
        lastDistance = cm;

#ifdef DEBUG_ENABLED       
        Serial.print("Ping: ");
        Serial.print(cm);
        Serial.println("cm");
#endif        

        if (settings.floorLevel > 0 && settings.safeDepth > 0) {
          int depth = settings.floorLevel - cm;

          if (depth <= settings.warnDepth) {
            smartthing.shieldSetLED(0, 4, 0);

public:
  int _size;
  int _v[T];
  int _average;

public:
  Queue() 
  {
    _size = 0;
    _average = 0;
    
    memset(&_v, 0, sizeof(_v));
  }

  inline int size() 
  {
    return _size;  
  }

  inline void invalidate()
  {
    _size = 0;
  }

  inline bool valid() 
  {
    return size() == T;
  }
