From: andreaskoepke Date: Thu, 14 Aug 2008 13:14:09 +0000 (+0000) Subject: improve computation of mean X-Git-Tag: rc_6_tinyos_2_1_1~656 X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=commitdiff_plain;ds=sidebyside;h=590009b1e92cd2324b391e8e5397f605c8a7026b;p=tinyos-2.x.git improve computation of mean --- diff --git a/tos/platforms/eyesIFX/byte_radio/RssiFixedThresholdCMP.nc b/tos/platforms/eyesIFX/byte_radio/RssiFixedThresholdCMP.nc index b1fd2097..cf9d4ad1 100644 --- a/tos/platforms/eyesIFX/byte_radio/RssiFixedThresholdCMP.nc +++ b/tos/platforms/eyesIFX/byte_radio/RssiFixedThresholdCMP.nc @@ -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; } }