Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Revision:
4:f9d364f10335
Parent:
3:b44ff6de81bd
Child:
5:73cd58b58f95
--- a/classLaserSensingTrajectory.cpp	Mon Apr 02 05:33:44 2012 +0000
+++ b/classLaserSensingTrajectory.cpp	Wed Apr 04 10:05:25 2012 +0000
@@ -7,12 +7,19 @@
    // lsdTrajectory.clear(); // there is no need to clear the vector, the destructor of this vector is called by default (and it's NOT a vector of pointers)
 }
 
+  
+void LaserSensingTrajectory::setDelayMirrors(int delay) {
+    delayMirrorSamples=delay;
+}
+
 void LaserSensingTrajectory::processSensedData() {
     // Compute max and min intensity on the loop
     maxI=0;
     minI=4096;
+    int auxSize=lsdTrajectory.size();
+    
     for (int i = 0; i < lsdTrajectory.size(); i++) {
-        float mesI=lsdTrajectory[i].intensity;
+        float mesI=lsdTrajectory[(i+auxSize-delayMirrorSamples)%auxSize].intensity; // I need to do "auxSize-delay" instead of "-delay" only, because otherwise I will get negative values
         if (maxI<mesI)  maxI=mesI;
         if (minI>mesI)  minI=mesI;
     }
@@ -30,10 +37,11 @@
     // idea of the blob "constant" internal pressure...
     lightTouched=false;
     for (int i = 0; i <  lsdTrajectory.size(); i++) {
-        if (lsdTrajectory[i].intensity>autoThreshold) { // this means a WHITE zone:
-            lsdTrajectory[i].lightZone= 2;//-1;//1;
+        int delayedpoint=(i+auxSize-delayMirrorSamples)%auxSize;
+        if (lsdTrajectory[delayedpoint].intensity>autoThreshold) { // this means a WHITE zone:
+            lsdTrajectory[delayedpoint].lightZone= -1;//1;
         } else { // something touched: DARK ZONE
-            lsdTrajectory[i].lightZone= 2;//0;
+            lsdTrajectory[delayedpoint].lightZone= 2;//0;
             lightTouched=true; // (for the whole loop)
         }
     }