Custom version for NXP cup car

Dependents:   NXPCUPcar

Revision:
1:68bb92736e14
Parent:
0:ccbc44580fab
diff -r ccbc44580fab -r 68bb92736e14 Vision.cpp
--- a/Vision.cpp	Fri Mar 25 13:05:09 2016 +0000
+++ b/Vision.cpp	Thu Jun 01 13:17:03 2017 +0000
@@ -13,6 +13,9 @@
 {
     uint8_t i;
     
+    dataAge.reset();
+    dataAge.start();
+    
     for(i=0;i<128;i++)
     {
         lineData[i] = newData[i];
@@ -96,9 +99,28 @@
         }
     }
     
+    result.leftEdgePosition = getPixelPosition(result.leftEdgeIndex);
+    result.rightEdgePosition = getPixelPosition(result.rightEdgeIndex);
+    
+    result.age = dataAge;
+    
     return result;
 }
 
+struct Point Vision::getPixelPosition(uint8_t pixelIndex)
+{
+    struct Point position;
+//    lensToImageDistance = lensHeightFromFloor/cos(lensAngle)
+//    x = lensToImageDistance*(pixelSpace+pixelWidth)/focalDistance*(pixelIndex-63.5);
+//    x = 8.6396*(pixelindex-63.5);
+//    y = tan(lensAngle)*lensHeightFromFloor+wheelLensHorizontalDistance
+
+    position.x = 8.6396*((float)pixelIndex-63.5);
+    position.y = 303.266;
+    
+    return position;
+}
+
 void Vision::lineScanLightAdjust()
 {
     uint8_t i;
@@ -109,7 +131,7 @@
     }
 }
 
-void Vision::processTasks()
+bool Vision::processTasks()
 {
     if(newDataToProcess)
     {
@@ -119,7 +141,9 @@
         currentRoadData = processLine();
         newDataToProcess = false;
         //TFC_BAT_LED3_OFF;
+        return true;
     }
+    return false;
 }
 
 struct lineScanData Vision::getRoadData()