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