CameraC328
Dependents: CameraC328_TestProgram CameraC328_Thresholding Camera_TestProgram_2015 Camera_TestProgram_2015 ... more
CameraC328.h@0:7e51c3176eb7, 2010-06-27 (annotated)
- Committer:
- shintamainjp
- Date:
- Sun Jun 27 03:36:10 2010 +0000
- Revision:
- 0:7e51c3176eb7
- Child:
- 1:167e51d598cf
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shintamainjp | 0:7e51c3176eb7 | 1 | #include "mbed.h" |
shintamainjp | 0:7e51c3176eb7 | 2 | |
shintamainjp | 0:7e51c3176eb7 | 3 | class CameraC328 { |
shintamainjp | 0:7e51c3176eb7 | 4 | public: |
shintamainjp | 0:7e51c3176eb7 | 5 | |
shintamainjp | 0:7e51c3176eb7 | 6 | CameraC328(PinName tx, PinName rx); |
shintamainjp | 0:7e51c3176eb7 | 7 | |
shintamainjp | 0:7e51c3176eb7 | 8 | ~CameraC328(); |
shintamainjp | 0:7e51c3176eb7 | 9 | |
shintamainjp | 0:7e51c3176eb7 | 10 | enum ColorType { |
shintamainjp | 0:7e51c3176eb7 | 11 | GrayScale2bit = 0x01, // 2bit for Y only |
shintamainjp | 0:7e51c3176eb7 | 12 | GrayScale4bit = 0x02, // 4bit for Y only |
shintamainjp | 0:7e51c3176eb7 | 13 | GrayScale8bit = 0x03, // 8bit for Y only |
shintamainjp | 0:7e51c3176eb7 | 14 | Color12bit = 0x05, // 444 (RGB) |
shintamainjp | 0:7e51c3176eb7 | 15 | Color16bit = 0x06, // 565 (RGB) |
shintamainjp | 0:7e51c3176eb7 | 16 | Jpeg = 0x07 |
shintamainjp | 0:7e51c3176eb7 | 17 | }; |
shintamainjp | 0:7e51c3176eb7 | 18 | |
shintamainjp | 0:7e51c3176eb7 | 19 | enum RawResolution { |
shintamainjp | 0:7e51c3176eb7 | 20 | RawResolution80x60 = 0x01, |
shintamainjp | 0:7e51c3176eb7 | 21 | RawResolution160x120 = 0x03 |
shintamainjp | 0:7e51c3176eb7 | 22 | }; |
shintamainjp | 0:7e51c3176eb7 | 23 | |
shintamainjp | 0:7e51c3176eb7 | 24 | enum JpegResolution { |
shintamainjp | 0:7e51c3176eb7 | 25 | JpegResolution80x64 = 0x01, |
shintamainjp | 0:7e51c3176eb7 | 26 | JpegResolution160x128 = 0x03, |
shintamainjp | 0:7e51c3176eb7 | 27 | JpegResolution320x240 = 0x05, |
shintamainjp | 0:7e51c3176eb7 | 28 | JpegResolution640x480 = 0x07 |
shintamainjp | 0:7e51c3176eb7 | 29 | }; |
shintamainjp | 0:7e51c3176eb7 | 30 | |
shintamainjp | 0:7e51c3176eb7 | 31 | enum ErrorNumber { |
shintamainjp | 0:7e51c3176eb7 | 32 | NoError = 0x00, |
shintamainjp | 0:7e51c3176eb7 | 33 | PictureTypeError = 0x01, |
shintamainjp | 0:7e51c3176eb7 | 34 | PictureUpScale = 0x02, |
shintamainjp | 0:7e51c3176eb7 | 35 | PictureScaleError = 0x03, |
shintamainjp | 0:7e51c3176eb7 | 36 | UnexpectedReply = 0x04, |
shintamainjp | 0:7e51c3176eb7 | 37 | SendPictureTimeout = 0x05, |
shintamainjp | 0:7e51c3176eb7 | 38 | UnexpectedCommand = 0x06, |
shintamainjp | 0:7e51c3176eb7 | 39 | SramJpegTypeError = 0x07, |
shintamainjp | 0:7e51c3176eb7 | 40 | SramJpegSizeError = 0x08, |
shintamainjp | 0:7e51c3176eb7 | 41 | PictureFormatError = 0x09, |
shintamainjp | 0:7e51c3176eb7 | 42 | PictureSizeError = 0x0a, |
shintamainjp | 0:7e51c3176eb7 | 43 | ParameterError = 0x0b, |
shintamainjp | 0:7e51c3176eb7 | 44 | SendRegisterTimeout = 0x0c, |
shintamainjp | 0:7e51c3176eb7 | 45 | CommandIdError = 0x0d, |
shintamainjp | 0:7e51c3176eb7 | 46 | PictureNotReady = 0x0f, |
shintamainjp | 0:7e51c3176eb7 | 47 | TransferPackageNumberError = 0x10, |
shintamainjp | 0:7e51c3176eb7 | 48 | SetTransferPackageSizeWrong = 0x11, |
shintamainjp | 0:7e51c3176eb7 | 49 | CommandHeaderError = 0xf0, |
shintamainjp | 0:7e51c3176eb7 | 50 | CommandLengthError = 0xf1, |
shintamainjp | 0:7e51c3176eb7 | 51 | SendPictureError = 0xf5, |
shintamainjp | 0:7e51c3176eb7 | 52 | SendCommandError = 0xff |
shintamainjp | 0:7e51c3176eb7 | 53 | }; |
shintamainjp | 0:7e51c3176eb7 | 54 | |
shintamainjp | 0:7e51c3176eb7 | 55 | enum PictureType { |
shintamainjp | 0:7e51c3176eb7 | 56 | SnapshotPicture = 0x01, |
shintamainjp | 0:7e51c3176eb7 | 57 | PreviewPicture = 0x02, |
shintamainjp | 0:7e51c3176eb7 | 58 | JpegPreviewPicture = 0x05 |
shintamainjp | 0:7e51c3176eb7 | 59 | }; |
shintamainjp | 0:7e51c3176eb7 | 60 | |
shintamainjp | 0:7e51c3176eb7 | 61 | ErrorNumber sync(); |
shintamainjp | 0:7e51c3176eb7 | 62 | ErrorNumber getPicture(PictureType pt, void(*func)(size_t done, size_t total, char c)); |
shintamainjp | 0:7e51c3176eb7 | 63 | ErrorNumber init(ColorType ct, RawResolution rr, JpegResolution jr); |
shintamainjp | 0:7e51c3176eb7 | 64 | |
shintamainjp | 0:7e51c3176eb7 | 65 | private: |
shintamainjp | 0:7e51c3176eb7 | 66 | Serial serial; |
shintamainjp | 0:7e51c3176eb7 | 67 | static const int COMMAND_LENGTH = 6; |
shintamainjp | 0:7e51c3176eb7 | 68 | static const int TIMEOUT_MS = 200; |
shintamainjp | 0:7e51c3176eb7 | 69 | static const int BAUD = 19600; |
shintamainjp | 0:7e51c3176eb7 | 70 | static const int SYNCMAX = 60; |
shintamainjp | 0:7e51c3176eb7 | 71 | |
shintamainjp | 0:7e51c3176eb7 | 72 | /* |
shintamainjp | 0:7e51c3176eb7 | 73 | * Get snapshot picture (uncompressed snapshot picture) |
shintamainjp | 0:7e51c3176eb7 | 74 | * |
shintamainjp | 0:7e51c3176eb7 | 75 | * @param func Pointer to a callback function. |
shintamainjp | 0:7e51c3176eb7 | 76 | * @return Status of the error. |
shintamainjp | 0:7e51c3176eb7 | 77 | */ |
shintamainjp | 0:7e51c3176eb7 | 78 | ErrorNumber getSnapshotPicture(void(*func)(size_t done, size_t total, char c)); |
shintamainjp | 0:7e51c3176eb7 | 79 | |
shintamainjp | 0:7e51c3176eb7 | 80 | /* |
shintamainjp | 0:7e51c3176eb7 | 81 | * Get preview picture (uncompressed preview picture) |
shintamainjp | 0:7e51c3176eb7 | 82 | * |
shintamainjp | 0:7e51c3176eb7 | 83 | * @param func Pointer to a callback function. |
shintamainjp | 0:7e51c3176eb7 | 84 | * @return Status of the error. |
shintamainjp | 0:7e51c3176eb7 | 85 | */ |
shintamainjp | 0:7e51c3176eb7 | 86 | ErrorNumber getPreviewPicture(void(*func)(size_t done, size_t total, char c)); |
shintamainjp | 0:7e51c3176eb7 | 87 | |
shintamainjp | 0:7e51c3176eb7 | 88 | /** |
shintamainjp | 0:7e51c3176eb7 | 89 | * Send bytes to camera module. |
shintamainjp | 0:7e51c3176eb7 | 90 | * |
shintamainjp | 0:7e51c3176eb7 | 91 | * @param buf Pointer to the data buffer. |
shintamainjp | 0:7e51c3176eb7 | 92 | * @param len Length of the data buffer. |
shintamainjp | 0:7e51c3176eb7 | 93 | * |
shintamainjp | 0:7e51c3176eb7 | 94 | * @return True if the data sended. |
shintamainjp | 0:7e51c3176eb7 | 95 | */ |
shintamainjp | 0:7e51c3176eb7 | 96 | bool sendBytes(char *buf, size_t len); |
shintamainjp | 0:7e51c3176eb7 | 97 | |
shintamainjp | 0:7e51c3176eb7 | 98 | /** |
shintamainjp | 0:7e51c3176eb7 | 99 | * Receive bytes from camera module. |
shintamainjp | 0:7e51c3176eb7 | 100 | * |
shintamainjp | 0:7e51c3176eb7 | 101 | * @param buf Pointer to the data buffer. |
shintamainjp | 0:7e51c3176eb7 | 102 | * @param len Length of the data buffer. |
shintamainjp | 0:7e51c3176eb7 | 103 | * |
shintamainjp | 0:7e51c3176eb7 | 104 | * @return True if the data received. |
shintamainjp | 0:7e51c3176eb7 | 105 | */ |
shintamainjp | 0:7e51c3176eb7 | 106 | bool recvBytes(char *buf, size_t len); |
shintamainjp | 0:7e51c3176eb7 | 107 | |
shintamainjp | 0:7e51c3176eb7 | 108 | /** |
shintamainjp | 0:7e51c3176eb7 | 109 | * Send bytes to camera module. |
shintamainjp | 0:7e51c3176eb7 | 110 | * |
shintamainjp | 0:7e51c3176eb7 | 111 | * @param buf Pointer to the data buffer. |
shintamainjp | 0:7e51c3176eb7 | 112 | * @param len Length of the data buffer. |
shintamainjp | 0:7e51c3176eb7 | 113 | * |
shintamainjp | 0:7e51c3176eb7 | 114 | * @return True if the data sended. |
shintamainjp | 0:7e51c3176eb7 | 115 | */ |
shintamainjp | 0:7e51c3176eb7 | 116 | bool sendBytesWithDebugOutput(char *buf, size_t len); |
shintamainjp | 0:7e51c3176eb7 | 117 | |
shintamainjp | 0:7e51c3176eb7 | 118 | /** |
shintamainjp | 0:7e51c3176eb7 | 119 | * Receive bytes from camera module. |
shintamainjp | 0:7e51c3176eb7 | 120 | * |
shintamainjp | 0:7e51c3176eb7 | 121 | * @param buf Pointer to the data buffer. |
shintamainjp | 0:7e51c3176eb7 | 122 | * @param len Length of the data buffer. |
shintamainjp | 0:7e51c3176eb7 | 123 | * |
shintamainjp | 0:7e51c3176eb7 | 124 | * @return True if the data received. |
shintamainjp | 0:7e51c3176eb7 | 125 | */ |
shintamainjp | 0:7e51c3176eb7 | 126 | bool recvBytesWithDebugOutput(char *buf, size_t len); |
shintamainjp | 0:7e51c3176eb7 | 127 | }; |