画像を2枚撮影

Committer:
yamaguch
Date:
Thu Nov 17 13:59:40 2011 +0000
Revision:
1:27417b6a951d
Parent:
0:974923b4db2d

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yamaguch 0:974923b4db2d 1 /* Arduino JPEGCamera Library
yamaguch 0:974923b4db2d 2 * Copyright 2010 SparkFun Electronics
yamaguch 0:974923b4db2d 3 * Written by Ryan Owens
yamaguch 0:974923b4db2d 4 * Modified by arms22
yamaguch 0:974923b4db2d 5 * Ported to mbed by yamaguch
yamaguch 0:974923b4db2d 6 */
yamaguch 0:974923b4db2d 7
yamaguch 0:974923b4db2d 8 #ifndef JPEG_CAMERA_H
yamaguch 0:974923b4db2d 9 #define JPEG_CAMERA_H
yamaguch 0:974923b4db2d 10
yamaguch 0:974923b4db2d 11 #include "mbed.h"
yamaguch 0:974923b4db2d 12
yamaguch 1:27417b6a951d 13 /**
yamaguch 0:974923b4db2d 14 * Interface for LinkSprite JPEG Camera module LS-Y201
yamaguch 0:974923b4db2d 15 */
yamaguch 0:974923b4db2d 16 class JPEGCamera : public Serial {
yamaguch 0:974923b4db2d 17 public:
yamaguch 0:974923b4db2d 18 /***/
yamaguch 0:974923b4db2d 19 enum PictureSize {
yamaguch 0:974923b4db2d 20 SIZE160x120 = 0x22,
yamaguch 0:974923b4db2d 21 SIZE320x240 = 0x11,
yamaguch 0:974923b4db2d 22 SIZE640x480 = 0x00,
yamaguch 0:974923b4db2d 23 };
yamaguch 0:974923b4db2d 24
yamaguch 0:974923b4db2d 25 /**
yamaguch 0:974923b4db2d 26 * Create JPEG Camera
yamaguch 0:974923b4db2d 27 *
yamaguch 0:974923b4db2d 28 * @param tx tx pin
yamaguch 0:974923b4db2d 29 * @param rx rx pin
yamaguch 0:974923b4db2d 30 */
yamaguch 0:974923b4db2d 31 JPEGCamera(PinName tx, PinName rx);
yamaguch 0:974923b4db2d 32
yamaguch 0:974923b4db2d 33 /**
yamaguch 0:974923b4db2d 34 * Set picture size
yamaguch 0:974923b4db2d 35 *
yamaguch 0:974923b4db2d 36 * @param size picture size (available sizes are SIZE160x120, SIZE320x240, SIZE640x480)
yamaguch 0:974923b4db2d 37 * @param doReset flag to perform reset operation after changing size
yamaguch 0:974923b4db2d 38 *
yamaguch 0:974923b4db2d 39 * @returns true if succeeded, false otherwise
yamaguch 0:974923b4db2d 40 */
yamaguch 0:974923b4db2d 41 bool setPictureSize(JPEGCamera::PictureSize size, bool doReset = true);
yamaguch 0:974923b4db2d 42
yamaguch 0:974923b4db2d 43 /**
yamaguch 0:974923b4db2d 44 * Return whether camera is ready or not
yamaguch 0:974923b4db2d 45 *
yamaguch 0:974923b4db2d 46 * @returns true if ready, false otherwise
yamaguch 0:974923b4db2d 47 */
yamaguch 0:974923b4db2d 48 bool isReady();
yamaguch 0:974923b4db2d 49
yamaguch 0:974923b4db2d 50 /**
yamaguch 0:974923b4db2d 51 * Return whether camera is processing the taken picture or not
yamaguch 0:974923b4db2d 52 *
yamaguch 0:974923b4db2d 53 * @returns true if the camera is in processing, false otherwise
yamaguch 0:974923b4db2d 54 */
yamaguch 0:974923b4db2d 55 bool isProcessing();
yamaguch 0:974923b4db2d 56
yamaguch 0:974923b4db2d 57 /**
yamaguch 0:974923b4db2d 58 * Take a picture
yamaguch 0:974923b4db2d 59 *
yamaguch 0:974923b4db2d 60 * @param filename filename to store the picture data
yamaguch 0:974923b4db2d 61 * @returns true if succeeded, false otherwise
yamaguch 0:974923b4db2d 62 */
yamaguch 0:974923b4db2d 63 bool takePicture(char *filename);
yamaguch 0:974923b4db2d 64 /**
yamaguch 0:974923b4db2d 65 * Process picture (writing the file)
yamaguch 0:974923b4db2d 66 *
yamaguch 0:974923b4db2d 67 * @returns true if no error in processing, false otherwise
yamaguch 0:974923b4db2d 68 */
yamaguch 0:974923b4db2d 69 bool processPicture();
yamaguch 0:974923b4db2d 70
yamaguch 0:974923b4db2d 71 /**
yamaguch 0:974923b4db2d 72 * Perform reset oepration (it takes 4 seconds)
yamaguch 0:974923b4db2d 73 *
yamaguch 0:974923b4db2d 74 * @returns true if succeeded, false otherwise
yamaguch 0:974923b4db2d 75 */
yamaguch 0:974923b4db2d 76 bool reset();
yamaguch 0:974923b4db2d 77
yamaguch 0:974923b4db2d 78 /**
yamaguch 0:974923b4db2d 79 * Send a picture command to the camera module
yamaguch 0:974923b4db2d 80 *
yamaguch 0:974923b4db2d 81 * @returns true if succeeded, false otherwise
yamaguch 0:974923b4db2d 82 */
yamaguch 0:974923b4db2d 83 bool takePicture(void);
yamaguch 0:974923b4db2d 84
yamaguch 0:974923b4db2d 85 /**
yamaguch 0:974923b4db2d 86 * Send a stop pictures command to the camera module
yamaguch 0:974923b4db2d 87 *
yamaguch 0:974923b4db2d 88 * @returns true if succeeded, false otherwise
yamaguch 0:974923b4db2d 89 */
yamaguch 0:974923b4db2d 90 bool stopPictures(void);
yamaguch 0:974923b4db2d 91
yamaguch 0:974923b4db2d 92 /**
yamaguch 0:974923b4db2d 93 * Get the picture image size
yamaguch 0:974923b4db2d 94 *
yamaguch 0:974923b4db2d 95 * @returns the actual image size in bytes
yamaguch 0:974923b4db2d 96 */
yamaguch 0:974923b4db2d 97 int getImageSize();
yamaguch 0:974923b4db2d 98
yamaguch 0:974923b4db2d 99 /**
yamaguch 0:974923b4db2d 100 * Read the picture data to the buffer
yamaguch 0:974923b4db2d 101 *
yamaguch 0:974923b4db2d 102 * @param dataBuf data buffer address to store the received data
yamaguch 0:974923b4db2d 103 * @param size data size to read
yamaguch 0:974923b4db2d 104 * @param address the address of the picture data to read
yamaguch 0:974923b4db2d 105 *
yamaguch 0:974923b4db2d 106 * @returns the size of the data read
yamaguch 0:974923b4db2d 107 */
yamaguch 0:974923b4db2d 108 int readData(char *dataBuf, int size, int address);
yamaguch 0:974923b4db2d 109
yamaguch 0:974923b4db2d 110 //private:
yamaguch 0:974923b4db2d 111 Timer timer;
yamaguch 0:974923b4db2d 112 FILE *fp;
yamaguch 0:974923b4db2d 113 int imageSize;
yamaguch 0:974923b4db2d 114 int address;
yamaguch 0:974923b4db2d 115 enum State {UNKNOWN, READY, PROCESSING, ERROR = -1} state;
yamaguch 0:974923b4db2d 116
yamaguch 0:974923b4db2d 117 int sendReceive(char *buf, int sendSize, int receiveSize);
yamaguch 0:974923b4db2d 118 int receive(char *buf, int size, int timeout);
yamaguch 0:974923b4db2d 119 };
yamaguch 0:974923b4db2d 120
yamaguch 0:974923b4db2d 121 #endif