CANSAT_CAMERA
Dependents: CANSAT_COMBINED CANSAT_CAMERA_servo CANSAT_CAMERA2
Fork of Camera_LS_Y201 by
Camera_LS_Y201.h
- Committer:
- Hagrass
- Date:
- 2015-09-09
- Revision:
- 6:2e14476d7164
- Parent:
- 1:43358d40f879
File content as of revision 6:2e14476d7164:
/** * ============================================================================= * LS-Y201 device driver class (Version 0.0.1) * Reference documents: LinkSprite JPEG Color Camera Serial UART Interface * January 2010 * ============================================================================= * Copyright (c) 2010 Shinichiro Nakamura (CuBeatSystems) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * ============================================================================= */ #ifndef LS_Y201_H #define LS_Y201_H #include "mbed.h" #include "SerialBuffered.h" /** * Camera */ class Camera_LS_Y201 { public: /** * Create. * * @param tx Transmitter. * @param rx Receiver. */ Camera_LS_Y201(PinName tx, PinName rx); /** * Dispose. */ ~Camera_LS_Y201(); /** * Error code. */ enum ErrorCode { NoError = 0, UnexpectedReply, Timeout, SendError, RecvError, InvalidArguments }; /** * Image size. */ enum ImageSize { ImageSize160x120, /**< 160x120. */ ImageSize320x280, /**< 320x280. */ ImageSize640x480 /**< 640x480. */ }; /** * Reset module. * * @return Error code. */ ErrorCode reset(); ErrorCode baud(); /** * Set image size. * * @param is Image size. * @return Error code. */ ErrorCode setImageSize(ImageSize is); /** * Take picture. * * @return Error code. */ ErrorCode takePicture(); /** * Read jpeg file size. * * @param fileSize File size. * @return Error code. */ ErrorCode readJpegFileSize(int *fileSize); /** * Read jpeg file content. * * @param func A pointer to a call back function. * @return Error code. */ ErrorCode readJpegFileContent(void (*func)(int done, int total, uint8_t *buf, size_t siz)); /** * Stop taking pictures. * * @return Error code. */ ErrorCode stopTakingPictures(); bool sendBytes(uint8_t *buf, size_t len, int timeout_us); /** * 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(uint8_t *buf, size_t len, int timeout_us); private: SerialBuffered serial; /** * Wait init end codes. * * @return Error code. */ ErrorCode waitInitEnd(); /** * 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. */ /** * Wait received. * * @return True if the data received. */ bool waitRecv(); /** * Wait idle state. * * @return True if it succeed. */ bool waitIdle(); }; #endif