removed wait with timer
Dependents: Gaurd_Server2 Gaurd_Server
Fork of JPEGCamera by
JPEGCamera.h
00001 /* Arduino JPEGCamera Library 00002 * Copyright 2010 SparkFun Electronics 00003 * Written by Ryan Owens 00004 * Modified by arms22 00005 * Ported to mbed by yamaguch 00006 */ 00007 00008 #ifndef JPEG_CAMERA_H 00009 #define JPEG_CAMERA_H 00010 00011 #include "mbed.h" 00012 00013 /** 00014 * Interface for LinkSprite JPEG Camera module LS-Y201 00015 */ 00016 class JPEGCamera : public Serial { 00017 public: 00018 /***/ 00019 enum PictureSize { 00020 SIZE160x120 = 0x22, 00021 SIZE320x240 = 0x11, 00022 SIZE640x480 = 0x00, 00023 }; 00024 00025 /** 00026 * Create JPEG Camera 00027 * 00028 * @param tx tx pin 00029 * @param rx rx pin 00030 */ 00031 JPEGCamera(PinName tx, PinName rx); 00032 00033 00034 /** 00035 * Set picture size 00036 * 00037 * @param size picture size (available sizes are SIZE160x120, SIZE320x240, SIZE640x480) 00038 * @param doReset flag to perform reset operation after changing size 00039 * 00040 * @returns true if succeeded, false otherwise 00041 */ 00042 bool setPictureSize(JPEGCamera::PictureSize size, bool doReset = true); 00043 00044 /** 00045 * Return whether camera is ready or not 00046 * 00047 * @returns true if ready, false otherwise 00048 */ 00049 bool isReady(); 00050 00051 /** 00052 * Return whether camera is processing the taken picture or not 00053 * 00054 * @returns true if the camera is in processing, false otherwise 00055 */ 00056 bool isProcessing(); 00057 00058 /** 00059 * Take a picture 00060 * 00061 * @param filename filename to store the picture data 00062 * @returns true if succeeded, false otherwise 00063 */ 00064 bool takePicture(char *filename); 00065 /** 00066 * Process picture (writing the file) 00067 * 00068 * @returns true if no error in processing, false otherwise 00069 */ 00070 bool processPicture(); 00071 00072 /** 00073 * Perform reset oepration (it takes 4 seconds) 00074 * 00075 * @returns true if succeeded, false otherwise 00076 */ 00077 bool reset(); 00078 00079 /** 00080 * Send a picture command to the camera module 00081 * 00082 * @returns true if succeeded, false otherwise 00083 */ 00084 bool takePicture(void); 00085 00086 /** 00087 * Send a stop pictures command to the camera module 00088 * 00089 * @returns true if succeeded, false otherwise 00090 */ 00091 bool stopPictures(void); 00092 00093 /** 00094 * Get the picture image size 00095 * 00096 * @returns the actual image size in bytes 00097 */ 00098 int getImageSize(); 00099 00100 /** 00101 * Read the picture data to the buffer 00102 * 00103 * @param dataBuf data buffer address to store the received data 00104 * @param size data size to read 00105 * @param address the address of the picture data to read 00106 * 00107 * @returns the size of the data read 00108 */ 00109 int readData(char *dataBuf, int size, int address); 00110 00111 //private: 00112 Timer timer; 00113 FILE *fp; 00114 int imageSize; 00115 int address; 00116 enum State {UNKNOWN, READY, PROCESSING, ERROR = -1} state; 00117 00118 int sendReceive(char *buf, int sendSize, int receiveSize); 00119 int receive(char *buf, int size, int timeout); 00120 }; 00121 00122 #endif
Generated on Thu Jul 14 2022 01:41:02 by 1.7.2