Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Revision:
33:43e8bc451ef0
Parent:
32:52273c3291fe
Child:
34:1244fa3f2559
--- a/classLaserSensingTrajectory.cpp	Mon Oct 29 14:28:47 2012 +0000
+++ b/classLaserSensingTrajectory.cpp	Mon Nov 05 06:08:35 2012 +0000
@@ -1,8 +1,9 @@
 #include "classLaserSensingTrajectory.h"
 
 LaserSensingTrajectory::LaserSensingTrajectory():lightTouched(false), 
-min_contrast_ratio(MIN_CONTRAST_RATIO), threshold_factor(THRESHOLD_FACTOR), 
-min_acceptable_intensity(MIN_ACCEPTABLE_INTENSITY) {
+modeThreshold(FIXED), 
+min_contrast_ratio(MIN_CONTRAST_RATIO), threshold_factor(THRESHOLD_FACTOR), min_acceptable_intensity(MIN_ACCEPTABLE_INTENSITY), 
+fixedThreshold(FIXED_THRESHOLD) {
 }
 
 LaserSensingTrajectory::~LaserSensingTrajectory() {
@@ -32,12 +33,17 @@
     }
 
     // Compute autoThreshold:
-    if (maxI<min_acceptable_intensity) autoThreshold=255;// (we consider that the saccade is FULL on something black)
-    else if (minI==0) autoThreshold=0; // (we consider that the saccade is FULL on something white)
-    else if (1.0*maxI/minI > min_contrast_ratio ) {
-        autoThreshold = (unsigned char) (1.0 * (maxI-minI) * threshold_factor + minI);    // threshold_factor = 2/3 or 1/2 is a good value.
-    } else {// ... otherwise, we consider that the saccade is FULL on something white
-        autoThreshold=0;
+    switch(modeThreshold) {
+    case AUTO:
+        if (minI==0) minI=1;
+        if (maxI<min_acceptable_intensity) autoThreshold=255;// (we consider that the saccade is FULL on something black)
+        else if (1.0*maxI/minI > min_contrast_ratio ) {
+            autoThreshold = (unsigned char) (1.0 * (maxI-minI) * threshold_factor + minI);    // threshold_factor = 2/3 or 1/2 is a good value.
+        } else {// ... otherwise, we consider that the saccade is FULL on something white
+            autoThreshold=0;
+        }
+    case FIXED:
+        autoThreshold=fixedThreshold;
     }
 
     // Segment the trajectory (only two levels for the time being, but we can have more - meaning different forces, real or even complex values to have different angle forces...):