fatboyslim / Mbed 2 deprecated buttontest

Dependencies:   FRDM-TFC mbed

Revision:
9:2b028ee421ad
Parent:
8:946806df7347
Child:
10:6d9d70a240fd
--- a/main.cpp	Thu Feb 19 19:31:37 2015 +0000
+++ b/main.cpp	Mon Feb 23 20:08:25 2015 +0000
@@ -14,10 +14,10 @@
     float current_right_motor_speed = 0;
     bool rear_motor_enable_flag = true;
     bool linescan_ping_pong = false;
-    bool linescan_enable = false;
+    bool linescan_enable = true;
     
-    uint16_t  MyImage0Buffer[2][128];
-    uint16_t  MyImage1Buffer[2][128];
+    //uint16_t  MyImage0Buffer[2][128];
+    //uint16_t  MyImage1Buffer[2][128];
     
     
     // major loop
@@ -26,10 +26,10 @@
         
         if (TFC_ReadPushButton(0) != 0 )
             {
-                TFC_BAT_LED0_ON;
+                /*(TFC_BAT_LED0_ON;
                 wait(0.004);
                 TFC_BAT_LED0_OFF; 
-                wait(0.004);
+                wait(0.004);*/
                 
                 current_servo_position = current_servo_position-.005;
                 if(current_servo_position <= -0.4)
@@ -39,15 +39,15 @@
             
         else
             {
-                TFC_BAT_LED0_ON;
+                //TFC_BAT_LED0_ON;
             }
             
         if (TFC_ReadPushButton(1) != 0 )
             {
-                TFC_BAT_LED1_ON;
+                /*TFC_BAT_LED1_ON;
                 wait(0.004);
                 TFC_BAT_LED1_OFF; 
-                wait(0.004);
+                wait(0.004);*/
                 
                 current_servo_position = current_servo_position+.005;
                 if(current_servo_position >= 0.4)
@@ -57,7 +57,7 @@
             
         else
             {
-                TFC_BAT_LED1_ON;
+                //TFC_BAT_LED1_ON;
             }
             
         if(rear_motor_enable_flag)
@@ -92,16 +92,41 @@
             {
              if (TFC_LineScanImageReady !=0)
                 {
+                // this block sucks
                 if (linescan_ping_pong) //checking channel 0
                     {
                         //...
+                        //uint8_t shitnum = uint8_t(*TFC_LineScanImage0>>3);
+                        uint8_t shitnum = 1;
+                        if (*(TFC_LineScanImage0+64) > 400)
+                            shitnum = 15;
+                        else if((*TFC_LineScanImage0 > 350))
+                            shitnum = 7;
+                        else if((*TFC_LineScanImage0 > 300))
+                            shitnum = 3;
+                        else 
+                            shitnum = 1;
+                        
+                        TFC_SetBatteryLED(shitnum);
                         linescan_ping_pong = false;
                     }
                 else                    //checking channel 1
                     {
                         //...
+                        //TFC_SetBatteryLED(*TFC_LineScanImage1+4);
                         linescan_ping_pong = true;
                     }
+                // end of this block sucks
+                    
+                /*    this block sucks too
+                if ((* TFC_LineScanImage0) > (* TFC_LineScanImage1))
+                    TFC_SetBatteryLED(*TFC_LineScanImage0);
+                else
+                    TFC_SetBatteryLED(*TFC_LineScanImage1);
+                */    
+                    
+                //TFC_SetBatteryLED(*TFC_LineScanImage0+4);    
+                    
                     
                 TFC_LineScanImageReady ==0;  // since we used it, we reset the flag
                 }// end imageready