fatboyslim / Mbed 2 deprecated buttontest

Dependencies:   FRDM-TFC mbed

Revision:
7:455e7dd338ee
Parent:
6:44d1079f076c
Child:
8:946806df7347
--- a/main.cpp	Wed Feb 18 20:51:28 2015 +0000
+++ b/main.cpp	Thu Feb 19 18:13:15 2015 +0000
@@ -5,13 +5,22 @@
 
 int main() 
 {
+    //run this before anything
     TFC_Init();
     
+    //variables
     float current_servo_position = 0;
     float current_left_motor_speed = 0;
     float current_right_motor_speed = 0;
     bool rear_motor_enable_flag = true;
+    bool linescan_ping_pong = false;
+    bool linescan_enable = false;
     
+    uint16_t  MyImage0Buffer[2][128];
+    uint16_t  MyImage1Buffer[2][128];
+    
+    
+    // major loop
     while(1) 
     {
         
@@ -26,7 +35,7 @@
                 if(current_servo_position <= -0.4)
                     current_servo_position = -0.4;
                 TFC_SetServo(0, current_servo_position);
-            }
+            }// end check button0
             
         else
             {
@@ -44,7 +53,7 @@
                 if(current_servo_position >= 0.4)
                     current_servo_position = 0.4;
                 TFC_SetServo(0, current_servo_position);
-            }
+            }// end check button1
             
         else
             {
@@ -53,12 +62,15 @@
             
         if(rear_motor_enable_flag)
             {
-                //
+                TFC_HBRIDGE_ENABLE;
                 //current_left_motor_speed    = current_left_motor_speed +  .3*(TFC_ReadPot(0));
                 //current_right_motor_speed   = current_right_motor_speed +  .3*(TFC_ReadPot(1));
                 
-                current_left_motor_speed    = .3*(TFC_ReadPot(0));
-                current_right_motor_speed   = .3*(TFC_ReadPot(1));
+                //current_left_motor_speed    = .3*(TFC_ReadPot(0));
+                //current_right_motor_speed   = .3*(TFC_ReadPot(1));
+                
+                current_left_motor_speed    = (TFC_ReadPot(0));
+                current_right_motor_speed   = (TFC_ReadPot(1));
                 
                 if(current_left_motor_speed >= 0.4)
                     current_left_motor_speed= 0.4;
@@ -70,7 +82,30 @@
                     current_right_motor_speed= -0.4;                       
                     
                 TFC_SetMotorPWM(current_left_motor_speed, current_right_motor_speed);
-            }    
+            }// end motor enabled
+        else
+            {
+                TFC_HBRIDGE_DISABLE;
+            }// end motor disabled    
+       
+        if (linescan_enable)
+            {
+             if (TFC_LineScanImageReady !=0)
+                {
+                if (linescan_ping_pong) //checking channel 0
+                    {
+                        //...
+                        linescan_ping_pong = false;
+                    }
+                else                    //checking channel 1
+                    {
+                        //...
+                        linescan_ping_pong = true;
+                    }
+                    
+                TFC_LineScanImageReady ==0;  // since we used it, we reset the flag
+                }// end imageready
+            }// end linescan stuff     
     }
 }
 //hi guys
\ No newline at end of file