synch the camera trigger with the signal in phase and quadrature (every frame or every N frames). We can also simulate the product by the in-phase signal (with a small arbitrary phase difference)

Dependencies:   mbed

Revision:
1:4284f27d638d
Parent:
0:4b5874bff9bb
--- a/Flipper.h	Mon Jul 14 09:35:12 2014 +0000
+++ b/Flipper.h	Mon Dec 08 07:03:38 2014 +0000
@@ -3,9 +3,9 @@
 
 #include "mbed.h"
 
-#define shutterPin p21 // for tests
-#define  ledPin p22 // the actual modulation of the LED source (equal to PHASE or QUAD signal every N frames)
-#define  cameraTriggerPin p23
+#define  ledPin p23 // the actual modulation of the LED source (equal to PHASE or QUAD signal every N frames)
+#define shutterPin p22 // for tests
+#define  cameraTriggerPin p21
 
 // A class for flip()-ing a DigitalOut using a timer
 
@@ -28,7 +28,7 @@
     }
     
     void start() {
-        myTicker.attach_us(this, &Flipper::flip, us_interval); // the address of the object, member function, and interval
+        myTicker.attach_us(this, &Flipper::flip, (unsigned int)(0.5*us_interval)); // the address of the object, member function, and interval
     }
     
    void stop() {
@@ -58,10 +58,18 @@
         NUM_STATES
         };
   
-    Trigger(PinName pin, float fps, unsigned int exposure) : _pin(pin) {
+    //Trigger(PinName pin, float fps, unsigned int exposure) : _pin(pin) {
+//    _pin=1;
+//    us_exposureTime=exposure;
+//    us_waitingTime=(unsigned int)(1000000.0/fps-us_exposureTime);
+//    framesQPToggle=2; // default number of frames before toggling between Q and P signals (delaying the Flipper signal by 90 deg). 
+//    QP_Mode=true;
+//    }
+
+Trigger(PinName pin, unsigned int waitingtime, unsigned int exposure) : _pin(pin) {
     _pin=1;
     us_exposureTime=exposure;
-    us_waitingTime=(unsigned int)(1000000.0/fps-us_exposureTime);
+    us_waitingTime=waitingtime;
     framesQPToggle=2; // default number of frames before toggling between Q and P signals (delaying the Flipper signal by 90 deg). 
     QP_Mode=true;
     }
@@ -70,8 +78,12 @@
         framesQPToggle=numToggleQPFrames;
     }
     
-    void setFrameRate(float fps) {
-        us_waitingTime=(unsigned int)(1000000.0/fps-us_exposureTime);
+   // void setFrameRate(float fps) {
+//        us_waitingTime=(unsigned int)(1000000.0/fps-us_exposureTime);
+//    }
+    
+     void setFrameRate(unsigned int waitingtime) {
+        us_waitingTime=waitingtime;
     }
     
      void setExposure(unsigned int exposure) {
@@ -143,7 +155,7 @@
     }
     
     void start() {
-        myTicker.attach_us(this, &Shutter::flip, us_interval); // the address of the object, member function, and interval
+        myTicker.attach_us(this, &Shutter::flip, (unsigned int)(0.5*us_interval)); // the address of the object, member function, and interval
     }
     
    void mixSignal(bool mode) {