• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

src/F2/Flash.cpp

00001 #include "FCam/Frame.h"
00002 #include "FCam/F2/Flash.h"
00003 
00004 #include "PhidgetDevice.h"
00005 #include "../Debug.h"
00006 
00007 namespace FCam { namespace F2 {
00008 
00011     class PhidgetFlash : public FCam::F2::PhidgetDevice {
00012     public:
00014         bool triggerFlash(int flashOutputIndex) {
00015             if (PhidgetDevice::phidgetsAvailable) {
00016                 CPhidgetInterfaceKit_setOutputState(PhidgetDevice::ifKit, flashOutputIndex, true);
00017                 CPhidgetInterfaceKit_setOutputState(PhidgetDevice::ifKit, flashOutputIndex, false);
00018                 return true;
00019             } else {
00020                 printf("Phidgets aren't available. The flash will not be fired.\n");
00021                 return false;
00022             }
00023         }
00025         bool startStrobe(int flashOutputIndex) {
00026             if (PhidgetDevice::phidgetsAvailable) {
00027                 CPhidgetInterfaceKit_setOutputState(PhidgetDevice::ifKit, flashOutputIndex, true);
00028                 return true;
00029             } else {
00030                 printf("Phidgets aren't available. The flash will not be fired.\n");
00031                 return false;
00032             }
00033         }
00035         bool stopStrobe(int flashOutputIndex) {
00036             if (PhidgetDevice::phidgetsAvailable) {
00037                 CPhidgetInterfaceKit_setOutputState(PhidgetDevice::ifKit, flashOutputIndex, false);
00038                 return true;
00039             } else {
00040                 printf("Phidgets aren't available. The flash will not be fired.\n");
00041                 return false;
00042             }
00043         }
00044     };
00045         
00046 
00047     Flash::Flash(int phidgetOutputIndex): phidgetFlash(NULL){
00048         phidgetFlash = new PhidgetFlash;
00049         phidgetIndex = phidgetOutputIndex;
00050         latencyGuess = 127*1000;
00051         //phidgetFlash->flashOutputIndex = phidgetIndex;
00052         //printf("phidgetFlash outputIndex is %d\n", phidgetFlash->flashOutputIndex);
00053     }
00054     Flash::~Flash() {
00055         if (phidgetFlash) delete phidgetFlash;
00056     }
00057     
00058     void Flash::setBrightness(float b) {
00059         // Yeah, nothing here.
00060     }
00061     
00062     
00063     void Flash::setDuration(int d) {
00064         // Figure this out later, probably using something more complicated than phidgets
00065     }
00066     
00067     void Flash::fire(float brightness, int duration) {
00068         printf("Flash::fire() called, using index %d\n", phidgetIndex);
00069         phidgetFlash->triggerFlash(phidgetIndex);
00070     }
00071 
00072     void Flash::startStrobe() {
00073         phidgetFlash->startStrobe(phidgetIndex);
00074     }
00075     void Flash::stopStrobe() {
00076         phidgetFlash->stopStrobe(phidgetIndex);
00077     }
00078 
00079     void Flash::tagFrame(FCam::Frame f) {};
00080 
00081     Flash::StrobeStartAction::StrobeStartAction(Flash *f) : flash(f){
00082         latency = flash->fireLatency();
00083         time = 0;
00084     }
00085     Flash::StrobeStartAction::StrobeStartAction(Flash *f, int t) : flash(f) {
00086         latency = flash->fireLatency();
00087         time = t;
00088     }
00089 
00090     Flash::StrobeStopAction::StrobeStopAction(Flash *f) : flash(f){
00091         latency = flash->fireLatency();
00092         time = 0;
00093     }
00094     Flash::StrobeStopAction::StrobeStopAction(Flash *f, int t) : flash(f) {
00095         latency = flash->fireLatency();
00096         time = t;
00097     }
00098   
00099     void Flash::StrobeStartAction::doAction() {
00100         flash->startStrobe();
00101     }
00102     void Flash::StrobeStopAction::doAction() {      
00103         flash->stopStrobe();
00104     }
00105 
00106    
00107     }
00108 }

Generated on Fri Sep 24 2010 15:53:00 for FCam by  doxygen 1.7.1