![](/media/cache/profiles/5f14615696649541a025d3d0f8e0447f.jpg.50x50_q85.jpg)
JBBoardに接続したモーター2つをRCBControllerでコントロールするテストです。
Dependencies: FatFileSystem TB6612FNG2 mbed
Fork of JBB_BTLE_Test by
uvc/uvc.h@7:3ed1e36587d4, 2014-05-12 (annotated)
- Committer:
- jksoft
- Date:
- Mon May 12 14:24:35 2014 +0000
- Revision:
- 7:3ed1e36587d4
- Parent:
- 0:1ed23ab1345f
First edition
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:1ed23ab1345f | 1 | #ifndef UVC_H |
va009039 | 0:1ed23ab1345f | 2 | #define UVC_H |
va009039 | 0:1ed23ab1345f | 3 | #include "UsbBaseClass.h" |
va009039 | 0:1ed23ab1345f | 4 | #include "usb_mem.h" |
va009039 | 0:1ed23ab1345f | 5 | #include "usb_mjpeg.h" |
va009039 | 0:1ed23ab1345f | 6 | |
va009039 | 0:1ed23ab1345f | 7 | #define CLASS_VIDEO 0x0E |
va009039 | 0:1ed23ab1345f | 8 | |
va009039 | 0:1ed23ab1345f | 9 | #define SET_CUR 0x01 |
va009039 | 0:1ed23ab1345f | 10 | #define GET_CUR 0x81 |
va009039 | 0:1ed23ab1345f | 11 | #define GET_MIN 0x82 |
va009039 | 0:1ed23ab1345f | 12 | #define GET_MAX 0x83 |
va009039 | 0:1ed23ab1345f | 13 | #define GET_RES 0x84 |
va009039 | 0:1ed23ab1345f | 14 | #define GET_LEN 0x85 |
va009039 | 0:1ed23ab1345f | 15 | #define GET_INFO 0x86 |
va009039 | 0:1ed23ab1345f | 16 | #define GET_DEF 0x87 |
va009039 | 0:1ed23ab1345f | 17 | |
va009039 | 0:1ed23ab1345f | 18 | #define VS_PROBE_CONTROL 0x01 |
va009039 | 0:1ed23ab1345f | 19 | #define VS_COMMIT_CONTROL 0x02 |
va009039 | 0:1ed23ab1345f | 20 | |
va009039 | 0:1ed23ab1345f | 21 | #define PAYLOAD_UNDEF 0 |
va009039 | 0:1ed23ab1345f | 22 | #define PAYLOAD_MJPEG 1 |
va009039 | 0:1ed23ab1345f | 23 | #define PAYLOAD_YUY2 2 |
va009039 | 0:1ed23ab1345f | 24 | |
va009039 | 0:1ed23ab1345f | 25 | class uvc : public UsbBaseClass { |
va009039 | 0:1ed23ab1345f | 26 | public: |
va009039 | 0:1ed23ab1345f | 27 | uvc(int cam = 0); |
va009039 | 0:1ed23ab1345f | 28 | ~uvc(); |
va009039 | 0:1ed23ab1345f | 29 | int setup(); |
va009039 | 0:1ed23ab1345f | 30 | int get_jpeg(const char* path); |
va009039 | 0:1ed23ab1345f | 31 | int get_jpeg(uint8_t* buf, int size); |
va009039 | 0:1ed23ab1345f | 32 | bool interrupt(); |
va009039 | 0:1ed23ab1345f | 33 | int isochronous(); |
va009039 | 0:1ed23ab1345f | 34 | void attach(usb_stream* stream); |
va009039 | 0:1ed23ab1345f | 35 | void detach(); |
va009039 | 0:1ed23ab1345f | 36 | ///set format index |
va009039 | 0:1ed23ab1345f | 37 | void SetFormatIndex(int index = 1); |
va009039 | 0:1ed23ab1345f | 38 | ///set frame index |
va009039 | 0:1ed23ab1345f | 39 | void SetFrameIndex(int index = 1); |
va009039 | 0:1ed23ab1345f | 40 | ///set frame interval |
va009039 | 0:1ed23ab1345f | 41 | void SetFrameInterval(int val = 2000000); |
va009039 | 0:1ed23ab1345f | 42 | ///set packet size |
va009039 | 0:1ed23ab1345f | 43 | void SetPacketSize(int size = 128); |
va009039 | 0:1ed23ab1345f | 44 | ///set image size |
va009039 | 0:1ed23ab1345f | 45 | void SetImageSize(int width = 160, int height = 120); |
va009039 | 0:1ed23ab1345f | 46 | ///set payload MJPEG or YUY2 |
va009039 | 0:1ed23ab1345f | 47 | void SetPayload(int payload); // MJPEG,YUV422(YUY2) |
va009039 | 0:1ed23ab1345f | 48 | UsbErr Control(int req, int cs, int index, uint8_t* buf, int size); |
va009039 | 0:1ed23ab1345f | 49 | ///Setups the result callback |
va009039 | 0:1ed23ab1345f | 50 | /** |
va009039 | 0:1ed23ab1345f | 51 | @param pMethod : callback function |
va009039 | 0:1ed23ab1345f | 52 | */ |
va009039 | 0:1ed23ab1345f | 53 | void setOnResult( void (*pMethod)(uint16_t, uint8_t*, int) ); |
va009039 | 0:1ed23ab1345f | 54 | |
va009039 | 0:1ed23ab1345f | 55 | ///Setups the result callback |
va009039 | 0:1ed23ab1345f | 56 | /** |
va009039 | 0:1ed23ab1345f | 57 | @param pItem : instance of class on which to execute the callback method |
va009039 | 0:1ed23ab1345f | 58 | @param pMethod : callback method |
va009039 | 0:1ed23ab1345f | 59 | */ |
va009039 | 0:1ed23ab1345f | 60 | class CDummy; |
va009039 | 0:1ed23ab1345f | 61 | template<class T> |
va009039 | 0:1ed23ab1345f | 62 | void setOnResult( T* pItem, void (T::*pMethod)(uint16_t, uint8_t*, int) ) |
va009039 | 0:1ed23ab1345f | 63 | { |
va009039 | 0:1ed23ab1345f | 64 | m_pCb = NULL; |
va009039 | 0:1ed23ab1345f | 65 | m_pCbItem = (CDummy*) pItem; |
va009039 | 0:1ed23ab1345f | 66 | m_pCbMeth = (void (CDummy::*)(uint16_t, uint8_t*, int)) pMethod; |
va009039 | 0:1ed23ab1345f | 67 | } |
va009039 | 0:1ed23ab1345f | 68 | void clearOnResult(); |
va009039 | 0:1ed23ab1345f | 69 | |
va009039 | 0:1ed23ab1345f | 70 | void poll(); |
va009039 | 0:1ed23ab1345f | 71 | void wait(float s); |
va009039 | 0:1ed23ab1345f | 72 | void wait_ms(int ms); |
va009039 | 0:1ed23ab1345f | 73 | uint16_t ReportConditionCode[16]; |
va009039 | 0:1ed23ab1345f | 74 | protected: |
va009039 | 0:1ed23ab1345f | 75 | int _init(); |
va009039 | 0:1ed23ab1345f | 76 | void _config(struct stcamcfg* cfg); |
va009039 | 0:1ed23ab1345f | 77 | void onResult(uint16_t frame, uint8_t* buf, int len); |
va009039 | 0:1ed23ab1345f | 78 | bool m_connect; |
va009039 | 0:1ed23ab1345f | 79 | bool m_init; |
va009039 | 0:1ed23ab1345f | 80 | int m_cam; |
va009039 | 0:1ed23ab1345f | 81 | UsbDevice* m_pDev; |
va009039 | 0:1ed23ab1345f | 82 | UsbEndpoint* m_pEpIntIn; |
va009039 | 0:1ed23ab1345f | 83 | UsbEndpoint* m_pEpIsoIn; |
va009039 | 0:1ed23ab1345f | 84 | int m_width; |
va009039 | 0:1ed23ab1345f | 85 | int m_height; |
va009039 | 0:1ed23ab1345f | 86 | int m_payload; |
va009039 | 0:1ed23ab1345f | 87 | int m_FormatIndex; |
va009039 | 0:1ed23ab1345f | 88 | int m_FrameIndex; |
va009039 | 0:1ed23ab1345f | 89 | int m_FrameInterval; |
va009039 | 0:1ed23ab1345f | 90 | int m_PacketSize; |
va009039 | 0:1ed23ab1345f | 91 | int m_FrameCount; // 1-8 |
va009039 | 0:1ed23ab1345f | 92 | int m_itdCount; |
va009039 | 0:1ed23ab1345f | 93 | uint8_t m_int_buf[16]; |
va009039 | 0:1ed23ab1345f | 94 | int m_int_seq; |
va009039 | 0:1ed23ab1345f | 95 | int m_iso_seq; |
va009039 | 0:1ed23ab1345f | 96 | uint16_t m_iso_frame; |
va009039 | 0:1ed23ab1345f | 97 | usb_stream* m_stream; |
va009039 | 0:1ed23ab1345f | 98 | CDummy* m_pCbItem; |
va009039 | 0:1ed23ab1345f | 99 | void (CDummy::*m_pCbMeth)(uint16_t, uint8_t*, int); |
va009039 | 0:1ed23ab1345f | 100 | void (*m_pCb)(uint16_t, uint8_t*, int); |
va009039 | 0:1ed23ab1345f | 101 | }; |
va009039 | 0:1ed23ab1345f | 102 | #endif //UVC_H |