Library for LinkSprite Y201 JPEG serial camera.

Y201.h

Committer:
ashleymills
Date:
2012-07-19
Revision:
6:d8f5f576712b
Parent:
3:decf96d8e6b0

File content as of revision 6:d8f5f576712b:

#include "mbed.h"
#define MODSERIAL_DEFAULT_RX_BUFFER_SIZE 1024
#define MODSERIAL_DEFAULT_TX_BUFFER_SIZE 64
#include "MODSERIAL.h"
#pragma once

class Y201 : MODSERIAL {

private:

    // serial commands to drive camera
    static const int resetSeq        [4];
    static const int resetSeqLen        = 4;
    static const int resetSeqAck     [4];
    static const int resetSeqAckLen     = 4;
    static const int takePicSeq      [5];
    static const int takePicSeqLen      = 5;
    static const int takePicSeqAck   [5];
    static const int takePicSeqAckLen   = 5;
    static const int set160x120      [9];
    static const int set320x240      [9];
    static const int set640x480      [9];
    static const int setSizeLen         = 9;
    static const int setSizeAck      [5];
    static const int setSizeAckLen      = 5;
    static const int readFileSize    [5];
    static const int readFileSizeLen    = 5;
    static const int readFileSizeAck [7];
    static const int readFileSizeAckLen = 7;
    static const int readFileHead    [8];
    static const int readFileHeadLen    = 8;
    static const int readFileAck     [5];
    static const int readFileAckLen     = 5;
    
public:
    
    enum Y201ImageSize {
        e160x120,
        e320x240,
        e640x480
    };

    Y201(PinName tx, PinName rx, const char *name = NULL);

    bool setImageSize(Y201ImageSize size);
    bool takePicture();
    bool readImageSize(int *fileSize);
    bool readImage(int startAddress, int readLen, uint8_t *readBuffer);
    void trash();
    
    bool waitForInt(int bytes, int *fileSize);
    bool waitFor(const int *seq, const int seqLen);
    void putSeq(const int *seq, int seqLen);
    bool reset();

};