program_SensorBlock //{Ping,Ir,Lines,compass} Sensor

Dependencies:   HMC6352 mbed

Fork of program_BlockPIL by Fumiya Fujisawa

Files at this revision

API Documentation at this revision

Comitter:
ryuna
Date:
Tue Feb 25 08:18:22 2014 +0000
Parent:
5:3457e0e66104
Commit message:
sensors version.4

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Feb 25 02:29:32 2014 +0000
+++ b/main.cpp	Tue Feb 25 08:18:22 2014 +0000
@@ -1,7 +1,7 @@
 #include "mbed.h"
 #include "HMC6352.h"
 /*PING DEFINE */
-#define ERROR_PING 0xFFF
+#define ERROR_PING 0xFF
 #define ALL_PING 4
 /*IR DEFINE*/
 #define BREAKPT_IR 833
@@ -9,7 +9,7 @@
 #define ALL_IR 10
 //#define OVERLINE_IR 46
 /*LINE DEFINE*/
-#define JUDGEVOL_LINE 0.9
+#define JUDGEVOL_LINE 0.8
 #define ALL_LINE 4
 //OTHERS
 #define ALL_KIND 3 //kind of sensors
@@ -99,12 +99,13 @@
     }
     time_ping.reset();
     while(sensor_ping){
-        if(time_ping.read_ms() >18.5){
+        if(time_ping.read_ms() >18.5){//18.5
             time_ping.stop();
             return ERROR_PING;
         }
     }
     memory = time_ping.read_us();
+    memory >>= 6;
     time_ping.stop();
     
     return memory;
@@ -190,23 +191,24 @@
             value_compass[1] = 0;
         }
         moving_ave(Ping,num[Ping],ping_function(num[Ping]));
-        pc.printf("compass0=%d compass[0]= %d  compass[1]= %d\n",value_compass0,value_compass[0],value_compass[1]);
-        //ir_min_fun();
-        //num[Ping]++;
-        //num[Ir]++;
-        //num[Line]++;        
+        moving_ave(Line,num[Line],line_function(num[Line]));
+        moving_ave(Ir,num[Ir],ir_function(num[Ir]));
+        ir_min_fun();
+        //pc.printf("%d,%d\n",value_ir_min,ir_min_num);
+        num[Ping]++;
+        num[Ir]++;
+        num[Line]++;        
         if(num[Ping]>= ALL_PING){
             num[Ping] = 0; 
-            putchar('\n');
+            //putchar('\n');
         }
         if(num[Ir]>= ALL_IR){
             num[Ir] = 0;
-            putchar('\n');
-            pc.printf("min=%d ,num = %d\n",value_ir_min,ir_min_num);
+            //putchar('\n');
         }
         if(num[Line]>= ALL_LINE){
             num[Line] = 0;
-            putchar('\n');
+            //putchar('\n');
         }
         
     }