Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Revision:
37:fa6b1f15819f
Parent:
36:233b12d0b1f0
Child:
38:9b522ef2c519
--- a/hardwareIO/hardwareIO.cpp	Wed Mar 13 11:38:48 2013 +0000
+++ b/hardwareIO/hardwareIO.cpp	Wed Mar 13 12:29:37 2013 +0000
@@ -18,7 +18,7 @@
  InterruptIn switchOne(SWITCH_ONE);   
  DigitalOut ledSwitchOne(LED_SWITCH_ONE);
  InterruptIn switchTwo(SWITCH_TWO); 
- //AnalogIn ain(POT_ANALOG_INPUT);   
+ AnalogIn ainPot(POT_ANALOG_INPUT);   
 
 void HardwareIO::init(void) {
 
@@ -102,28 +102,36 @@
     } else return(false);
 }
 
+// THIS IS NOT WORKING!!!!!!
 unsigned char HardwareIO::updatePotValue() { // this will update the pot value, and return it too.
-    //The value will be ajusted in the range 0-255
+   //The value will be ajusted in the range 0-255
     //The 0.0v to 3.3v range of the AnalogIn is represented in software as a normalised floating point number from 0.0 to 1.0.
-    //potValue=(unsigned char )(ain*255);
-    
+
+ //   potValue=(unsigned char )(ainPot*255);
+   // Attention: go back to burst mode:
+ //   lockin.setADC_forLockin(1);
+ //   wait(1);
+
+ //USING the adc library: 
+    // unset fast adc for lockin, and set normal adc for conversion from analog input pin:
     lockin.setADC_forLockin(0);
-    
-     adc.setup(POT_ANALOG_INPUT,1);
-     wait(1);
-        
-        //Measure pin POT_ANALOG_INPUT
-        adc.select(POT_ANALOG_INPUT);
-        //Start ADC conversion
-        adc.start();
-        //Wait for it to complete
-        while(!adc.done(POT_ANALOG_INPUT));
-        potValue=adc.read(POT_ANALOG_INPUT);
-    
-     //Unset pin POT_ANALOG_INPUT
-        adc.setup(POT_ANALOG_INPUT,0);
-    
-     lockin.setADC_forLockin(1);
+    adc.setup(POT_ANALOG_INPUT,1);
+
+    wait(1);
+
+    //Measure pin POT_ANALOG_INPUT
+    adc.select(POT_ANALOG_INPUT);
+    //Start ADC conversion
+    adc.start();
+    //Wait for it to complete
+    while(!adc.done(POT_ANALOG_INPUT));
+    potValue=adc.read(POT_ANALOG_INPUT);
+
+    //Unset pin POT_ANALOG_INPUT
+    adc.setup(POT_ANALOG_INPUT,0);
+
+    lockin.setADC_forLockin(1);
+    wait(0.5);
     
     return(potValue);
 }