X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fplatforms%2Ftmirws%2Fsensors%2FAeroVaneReadP.nc;h=c620006e693ccc1dbd0f114e44c6879f8c1c60f9;hb=0f58276b9e5d322d87624bd7c11ff7eb5c2c8b57;hp=56001dde33f9c5d7a7bda956c1d2091baba2933d;hpb=7373db28ff8b66edda83925025fbffea6ed88148;p=tinyos-2.x.git diff --git a/tos/platforms/tmirws/sensors/AeroVaneReadP.nc b/tos/platforms/tmirws/sensors/AeroVaneReadP.nc index 56001dde..c620006e 100644 --- a/tos/platforms/tmirws/sensors/AeroVaneReadP.nc +++ b/tos/platforms/tmirws/sensors/AeroVaneReadP.nc @@ -39,11 +39,7 @@ generic module AeroVaneReadP(uint16_t period) { provides interface Notify; uses { -#if 0 - interface Alarm; -#else interface Timer; -#endif interface Read; interface StdControl as AnemometerControl; interface AsyncGet as Count; @@ -62,8 +58,6 @@ implementation { int m_vane; int m_sum; - task void readVane(); - void init() { m_count = 0; @@ -78,40 +72,21 @@ implementation { init(); call AnemometerControl.start(); - /* FIXME: First alarm should be synced to top of the next second. How? */ -#if 0 - call Alarm.start(call Alarm.getNow() + period); -#else + /* FIXME: How to get first Timer.fired() synced with top of hour? */ call Timer.startPeriodic(period); -#endif return SUCCESS; } command error_t Notify.disable() { call State.toIdle(); -#if 0 - call Alarm.stop(); -#else call Timer.stop(); -#endif call AnemometerControl.stop(); return SUCCESS; } -#if 0 - async event void Alarm.fired() -#else event void Timer.fired() -#endif - { - //call Alarm.start(call Alarm.getAlarm() + period); - post readVane(); - } - - task void readVane() { - //call Alarm.start(call Alarm.getAlarm() + period); if (!(call State.isIdle())) call Read.read(); } @@ -141,7 +116,8 @@ implementation { norace aerovector_t vector; /* Get speed average */ - atomic vector.speed = call Count.get(); + atomic vector.speed = (call Count.get() * 2.25) / (period * 4 / 1024) + + 0.5; /* Complete direction average */ vector.dir = m_sum / PHYS_PER_READ;