cansat_B 2019 / Mbed 2 deprecated tougou1

Dependencies:   mbed

Committer:
KINU
Date:
Fri Nov 15 14:02:01 2019 +0000
Revision:
0:f728b8e6bdf2
us015sb612Camera

Who changed what in which revision?

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