]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
improve computation of mean
authorandreaskoepke <andreaskoepke>
Thu, 14 Aug 2008 13:14:09 +0000 (13:14 +0000)
committerandreaskoepke <andreaskoepke>
Thu, 14 Aug 2008 13:14:09 +0000 (13:14 +0000)
tos/platforms/eyesIFX/byte_radio/RssiFixedThresholdCMP.nc

index b1fd2097f10330fa7a4d2407c78ce2ed24fd1710..cf9d4ad11683c336e00924f6c19f9788d972bc67 100644 (file)
@@ -286,7 +286,7 @@ implementation
     task void UpdateNoiseFloorTask() {
         shellsort(rssisamples,NSAMPLES);
         atomic { 
-            noisefloor = (5*noisefloor + rssisamples[NSAMPLES/2])/6;
+            noisefloor = (5*noisefloor + rssisamples[NSAMPLES/2] + 3)/6;
             rssiindex = 0; 
         }
         sdDebug(60000U + noisefloor);
@@ -318,7 +318,7 @@ implementation
             } else { 
                 shellsort(rssisamples,NSAMPLES);
                 if(rssisamples[MINIMUM_POSITION] < noisefloor + THREE_SIGMA)  {
-                    noisefloor = (7*noisefloor + rssisamples[NSAMPLES/2])/8;
+                    noisefloor = (7*noisefloor + rssisamples[NSAMPLES/2] + 4)/8;
                     ++deadlockCounter;
                 }
                 else {
@@ -411,6 +411,6 @@ implementation
     async command uint16_t BatteryLevel.getLevel() {
         uint16_t l;
         atomic l = batteryLevel;
-        return (uint32_t)l*39>>5;
+        return (uint32_t)(l+3)*6/5;
     }
 }