PIDs and fun

Dependencies:   btbee m3pi_ng mbed FatFileSystemCpp

Revision:
7:74c9a0fbf2b1
Parent:
6:75a6f6b50188
Child:
8:e7b322f72d16
diff -r 75a6f6b50188 -r 74c9a0fbf2b1 main.cpp
--- a/main.cpp	Thu May 28 11:01:48 2015 +0000
+++ b/main.cpp	Thu May 28 12:51:37 2015 +0000
@@ -154,138 +154,138 @@
     s1 = LapTest[0];
     s5 = LapTest[4];
     
-    if (s1 > 500 and s5 > 500) {
-        checkvar = 1;
-        }
-        
-    if (s1 < 500 and s5 < 500 and checkvar == 1 and counter == -1) {
-        LapTimer.reset();
-        LapTimer.start();
-        }
-        
-    if (s1 < 500 and s5 < 500 and checkvar == 1) {
-        counter = counter + 1;
-        m3pi.cls();
-        m3pi.printf("%d", counter);
-        checkvar = 0;
-        switch (counter) {
-            case 1: {
-                Time1 = LapTimer.read();
-                LapTimer.reset();
-                LapTimer.start();
-                btbee.printf("Lap 1: %f \n", Time1);
-                break;
-                }
-            case 2: {
-                Time2 = LapTimer.read();
-                LapTimer.reset();
-                LapTimer.start();
-                btbee.printf("Lap 2: %f \n", Time2);
-                break;
-                }
-            case 3: {
-                Time3 = LapTimer.read();
-                LapTimer.reset();
-                LapTimer.start();
-                btbee.printf("Lap 3: %f \n", Time3);
-                break;
-                }
-            case 4: {
-                Time4 = LapTimer.read();
-                LapTimer.reset();
-                LapTimer.start();
-                btbee.printf("Lap 4: %f \n", Time4);
-                break;
-                }
-            case 5: {
-                Time5 = LapTimer.read();
-                LapTimer.reset();
-                LapTimer.start();
-                btbee.printf("Lap 5: %f \n", Time5);
-                break;
-                }
-            }
-                
-        
-        }
-        
-    if (counter == 5) {
-        m3pi.stop();
-        m3pi.cls();
-        m3pi.locate(0,0);
-        m3pi.printf("Ave time");
-        TimeAve = (Time1 + Time2 + Time3 + Time4 + Time5)/5.0;
-        m3pi.locate(0,1);
-        m3pi.printf("%f", TimeAve);
-        btbee.printf("Average time per lap: %f \n", TimeAve);
-        btbee.printf("\n");
-        btbee.printf("Enter P value, I value, and D value separately \n");
-                
-                while(1) {
-                    
-                        
-                        if (btbee.readable()) {
-                            
-                          btbee.printf("Enter P valure: \n");
-            
-            
-                          btbee.read_all(arr_read, 30, &chars_read);
-                           P_TERM = atof(arr_read);
-            
-                          btbee.printf("P term is %f \n", P_TERM);
-            
-                          wait(1.0);
-            
-            break;
-            
-                                             }
-            
-                          }
-            
-            while(1) {
-                            
-            if(btbee.readable()) {
-                
-                btbee.printf("Enter I value: \n");
-            
-                btbee.read_all(arr_read, 30, &chars_read);
-                I_TERM = atof(arr_read);
-            
-                btbee.printf("I term is %f \n", I_TERM);
-            
-                 wait(1.0);
-            
-                 break;
-            
-                                    }
-                                    
-                        }
-                        
-            while(1)  {
-                
-                if(btbee.readable()) {
-                    
-                    btbee.printf("Enter D value: \n");
-            
-                    btbee.read_all(arr_read, 30, &chars_read);
-                    D_TERM = atof(arr_read);
-            
-                    btbee.printf("D term is %f \n", D_TERM);
-                    
-                    wait(1);
-                    
-                    btbee.printf("Starting again with new parameters");
-            
-                    counter = -1;
-            
-            
-                     break;
-            
-                                    }
-            
-                      }
-              
-        }
+    //if (s1 > 500 and s5 > 500) {
+//        checkvar = 1;
+//        }
+//        
+//    if (s1 < 500 and s5 < 500 and checkvar == 1 and counter == -1) {
+//        LapTimer.reset();
+//        LapTimer.start();
+//        }
+//        
+//    if (s1 < 500 and s5 < 500 and checkvar == 1) {
+//        counter = counter + 1;
+//        m3pi.cls();
+//        m3pi.printf("%d", counter);
+//        checkvar = 0;
+//        switch (counter) {
+//            case 1: {
+//                Time1 = LapTimer.read();
+//                LapTimer.reset();
+//                LapTimer.start();
+//                btbee.printf("Lap 1: %f \n", Time1);
+//                break;
+//                }
+//            case 2: {
+//                Time2 = LapTimer.read();
+//                LapTimer.reset();
+//                LapTimer.start();
+//                btbee.printf("Lap 2: %f \n", Time2);
+//                break;
+//                }
+//            case 3: {
+//                Time3 = LapTimer.read();
+//                LapTimer.reset();
+//                LapTimer.start();
+//                btbee.printf("Lap 3: %f \n", Time3);
+//                break;
+//                }
+//            case 4: {
+//                Time4 = LapTimer.read();
+//                LapTimer.reset();
+//                LapTimer.start();
+//                btbee.printf("Lap 4: %f \n", Time4);
+//                break;
+//                }
+//            case 5: {
+//                Time5 = LapTimer.read();
+//                LapTimer.reset();
+//                LapTimer.start();
+//                btbee.printf("Lap 5: %f \n", Time5);
+//                break;
+//                }
+//            }
+//                
+//        
+//        }
+//        
+    //if (counter == 5) {
+//        m3pi.stop();
+//        m3pi.cls();
+//        m3pi.locate(0,0);
+//        m3pi.printf("Ave time");
+//        TimeAve = (Time1 + Time2 + Time3 + Time4 + Time5)/5.0;
+//        m3pi.locate(0,1);
+//        m3pi.printf("%f", TimeAve);
+//        btbee.printf("Average time per lap: %f \n", TimeAve);
+//        btbee.printf("\n");
+//        btbee.printf("Enter P value, I value, and D value separately \n");
+//                
+//                while(1) {
+//                    
+//                        
+//                        if (btbee.readable()) {
+//                            
+//                          btbee.printf("Enter P valure: \n");
+//            
+//            
+//                          btbee.read_all(arr_read, 30, &chars_read);
+//                           P_TERM = atof(arr_read);
+//            
+//                          btbee.printf("P term is %f \n", P_TERM);
+//            
+//                          wait(1.0);
+//            
+//            break;
+//            
+//                                             }
+//            
+//                          }
+//            
+//            while(1) {
+//                            
+//            if(btbee.readable()) {
+//                
+//                btbee.printf("Enter I value: \n");
+//            
+//                btbee.read_all(arr_read, 30, &chars_read);
+//                I_TERM = atof(arr_read);
+//            
+//                btbee.printf("I term is %f \n", I_TERM);
+//            
+//                 wait(1.0);
+//            
+//                 break;
+//            
+//                                    }
+//                                    
+//                        }
+//                        
+//            while(1)  {
+//                
+//                if(btbee.readable()) {
+//                    
+//                    btbee.printf("Enter D value: \n");
+//            
+//                    btbee.read_all(arr_read, 30, &chars_read);
+//                    D_TERM = atof(arr_read);
+//            
+//                    btbee.printf("D term is %f \n", D_TERM);
+//                    
+//                    wait(1);
+//                    
+//                    btbee.printf("Starting again with new parameters");
+//            
+//                    counter = -1;
+//            
+//            
+//                     break;
+//            
+//                                    }
+//            
+//                      }
+//              
+//        }