QC Control software

Dependencies:   mbed

Fork of dgps by Colin Stearns

Committer:
dylanembed123
Date:
Mon May 05 13:20:35 2014 +0000
Revision:
66:5d43988d100c
Parent:
14:6be57da62283
Final Project;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dylanembed123 7:c75d5e5e6bfc 1 /**
dylanembed123 7:c75d5e5e6bfc 2 * \brief Camera interface
dylanembed123 7:c75d5e5e6bfc 3 **/
dylanembed123 7:c75d5e5e6bfc 4 #define CAMERABUFFSIZ 128
dylanembed123 7:c75d5e5e6bfc 5 #include "usb.h"
dylanembed123 7:c75d5e5e6bfc 6 #include "mbed.h"
dylanembed123 7:c75d5e5e6bfc 7
dylanembed123 7:c75d5e5e6bfc 8 /// Define Pinout
dylanembed123 13:a6d3cf2b018e 9 #define CAMERAPINTX p13
dylanembed123 13:a6d3cf2b018e 10 #define CAMERAPINRX p14
dylanembed123 7:c75d5e5e6bfc 11
dylanembed123 7:c75d5e5e6bfc 12 /// Define Baud
dylanembed123 7:c75d5e5e6bfc 13 #define CAMERABAUD 38400
dylanembed123 7:c75d5e5e6bfc 14
dylanembed123 7:c75d5e5e6bfc 15 /// Define commands
dylanembed123 7:c75d5e5e6bfc 16 #define VC0706_RESET 0x26
dylanembed123 7:c75d5e5e6bfc 17 #define VC0706_GEN_VERSION 0x11
dylanembed123 7:c75d5e5e6bfc 18 #define VC0706_READ_FBUF 0x32
dylanembed123 7:c75d5e5e6bfc 19 #define VC0706_GET_FBUF_LEN 0x34
dylanembed123 7:c75d5e5e6bfc 20 #define VC0706_FBUF_CTRL 0x36
dylanembed123 7:c75d5e5e6bfc 21 #define VC0706_DOWNSIZE_CTRL 0x54
dylanembed123 7:c75d5e5e6bfc 22 #define VC0706_DOWNSIZE_STATUS 0x55
dylanembed123 7:c75d5e5e6bfc 23 #define VC0706_READ_DATA 0x30
dylanembed123 7:c75d5e5e6bfc 24 #define VC0706_WRITE_DATA 0x31
dylanembed123 7:c75d5e5e6bfc 25 #define VC0706_COMM_MOTION_CTRL 0x37
dylanembed123 7:c75d5e5e6bfc 26 #define VC0706_COMM_MOTION_STATUS 0x38
dylanembed123 7:c75d5e5e6bfc 27 #define VC0706_COMM_MOTION_DETECTED 0x39
dylanembed123 7:c75d5e5e6bfc 28 #define VC0706_MOTION_CTRL 0x42
dylanembed123 7:c75d5e5e6bfc 29 #define VC0706_MOTION_STATUS 0x43
dylanembed123 7:c75d5e5e6bfc 30 #define VC0706_TVOUT_CTRL 0x44
dylanembed123 7:c75d5e5e6bfc 31 #define VC0706_OSD_ADD_CHAR 0x45
dylanembed123 7:c75d5e5e6bfc 32
dylanembed123 7:c75d5e5e6bfc 33 #define VC0706_STOPCURRENTFRAME 0x0
dylanembed123 7:c75d5e5e6bfc 34 #define VC0706_STOPNEXTFRAME 0x1
dylanembed123 7:c75d5e5e6bfc 35 #define VC0706_RESUMEFRAME 0x3
dylanembed123 7:c75d5e5e6bfc 36 #define VC0706_STEPFRAME 0x2
dylanembed123 7:c75d5e5e6bfc 37
dylanembed123 7:c75d5e5e6bfc 38 #define VC0706_640x480 0x00
dylanembed123 7:c75d5e5e6bfc 39 #define VC0706_320x240 0x11
dylanembed123 7:c75d5e5e6bfc 40 #define VC0706_160x120 0x22
dylanembed123 7:c75d5e5e6bfc 41
dylanembed123 7:c75d5e5e6bfc 42 #define VC0706_MOTIONCONTROL 0x0
dylanembed123 7:c75d5e5e6bfc 43 #define VC0706_UARTMOTION 0x01
dylanembed123 7:c75d5e5e6bfc 44 #define VC0706_ACTIVATEMOTION 0x01
dylanembed123 7:c75d5e5e6bfc 45
dylanembed123 7:c75d5e5e6bfc 46 #define VC0706_SET_ZOOM 0x52
dylanembed123 7:c75d5e5e6bfc 47 #define VC0706_GET_ZOOM 0x53
dylanembed123 7:c75d5e5e6bfc 48
dylanembed123 7:c75d5e5e6bfc 49 //#define CAMERABUFFSIZ 100
dylanembed123 7:c75d5e5e6bfc 50 #define CAMERADELAY 10
dylanembed123 7:c75d5e5e6bfc 51
dylanembed123 7:c75d5e5e6bfc 52
dylanembed123 7:c75d5e5e6bfc 53
dylanembed123 7:c75d5e5e6bfc 54
dylanembed123 7:c75d5e5e6bfc 55 /// \brief Camera class
dylanembed123 7:c75d5e5e6bfc 56 class Camera{
dylanembed123 7:c75d5e5e6bfc 57 static Serial* camera;
dylanembed123 7:c75d5e5e6bfc 58 static uint8_t serialNum;
dylanembed123 7:c75d5e5e6bfc 59 uint8_t bufferLen;
dylanembed123 7:c75d5e5e6bfc 60 uint8_t camerabuff[CAMERABUFFSIZ+1];
dylanembed123 7:c75d5e5e6bfc 61 uint16_t frameptr;
dylanembed123 7:c75d5e5e6bfc 62 public:
dylanembed123 7:c75d5e5e6bfc 63 /// \brief Call this function to get a hold of the serial for camera.
dylanembed123 7:c75d5e5e6bfc 64 static Serial& getSerial();
dylanembed123 7:c75d5e5e6bfc 65 /// \brief Reset the camera
dylanembed123 7:c75d5e5e6bfc 66 bool reset();
dylanembed123 7:c75d5e5e6bfc 67 /// \brief Get the camera version
dylanembed123 7:c75d5e5e6bfc 68 char * getVersion(void);
dylanembed123 7:c75d5e5e6bfc 69
dylanembed123 7:c75d5e5e6bfc 70 bool takePicture();
dylanembed123 14:6be57da62283 71 bool resumeVideo();
dylanembed123 7:c75d5e5e6bfc 72 bool cameraFrameBuffCtrl(uint8_t command);
dylanembed123 7:c75d5e5e6bfc 73 uint8_t* readPicture(uint8_t n,uint8_t* outSize=NULL);
dylanembed123 7:c75d5e5e6bfc 74 uint32_t frameLength(void);
dylanembed123 7:c75d5e5e6bfc 75 /// \brief Get the image Size
dylanembed123 7:c75d5e5e6bfc 76 uint8_t getImageSize();
dylanembed123 7:c75d5e5e6bfc 77 /// \brief Set the image Size
dylanembed123 7:c75d5e5e6bfc 78 bool setImageSize(uint8_t x);
dylanembed123 7:c75d5e5e6bfc 79 //
dylanembed123 7:c75d5e5e6bfc 80 // Low level commands
dylanembed123 7:c75d5e5e6bfc 81 //
dylanembed123 7:c75d5e5e6bfc 82 // Run a command
dylanembed123 7:c75d5e5e6bfc 83 bool runCommand(uint8_t cmd, uint8_t *args, uint8_t argn, uint8_t resplen, bool flushflag = true);
dylanembed123 7:c75d5e5e6bfc 84 // Output the buffer over the USB
dylanembed123 7:c75d5e5e6bfc 85 void printBuff();
dylanembed123 7:c75d5e5e6bfc 86 // Varify the response
dylanembed123 7:c75d5e5e6bfc 87 bool verifyResponse(uint8_t command);
dylanembed123 7:c75d5e5e6bfc 88 // Read the response
dylanembed123 7:c75d5e5e6bfc 89 uint8_t readResponse(uint8_t numbytes, uint8_t timeout);
dylanembed123 7:c75d5e5e6bfc 90 // Send the command
dylanembed123 7:c75d5e5e6bfc 91 void sendCommand(uint8_t cmd, uint8_t args[] = 0, uint8_t argn = 0);
dylanembed123 7:c75d5e5e6bfc 92 };