1 sensor using RTOS Timer, another 2 over RTOS Semaphore

Dependents:   Autonomous_quadcopter

Fork of HCSR04 by Antoniolinux B.

Revision:
4:34023f76fc4f
Parent:
3:81512ca9a13c
--- a/hcsr04.cpp	Sat Jan 20 11:44:21 2018 +0000
+++ b/hcsr04.cpp	Sun Jan 21 17:56:47 2018 +0000
@@ -1,13 +1,17 @@
 #include "hcsr04.h"
+#include "definitions.h"
 #include "mbed.h"
 #include "rtos.h"
+
+
 /*
 *HCSR04.cpp
 */
 HCSR04::HCSR04(PinName t, PinName e) : trig(t), echo(e) {
     //thread = new Thread(threadWorker, this);
     threadUpdateTimer = new RtosTimer(threadWorker, osTimerPeriodic, this);
-    threadUpdateTimer->start(5);
+    int rate = (1.0 / FLIGHT_CONTROLLER_FREQUENCY) * 1000;
+    threadUpdateTimer->start(rate);
 }
 
 void HCSR04::threadWorker(void const *p)