7Robot_Freescale / Mbed 2 deprecated freescal_cup_k22f

Dependencies:   mbed freescal_cup_k22f

Dependents:   freescal_cup_k22f

Revision:
26:a836e62e0c98
Parent:
25:f9d3d30cbb5d
Child:
27:d1da489fc79a
--- a/source/main.cpp	Wed Jan 21 10:30:39 2015 +0000
+++ b/source/main.cpp	Wed Jan 21 16:54:53 2015 +0000
@@ -12,107 +12,50 @@
 
 Serial uart(PTD3, PTD2); //xbee
 //Serial uart(USBTX, USBRX); //port série usb ACM0
-Servo servo(PTD0);
+
 AnalogIn pot1(PTC1);
 
 int main() {
  // Initialisation
  
-    int indexMin=10; 
-    int indexMax=118;
+
     int compteur_uart=0;
-    int max_detect1=indexMin;
-    int min_detect2=indexMin;
-    int max_detect=(max_detect1+min_detect2)/2;
-    float Kp_servo = 0;
+    int indice_pixel;
+    //float Kp_servo = 0;
     uart.baud(115200); 
     init_led();
+    init_camera();
    
     // Init UART baudrate
 
          
     // Lancement boucle
     while(1){
-        double ordre;
-        readline();
-        passebas(10);
-        derivation();
-        //passebas(4); 
-        for (int i=0;i<15;i++)
-        {
-            pixel1[i]=0;
-            pixel2[i]=0;
-            pixel1[127-i]=0;
-            pixel2[127-i]=0;
-        } 
-        if (compteur_uart ==2) // on envoit une trame toute les 50 acquisitions de cameras
-        {  
-            uart.printf("S1");//debug START
-            for (int indice_pixel=0; indice_pixel<128; indice_pixel++)   
-            {
-                uart.printf("%d,",pixel1[indice_pixel]);
+        
+        if (flag_new_image==1){
+          /*  if (compteur_uart ==15) // on envoit une trame toute les 50 acquisitions de cameras
+            {  
+                uart.printf("S1");//debug START
+                for (indice_pixel=0; indice_pixel<128; indice_pixel++)   
+                {
+                    uart.printf("%d,",pixel1[indice_pixel]);
+                }
+                uart.printf("E");//debug END
+                
+                uart.printf("S2");//debug START
+                for (indice_pixel=0; indice_pixel<128; indice_pixel++)   
+                {
+                    uart.printf("%d,",pixel2[indice_pixel]);
+                }
+                uart.printf("E");//debug END
+                compteur_uart =0;
             }
-            uart.printf("E");//debug END
-            
-            uart.printf("S2");//debug START
-            for (int indice_pixel=0; indice_pixel<128; indice_pixel++)   
-            {
-                uart.printf("%d,",pixel2[indice_pixel]);
-            }
-            uart.printf("E");//debug END
-            compteur_uart =0;
-        }
-        else {
-        compteur_uart =compteur_uart+1;  
+            else {
+                compteur_uart =compteur_uart+1;  
+            }*/
+            uart.printf("0,%d,%d\n\r",max_detect1,max_detect2);
+            flag_new_image=0;
         }
-        
-        max_detect1=indexMin;
-        min_detect2=indexMin;
-        
-        for (int j=indexMin; j<=indexMax; j++)
-        {
-            if (pixel1[j]>pixel1[max_detect1])
-            {
-                max_detect1=j;
-            }
-        }  
-        for (int j=indexMin; j<=indexMax; j++)
-        {      
-            if (pixel2[j]>pixel2[min_detect2])
-            {
-                min_detect2=j;
-            }    
-        }  
-        max_detect=(max_detect1+min_detect2)/2; 
-        // Réduction proportionelle de la vitesse moteur si l'angle du servo augmente
-        if (max_detect>64)
-        {
-            consigne_moteur_1=6*(1-(max_detect-64)/150.);
-            consigne_moteur_2=6*(1-(max_detect-64)/100.);
-        }
-        else
-        {
-            consigne_moteur_1=6*(1-(64-max_detect)/100.);
-            consigne_moteur_2=6*(1-(64-max_detect)/150.); 
-        }
-        // Lecture du potentiometre
-        Kp_servo=2.0*pot1.read();
-        ordre=(/*consigne*/0-((127-max_detect1)-min_detect2));//ya une merde ici
-
-     
-        ordre=ordre/254+0.5;
-        
-        if (ordre >=0.88)
-            servo=0.88;
-        else if (ordre <=0.22)
-            servo=0.22;
-        else
-            servo= ordre; 
-        
-        uart.printf("a=%d, b=%d \n\r",max_detect1,min_detect2);
-        
-
-      
     }
 }