CameraC328
Dependents: CameraC328_TestProgram CameraC328_Thresholding Camera_TestProgram_2015 Camera_TestProgram_2015 ... more
Diff: CameraC328.h
- Revision:
- 0:7e51c3176eb7
- Child:
- 1:167e51d598cf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CameraC328.h Sun Jun 27 03:36:10 2010 +0000 @@ -0,0 +1,127 @@ +#include "mbed.h" + +class CameraC328 { +public: + + CameraC328(PinName tx, PinName rx); + + ~CameraC328(); + + enum ColorType { + GrayScale2bit = 0x01, // 2bit for Y only + GrayScale4bit = 0x02, // 4bit for Y only + GrayScale8bit = 0x03, // 8bit for Y only + Color12bit = 0x05, // 444 (RGB) + Color16bit = 0x06, // 565 (RGB) + Jpeg = 0x07 + }; + + enum RawResolution { + RawResolution80x60 = 0x01, + RawResolution160x120 = 0x03 + }; + + enum JpegResolution { + JpegResolution80x64 = 0x01, + JpegResolution160x128 = 0x03, + JpegResolution320x240 = 0x05, + JpegResolution640x480 = 0x07 + }; + + enum ErrorNumber { + NoError = 0x00, + PictureTypeError = 0x01, + PictureUpScale = 0x02, + PictureScaleError = 0x03, + UnexpectedReply = 0x04, + SendPictureTimeout = 0x05, + UnexpectedCommand = 0x06, + SramJpegTypeError = 0x07, + SramJpegSizeError = 0x08, + PictureFormatError = 0x09, + PictureSizeError = 0x0a, + ParameterError = 0x0b, + SendRegisterTimeout = 0x0c, + CommandIdError = 0x0d, + PictureNotReady = 0x0f, + TransferPackageNumberError = 0x10, + SetTransferPackageSizeWrong = 0x11, + CommandHeaderError = 0xf0, + CommandLengthError = 0xf1, + SendPictureError = 0xf5, + SendCommandError = 0xff + }; + + enum PictureType { + SnapshotPicture = 0x01, + PreviewPicture = 0x02, + JpegPreviewPicture = 0x05 + }; + + ErrorNumber sync(); + ErrorNumber getPicture(PictureType pt, void(*func)(size_t done, size_t total, char c)); + ErrorNumber init(ColorType ct, RawResolution rr, JpegResolution jr); + +private: + Serial serial; + static const int COMMAND_LENGTH = 6; + static const int TIMEOUT_MS = 200; + static const int BAUD = 19600; + static const int SYNCMAX = 60; + + /* + * Get snapshot picture (uncompressed snapshot picture) + * + * @param func Pointer to a callback function. + * @return Status of the error. + */ + ErrorNumber getSnapshotPicture(void(*func)(size_t done, size_t total, char c)); + + /* + * Get preview picture (uncompressed preview picture) + * + * @param func Pointer to a callback function. + * @return Status of the error. + */ + ErrorNumber getPreviewPicture(void(*func)(size_t done, size_t total, char c)); + + /** + * Send bytes to camera module. + * + * @param buf Pointer to the data buffer. + * @param len Length of the data buffer. + * + * @return True if the data sended. + */ + bool sendBytes(char *buf, size_t len); + + /** + * Receive bytes from camera module. + * + * @param buf Pointer to the data buffer. + * @param len Length of the data buffer. + * + * @return True if the data received. + */ + bool recvBytes(char *buf, size_t len); + + /** + * Send bytes to camera module. + * + * @param buf Pointer to the data buffer. + * @param len Length of the data buffer. + * + * @return True if the data sended. + */ + bool sendBytesWithDebugOutput(char *buf, size_t len); + + /** + * Receive bytes from camera module. + * + * @param buf Pointer to the data buffer. + * @param len Length of the data buffer. + * + * @return True if the data received. + */ + bool recvBytesWithDebugOutput(char *buf, size_t len); +};