wu

Dependencies:   mbed-rtos mbed

Fork of Boboobooov4 by kao yi

Revision:
12:fdada4af384a
Parent:
11:418e39749f48
Child:
13:63f9a5101205
--- a/main.cpp	Sat Jun 28 05:43:23 2014 +0000
+++ b/main.cpp	Sat Jun 28 06:33:28 2014 +0000
@@ -19,8 +19,7 @@
 
 
 
-
-
+ Serial pc(USBTX, USBRX); // tx, rx
 
 
 
@@ -69,12 +68,12 @@
         
         if(l3_p==0){
         
-            line3[l3_p]=(double)cam.black_centerR();
+            line3[l3_p]=(double)cam.black_centerL();
         }else if(l3_p==1){
             line3[l3_p]=0;
             
         }else {
-           line3[l3_p]=(double)cam.black_centerL();    
+           line3[l3_p]=(double)cam.black_centerR();    
                
         }        
                
@@ -93,58 +92,40 @@
     while(1){
         
         
-          cam.read();
-        
-        b_l_c=(double)cam.black_centerL();
-        
-        if(l3_p==0){
-        
-            line3[l3_p]=(double)cam.black_centerR();
-        }else if(l3_p==1){
-            line3[l3_p]=0;
-            
-        }else {
-           line3[l3_p]=(double)cam.black_centerL();    
-               
-        }        
-               
-        l3_p++;
-        if(l3_p==3)
-            l3_p=0;
         
         
     stdio_mutex.lock();    
     #ifdef Debug_cam_uart 
       #ifdef L_eye  
-        printf("L: ");
+        pc.printf("L: ");
         for(int i=0;i<128;i++){
              if(i==64)
-               printf("X");
+               pc.printf("X");
              else if(i<10)
-               printf("-");
+               pc.printf("-");
              else if(i>117)
-              printf("-");  
+               pc.printf("-");  
                
              else          
-               printf("%c", cam.sign_line_imageL[i]);
+               pc.printf("%c", cam.sign_line_imageL[i]);
          }
-         printf("           ||             ");
+         pc.printf("           ||             ");
       #endif
       #ifdef R_eye
-        printf("R: ");
+        pc.printf("R: ");
         for(int i=128;i>=0;i--){
              if(i==64)
-               printf("X");
+               pc.printf("X");
              else if(i<10)
-               printf("-");
+               pc.printf("-");
              else if(i>117)
-               printf("-");
+               pc.printf("-");
              else          
-               printf("%c", cam.sign_line_imageR[i]);         
+               pc.printf("%c", cam.sign_line_imageR[i]);         
          }
-         printf("\r\n");
+         pc.printf("\r\n");
      #endif
-         printf("L: %d  mid: %d R: %d\r\n",line3[0],line3[1],line3[2]);
+         pc.printf("L: %d  mid: %d R: %d\r\n",line3[0],line3[1],line3[2]);
          stdio_mutex.unlock();
      
          
@@ -229,8 +210,8 @@
 int main() {
     
 // baud rate init --- no function
-     
-    
+  
+    pc.baud(115200);
    /*
       while(1){
          
@@ -238,7 +219,7 @@
              break;
       }
     */
-    //  Thread th_c(cam_thread);
+      Thread th_c(cam_thread);
    //   Thread thread(ctrl_thread);  
    //   Thread thread(servo_thread);  
    //   Thread thread(motor_thread);     
@@ -247,11 +228,11 @@
          
            
      //idle
-     //stdio_mutex.lock();
-     //   printf("L: %d  mid: %d R: %d\r\n",line3[0],line3[1],line3[2]);
+  //   stdio_mutex.lock();
+    //    printf("L: %d  mid: %d R: %d\r\n",line3[0],line3[1],line3[2]);
     // stdio_mutex.unlock();     
           Thread::wait(2000);
-     
+    
      }