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 { namespace N900 { 00013 00017 class Lens : public FCam::Lens { 00018 00019 public: 00020 Lens(); 00021 ~Lens(); 00022 00023 void setFocus(float, float speed); 00024 float getFocus() const; 00025 00027 float farFocus() const {return 0.0f;} 00028 00030 float nearFocus() const {return 20.0f;} 00031 bool focusChanging() const; 00032 00033 00039 float minFocusSpeed() const; 00040 00044 float maxFocusSpeed() const; 00045 00046 00047 /* The lens starts moving about 175 microseconds after 00048 * setFocus is called. 00049 * 00050 * \todo This is a guess based on the fact setFocus takes 00051 * about 350us. We would like to calibrate this better. 00052 * 00053 */ 00054 int focusLatency() const {return 175;} 00055 00057 void setZoom(float, float) {} 00058 00060 float getZoom() const {return 5.2f;} 00061 00063 float minZoom() const {return 5.2f;} 00064 00066 float maxZoom() const {return 5.2f;} 00067 00069 bool zoomChanging() const {return false;} 00070 00072 float minZoomSpeed() const {return 0;} 00073 00075 float maxZoomSpeed() const {return 0;} 00076 00078 int zoomLatency() const {return 0;} 00079 00081 void setAperture(float, float) {} 00082 00084 float getAperture() const {return 2.8f;} 00085 00087 float wideAperture(float) const {return 2.8f;} 00088 00090 float narrowAperture(float) const {return 2.8f;} 00091 00093 bool apertureChanging() const {return false;} 00094 00096 int apertureLatency() const {return 0;} 00097 00099 float minApertureSpeed() const {return 0.0f;} 00100 00102 float maxApertureSpeed() const {return 0.0f;} 00103 00106 void tagFrame(FCam::Frame); 00107 00110 float getFocus(Time t) const; 00111 00112 private: 00113 00114 int ioctlSet(unsigned key, int val); 00115 int ioctlGet(unsigned key); 00116 00117 float ticksToDiopters(int) const; 00118 int dioptersToTicks(float) const; 00119 float tickRateToDiopterRate(int) const; 00120 int diopterRateToTickRate(float) const; 00121 00122 struct LensState { 00123 Time time; 00124 float position; 00125 }; 00126 CircularBuffer<LensState> lensHistory; 00127 }; 00128 00129 }} 00130 00131 #endif