HOme Sheriff And Lamp
Dependencies: CameraC328 HCSR04 SDFileSystem WIZnetInterface mbed
Fork of HoSAL by
Diff: rev_Hcsr04.cpp
- Revision:
- 2:3c7526a1893a
- Parent:
- 0:35211a622a44
- Child:
- 8:28f7b30c1ae4
--- a/rev_Hcsr04.cpp Tue Aug 11 16:07:05 2015 +0000
+++ b/rev_Hcsr04.cpp Tue Aug 11 16:30:37 2015 +0000
@@ -17,20 +17,18 @@
#include "rev_Hcsr04.h"
-//HCSR04 sensor(D12, D11);
-extern HCSR04 sensor;
-
-int sum_dist[3];
-int avg_dist = 0;
-int index_dist = 0;
-long distance_cm = 0; //ryuhs74@20150810 - Add
#if defined(USE_MEASURE_DISTANCE)
-int get_distance(void)
+long avg_dist = 0;
+long distance_cm = 0; //ryuhs74@20150810 - Add
+uint8_t index_dist = 0;
+long sum_dist[3];
+
+int get_distance(HCSR04 *pH)
{
-
+
while (true) {
- distance_cm = sensor.distance(); //ryuhs74@20150810 - cm 단위 측정 거리 return
+ distance_cm = pH->distance(); //ryuhs74@20150810 - cm 단위 측정 거리 return
if( index_dist < 3){ //ryuhs74@20150810
sum_dist[index_dist] = distance_cm;
DM_fLN("sum_dist[%d] = %d", index_dist, sum_dist[index_dist]);
@@ -44,6 +42,7 @@
}
avg_dist /= 3;
+ DM_fLN("avg: %d", avg_dist);
return avg_dist;
}
#if 0
