
Simple USBHost WebCam test program
Dependencies: F401RE-USBHost mbed
Fork of KL46Z-USBHostC270_example by
WebカメラからJPEG画像を読み取るテストプログラムです。
使い方はKL46Z-USBHostC270_exampleと同じです。
動作確認カメラ: Logitech C270, Logitech C210, Logitech Q200R(Qcam Orbit AF), LifeCam VX-500
Diff: KL46Z_USBHostC270/USBHostCam.h
- Revision:
- 2:2a40888db9fc
- Parent:
- 1:22304b8f8395
--- a/KL46Z_USBHostC270/USBHostCam.h Tue Jan 28 06:54:16 2014 +0000 +++ b/KL46Z_USBHostC270/USBHostCam.h Fri Jan 31 13:50:15 2014 +0000 @@ -38,7 +38,7 @@ /** * A class to communicate a Cam */ -class USBHostCam : public BaseUvc, public decodeMJPEG { +class USBHostCam : public IUSBEnumerator, public BaseUvc, public decodeMJPEG { public: /** * Constructor @@ -47,6 +47,20 @@ USBHostCam(uint8_t size = _160x120, uint8_t option = 0, CamInfo* user_caminfo = NULL); /** + * Check if a Cam device is connected + * + * @return true if a Cam device is connected + */ + bool connected(); + + /** + * Try to connect to a Cam device + * + * @return true if connection was successful + */ + bool connect(); + + /** * read jpeg image * * @param buf read buffer @@ -56,7 +70,19 @@ */ int readJPEG(uint8_t* buf, int size, int timeout_ms = 15*1000); +protected: + //From IUSBEnumerator + virtual void setVidPid(uint16_t vid, uint16_t pid); + 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 + virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used + private: + bool dev_connected; + + int cam_intf; + bool device_found; + bool caminfo_found; + uint8_t _seq; uint8_t* _buf; int _pos; @@ -66,7 +92,7 @@ uint8_t _caminfo_size; uint8_t _caminfo_option; - void setup(); virtual void outputJPEG(uint8_t c, int status); // from decodeMJPEG void callback_motion_jpeg(uint16_t frame, uint8_t* buf, int len); + void init(); };