WIP for dgps

Dependencies:   mbed

Committer:
dylanembed123
Date:
Thu Apr 03 16:27:23 2014 +0000
Revision:
6:f0248eb6714d
Parent:
4:c75d5e5e6bfc
Fix compile errors;

Who changed what in which revision?

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