Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Revision:
34:1244fa3f2559
Parent:
33:43e8bc451ef0
Child:
35:35af5086ab4f
diff -r 43e8bc451ef0 -r 1244fa3f2559 main.cpp
--- a/main.cpp	Mon Nov 05 06:08:35 2012 +0000
+++ b/main.cpp	Wed Nov 07 14:41:55 2012 +0000
@@ -193,6 +193,21 @@
         if (pc.readable()>0) processSerial();
 #endif
 
+        // Potentiometer, switches, etc:
+        //(1) Check for change of threshold mode button (switch one): 
+        //!!! ATTENTION: this does not work very well to say the truth: bouncing+adc settings problems...
+        bool stateswitch;
+        if (IO.switchOneCheck(stateswitch)) {
+            if (stateswitch) pc.printf("Setting AUTO threshold mode\n"); else pc.printf("Setting FIXED threshold mode\n"); 
+            for (int i=0; i< blobconf.numBlobs; i++) blobconf.blobArray[i]->displaySensingBuffer.setThresholdMode((stateswitch? 1 : 0));
+        }
+        //(2) in case the threshold mode is set to fixed, check the current pot value and update the threshold when pressing second switch:
+       if ((blobconf.blobArray[0]->displaySensingBuffer.modeThreshold==FIXED)&&(IO.switchTwoCheck(stateswitch))) { 
+           IO.updatePotValue(); 
+           for (int i=0; i< blobconf.numBlobs; i++) blobconf.blobArray[i]->displaySensingBuffer.setFixedThreshold(IO.potValue);
+           pc.printf("Got :%d\n", IO.potValue);
+        }
+        
 
         // text:
         /*
@@ -589,10 +604,9 @@
 
     
  // THRESHOLD MODE, and PARAMETERS:
-    //(1) using multiplicative factor:
+    //(1) Set the threshold mode:
     else if (!strcmp( address[0], "autoThreshold" ) ) {
-      int value=data[0]; // value 100 means no change of the current contrast value. 200 means a min contrast 
-      // that is twice as large and 50 is half as large as before. 
+      int value=data[0]; // 1 (auto) or 0 (fixed) 
       if (value!=-1) { // otherwise do nothing, this is a reception error (there was no data)     
         for (int i=0; i< blobconf.numBlobs; i++) blobconf.blobArray[i]->displaySensingBuffer.setThresholdMode(value);
       }
@@ -615,7 +629,7 @@
         for (int i=0; i< blobconf.numBlobs; i++) blobconf.blobArray[i]->displaySensingBuffer.setMinContrastRatio((float)(1.0*value/100.0));
       }
     }
-    // THESHOLD FACTOR: 
+    // THRESHOLD FACTOR: 
     //(1) using multiplicative factor:
     else if (!strcmp( address[0], "adjustMultThreshold" ) ) {
       int value=data[0]; // value 100 means no change of the current contrast value. 200 means a min contrast