Lcd companion boards support (VKLCD50RTA & VKLCD70RT)
Embed:
(wiki syntax)
Show/hide line numbers
USBHostCam.h
00001 // USBHostCam.h 00002 #include "USBHostConf.h" 00003 #include "USBHost.h" 00004 #include "USBIsochronous.h" 00005 #include "BaseUvc.h" 00006 #include "decodeMJPEG.h" 00007 #pragma once 00008 00009 #define _640x480 1 00010 #define _160x120 2 00011 #define _176x144 3 00012 #define _320x176 4 00013 #define _320x240 5 00014 #define _352x288 6 00015 #define _432x240 7 00016 #define _544x288 8 00017 #define _640x360 9 00018 // 00019 #define _752x416 10 00020 #define _800x448 11 00021 #define _800x600 12 00022 // 00023 #define _864x480 13 00024 #define _960x544 14 00025 #define _960x720 15 00026 // 00027 #define _1024x576 16 00028 #define _1184x656 17 00029 #define _1280x720 18 00030 #define _1280x960 19 00031 00032 /* 00033 #define _640x480 1 00034 #define _352x288 2 00035 #define _320x240 3 00036 #define _176x144 4 00037 #define _160x120 5 00038 #define _544x288 6 00039 #define _432x240 7 00040 #define _320x176 8 00041 #define _640x360 9 00042 00043 #define _800x480 10 00044 00045 #define _1024x768 11 00046 */ 00047 00048 00049 #define TEST_ASSERT(A) while(!(A)){fprintf(stderr,"\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);}; 00050 00051 struct CamInfo { 00052 uint16_t vid; 00053 uint16_t pid; 00054 uint8_t size; 00055 uint8_t option; 00056 // 00057 const char* name; 00058 uint8_t formatIndex; 00059 uint8_t frameIndex; 00060 uint32_t interval; 00061 uint8_t en; 00062 uint16_t mps; 00063 uint8_t if_alt; 00064 uint8_t frameCount; // ITD frame count 1-8 00065 uint8_t queueLimit; // ITD queue limit 1-3 00066 }; 00067 00068 /** 00069 * A class to communicate a Cam 00070 */ 00071 class USBHostCam : public IUSBEnumerator, public BaseUvc, public decodeMJPEG { 00072 public: 00073 /** 00074 * Constructor 00075 * 00076 */ 00077 USBHostCam(uint8_t size = _160x120, uint8_t option = 0, CamInfo* user_caminfo = NULL); 00078 00079 /** 00080 * Check if a Cam device is connected 00081 * 00082 * @return true if a Cam device is connected 00083 */ 00084 bool connected(); 00085 00086 /** 00087 * Check if a usb connector is plugged 00088 * 00089 * @return true if a connector is plugged 00090 */ 00091 bool plugged(); 00092 00093 /** 00094 * Try to connect to a Cam device 00095 * 00096 * @return true if connection was successful 00097 */ 00098 bool connect(); 00099 00100 /** 00101 * read jpeg image 00102 * 00103 * @param buf read buffer 00104 * @param size buffer size 00105 * @param timeout_ms timeout default 15sec 00106 * @return jpeg size if read success else -1 00107 */ 00108 int readJPEG(uint8_t* buf, int size, int timeout_ms = 15*1000); 00109 00110 protected: 00111 //From IUSBEnumerator 00112 virtual void setVidPid(uint16_t vid, uint16_t pid); 00113 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed 00114 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00115 00116 private: 00117 bool dev_connected; 00118 00119 int cam_intf; 00120 bool device_found; 00121 bool caminfo_found; 00122 uint8_t _seq; 00123 uint8_t* _buf; 00124 int _pos; 00125 int _size; 00126 CamInfo* CamInfoList; 00127 CamInfo* caminfo; 00128 uint8_t _caminfo_size; 00129 uint8_t _caminfo_option; 00130 00131 virtual void outputJPEG(uint8_t c, int status); // from decodeMJPEG 00132 void callback_motion_jpeg(uint16_t frame, uint8_t* buf, int len); 00133 void init(); 00134 void onDisconnect(); 00135 };
Generated on Tue Jul 12 2022 14:32:48 by
1.7.2