CameraC328

Dependents:   CameraC328_TestProgram CameraC328_Thresholding Camera_TestProgram_2015 Camera_TestProgram_2015 ... more

Committer:
shintamainjp
Date:
Mon Jun 28 13:57:15 2010 +0000
Revision:
2:6a72fcad5c0a
Parent:
1:167e51d598cf
Child:
3:6d3150d4396a

        

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 2:6a72fcad5c0a 72 bool syncdone;
shintamainjp 0:7e51c3176eb7 73 static const int COMMAND_LENGTH = 6;
shintamainjp 2:6a72fcad5c0a 74 static const int TIMEOUT_US = 1200;
shintamainjp 2:6a72fcad5c0a 75 static const int BAUD = 57600;
shintamainjp 0:7e51c3176eb7 76 static const int SYNCMAX = 60;
shintamainjp 0:7e51c3176eb7 77
shintamainjp 0:7e51c3176eb7 78 /**
shintamainjp 0:7e51c3176eb7 79 * Send bytes to camera module.
shintamainjp 0:7e51c3176eb7 80 *
shintamainjp 0:7e51c3176eb7 81 * @param buf Pointer to the data buffer.
shintamainjp 0:7e51c3176eb7 82 * @param len Length of the data buffer.
shintamainjp 0:7e51c3176eb7 83 *
shintamainjp 0:7e51c3176eb7 84 * @return True if the data sended.
shintamainjp 0:7e51c3176eb7 85 */
shintamainjp 0:7e51c3176eb7 86 bool sendBytes(char *buf, size_t len);
shintamainjp 0:7e51c3176eb7 87
shintamainjp 0:7e51c3176eb7 88 /**
shintamainjp 0:7e51c3176eb7 89 * Receive bytes from 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 received.
shintamainjp 0:7e51c3176eb7 95 */
shintamainjp 0:7e51c3176eb7 96 bool recvBytes(char *buf, size_t len);
shintamainjp 0:7e51c3176eb7 97
shintamainjp 0:7e51c3176eb7 98 /**
shintamainjp 0:7e51c3176eb7 99 * Send bytes to 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 sended.
shintamainjp 0:7e51c3176eb7 105 */
shintamainjp 0:7e51c3176eb7 106 bool sendBytesWithDebugOutput(char *buf, size_t len);
shintamainjp 0:7e51c3176eb7 107
shintamainjp 0:7e51c3176eb7 108 /**
shintamainjp 0:7e51c3176eb7 109 * Receive bytes from 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 received.
shintamainjp 0:7e51c3176eb7 115 */
shintamainjp 0:7e51c3176eb7 116 bool recvBytesWithDebugOutput(char *buf, size_t len);
shintamainjp 0:7e51c3176eb7 117 };