CameraC328

Dependents:   CameraC328_TestProgram CameraC328_Thresholding Camera_TestProgram_2015 Camera_TestProgram_2015 ... more

Committer:
shintamainjp
Date:
Sun Jun 27 05:04:04 2010 +0000
Revision:
1:167e51d598cf
Parent:
0:7e51c3176eb7
Child:
2:6a72fcad5c0a

        

Who changed what in which revision?

UserRevisionLine numberNew 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 1:167e51d598cf 54
shintamainjp 1:167e51d598cf 55 enum SnapshotType {
shintamainjp 1:167e51d598cf 56 CompressedPicture = 0x00,
shintamainjp 1:167e51d598cf 57 UncompressedPicture = 0x01
shintamainjp 1:167e51d598cf 58 };
shintamainjp 0:7e51c3176eb7 59
shintamainjp 0:7e51c3176eb7 60 enum PictureType {
shintamainjp 0:7e51c3176eb7 61 SnapshotPicture = 0x01,
shintamainjp 0:7e51c3176eb7 62 PreviewPicture = 0x02,
shintamainjp 0:7e51c3176eb7 63 JpegPreviewPicture = 0x05
shintamainjp 0:7e51c3176eb7 64 };
shintamainjp 0:7e51c3176eb7 65
shintamainjp 0:7e51c3176eb7 66 ErrorNumber sync();
shintamainjp 0:7e51c3176eb7 67 ErrorNumber init(ColorType ct, RawResolution rr, JpegResolution jr);
shintamainjp 1:167e51d598cf 68 ErrorNumber getJpegSnapshotPicture(void(*func)(size_t done, size_t total, char c));
shintamainjp 0:7e51c3176eb7 69
shintamainjp 0:7e51c3176eb7 70 private:
shintamainjp 0:7e51c3176eb7 71 Serial serial;
shintamainjp 0:7e51c3176eb7 72 static const int COMMAND_LENGTH = 6;
shintamainjp 0:7e51c3176eb7 73 static const int TIMEOUT_MS = 200;
shintamainjp 0:7e51c3176eb7 74 static const int BAUD = 19600;
shintamainjp 0:7e51c3176eb7 75 static const int SYNCMAX = 60;
shintamainjp 0:7e51c3176eb7 76
shintamainjp 0:7e51c3176eb7 77 /**
shintamainjp 0:7e51c3176eb7 78 * Send bytes to camera module.
shintamainjp 0:7e51c3176eb7 79 *
shintamainjp 0:7e51c3176eb7 80 * @param buf Pointer to the data buffer.
shintamainjp 0:7e51c3176eb7 81 * @param len Length of the data buffer.
shintamainjp 0:7e51c3176eb7 82 *
shintamainjp 0:7e51c3176eb7 83 * @return True if the data sended.
shintamainjp 0:7e51c3176eb7 84 */
shintamainjp 0:7e51c3176eb7 85 bool sendBytes(char *buf, size_t len);
shintamainjp 0:7e51c3176eb7 86
shintamainjp 0:7e51c3176eb7 87 /**
shintamainjp 0:7e51c3176eb7 88 * Receive bytes from camera module.
shintamainjp 0:7e51c3176eb7 89 *
shintamainjp 0:7e51c3176eb7 90 * @param buf Pointer to the data buffer.
shintamainjp 0:7e51c3176eb7 91 * @param len Length of the data buffer.
shintamainjp 0:7e51c3176eb7 92 *
shintamainjp 0:7e51c3176eb7 93 * @return True if the data received.
shintamainjp 0:7e51c3176eb7 94 */
shintamainjp 0:7e51c3176eb7 95 bool recvBytes(char *buf, size_t len);
shintamainjp 0:7e51c3176eb7 96
shintamainjp 0:7e51c3176eb7 97 /**
shintamainjp 0:7e51c3176eb7 98 * Send bytes to camera module.
shintamainjp 0:7e51c3176eb7 99 *
shintamainjp 0:7e51c3176eb7 100 * @param buf Pointer to the data buffer.
shintamainjp 0:7e51c3176eb7 101 * @param len Length of the data buffer.
shintamainjp 0:7e51c3176eb7 102 *
shintamainjp 0:7e51c3176eb7 103 * @return True if the data sended.
shintamainjp 0:7e51c3176eb7 104 */
shintamainjp 0:7e51c3176eb7 105 bool sendBytesWithDebugOutput(char *buf, size_t len);
shintamainjp 0:7e51c3176eb7 106
shintamainjp 0:7e51c3176eb7 107 /**
shintamainjp 0:7e51c3176eb7 108 * Receive bytes from camera module.
shintamainjp 0:7e51c3176eb7 109 *
shintamainjp 0:7e51c3176eb7 110 * @param buf Pointer to the data buffer.
shintamainjp 0:7e51c3176eb7 111 * @param len Length of the data buffer.
shintamainjp 0:7e51c3176eb7 112 *
shintamainjp 0:7e51c3176eb7 113 * @return True if the data received.
shintamainjp 0:7e51c3176eb7 114 */
shintamainjp 0:7e51c3176eb7 115 bool recvBytesWithDebugOutput(char *buf, size_t len);
shintamainjp 0:7e51c3176eb7 116 };