fatboyslim / Mbed 2 deprecated bouncesinglecam

Dependencies:   FRDM-TFC mbed

Revision:
15:60d699b587c5
Parent:
14:1a408e13679d
Child:
16:25eb20a73e59
--- a/main.cpp	Thu Mar 26 20:18:04 2015 +0000
+++ b/main.cpp	Thu Mar 26 20:23:16 2015 +0000
@@ -179,15 +179,15 @@
                     
                     uint8_t num = 0;
                     
-                    if(center_now > 10 && center_now < 27)
+                    if(center_now > 10 && center_now < 45) // linear func
                         num = 1;
-                    else if(center_now >= 27 && center_now < 63)
+                    else if(center_now >= 45 && center_now < 63) // snap
                         num = 2;
-                    else if(center_now > 63 && center_now < 65)
+                    else if(center_now > 63 && center_now < 65) // nothing zone
                         num = 15;
-                    else if(center_now >= 65 && center_now < 81)
+                    else if(center_now >= 65 && center_now < 83) // snap
                         num = 4;
-                    else if(center_now >= 81 && center_now < 118)
+                    else if(center_now >= 83 && center_now < 118) // linear func
                         num = 8;
                     
                     else
@@ -205,32 +205,19 @@
                     
                     // turn left
                     // hit wall a little bit on the right
-                    //if (num==8 and right_counter <.2 ) // only if we arent turning right
-                    if(center_now >= 110 && center_now < 118 and right_counter <.2)
+                    if (num==8 and right_counter <.2 ) // only if we arent turning right
+                    //if(center_now >= 110 && center_now < 118 and right_counter <.2)
                     {
                         //turn away a little bit for each frame that is wall
                         if (left_counter >-.45)
                             //left_counter -=.05;    
-                            left_counter -=.03; 
+                            //left_counter -=.03; 
+                            left_counter -= (.001428571*center_now);
                             
                         turn_left=true;
                         turn_right=false;
                     }
                     
-                    // turn left
-                    // hit wall a little bit on the right
-                    if(center_now >= 81 && center_now < 110 and right_counter <.2)
-                    {
-                        //turn away a little bit for each frame that is wall
-                        if (left_counter >-.45)
-                            left_counter -=.05;    
-                            //left_counter -=.03; 
-                            
-                        turn_left=true;
-                        turn_right=false;
-                    }
-                    
-                    
                     // turn left real hard
                     // wall is close to center on right
                     if (num==4 and right_counter <.2) // only if we arent turning right
@@ -254,30 +241,20 @@
                     
                     // turn right
                     // hit wall a little bit on the left
-                    //else if (num==1 and left_counter >-.2) // only if we arent turning left
-                    else if ( center_now > 15 && center_now < 27 and left_counter >-.2) // only if we arent turning left
+                    else if (num==1 and left_counter >-.2) // only if we arent turning left
+                    //else if ( center_now > 15 && center_now < 27 and left_counter >-.2) // only if we arent turning left
                     {    
                         //turn away a little bit for each frame that is wall
                         if (right_counter <.45)
-                            right_counter +=.05;
+                            //right_counter +=.05;
                             //right_counter +=.03;
+                            right_counter +=(.001428571*center_now);
               
                         turn_left=false;
                         turn_right=true;
                     }
                     
-                    // turn right
-                    // hit wall a little bit on the left
-                    else if ( center_now > 10 && center_now < 15 and left_counter >-.2) // only if we arent turning left
-                    {    
-                        //turn away a little bit for each frame that is wall
-                        if (right_counter <.45)
-                            //right_counter +=.05;
-                            right_counter +=.03;
-              
-                        turn_left=false;
-                        turn_right=true;
-                    }
+                    
 
 
                    // going straight yesssss