00001 #ifndef FCAM_N900_LENS_H 00002 #define FCAM_N900_LENS_H 00003 00007 #include "../Lens.h" 00008 #include "../CircularBuffer.h" 00009 #include "../Time.h" 00010 #include <vector> 00011 00012 namespace FCam { 00013 namespace N900 { 00014 00018 class Lens : public FCam::Lens { 00019 00020 public: 00021 Lens(); 00022 ~Lens(); 00023 00024 void setFocus(float, float speed); 00025 float getFocus() const; 00026 00028 float farFocus() const {return 0.0f;} 00029 00031 float nearFocus() const {return 20.0f;} 00032 bool focusChanging() const; 00033 00034 00040 float minFocusSpeed() const; 00041 00045 float maxFocusSpeed() const; 00046 00047 00048 /* The lens starts moving about 175 microseconds after 00049 * setFocus is called. 00050 * 00051 * \todo This is a guess based on the fact setFocus takes 00052 * about 350us. We would like to calibrate this better. 00053 * 00054 */ 00055 int focusLatency() const {return 175;} 00056 00058 void setZoom(float, float) {} 00059 00061 float getZoom() const {return 5.2f;} 00062 00064 float minZoom() const {return 5.2f;} 00065 00067 float maxZoom() const {return 5.2f;} 00068 00070 bool zoomChanging() const {return false;} 00071 00073 float minZoomSpeed() const {return 0;} 00074 00076 float maxZoomSpeed() const {return 0;} 00077 00079 int zoomLatency() const {return 0;} 00080 00082 void setAperture(float, float) {} 00083 00085 float getAperture() const {return 2.8f;} 00086 00088 float wideAperture(float) const {return 2.8f;} 00089 00091 float narrowAperture(float) const {return 2.8f;} 00092 00094 bool apertureChanging() const {return false;} 00095 00097 int apertureLatency() const {return 0;} 00098 00100 float minApertureSpeed() const {return 0.0f;} 00101 00103 float maxApertureSpeed() const {return 0.0f;} 00104 00107 void tagFrame(FCam::Frame); 00108 00111 float getFocus(Time t) const; 00112 00113 private: 00114 00115 int ioctlSet(unsigned key, int val); 00116 int ioctlGet(unsigned key); 00117 00118 float ticksToDiopters(int) const; 00119 int dioptersToTicks(float) const; 00120 float tickRateToDiopterRate(int) const; 00121 int diopterRateToTickRate(float) const; 00122 00123 struct LensState { 00124 Time time; 00125 float position; 00126 }; 00127 CircularBuffer<LensState> lensHistory; 00128 }; 00129 00130 } 00131 } 00132 00133 #endif