Smart coffee machine with facial recognition and remote control
Dependencies: Camera_LS_Y201 EthernetInterface EthernetNetIf HTTPClient SRF05 TextLCD mbed-rtos mbed-src
Camera_LS_Y201_RTOS/Camera_LS_Y201.h@0:43669f623d43, 2014-01-15 (annotated)
- Committer:
- projetmacintel
- Date:
- Wed Jan 15 11:09:52 2014 +0000
- Revision:
- 0:43669f623d43
dep?t final PAO Macintel
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
projetmacintel | 0:43669f623d43 | 1 | /** |
projetmacintel | 0:43669f623d43 | 2 | * ============================================================================= |
projetmacintel | 0:43669f623d43 | 3 | * LS-Y201 device driver class (Version 0.0.1) |
projetmacintel | 0:43669f623d43 | 4 | * Reference documents: LinkSprite JPEG Color Camera Serial UART Interface |
projetmacintel | 0:43669f623d43 | 5 | * January 2010 |
projetmacintel | 0:43669f623d43 | 6 | * ============================================================================= |
projetmacintel | 0:43669f623d43 | 7 | * Copyright (c) 2010 Shinichiro Nakamura (CuBeatSystems) |
projetmacintel | 0:43669f623d43 | 8 | * |
projetmacintel | 0:43669f623d43 | 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
projetmacintel | 0:43669f623d43 | 10 | * of this software and associated documentation files (the "Software"), to deal |
projetmacintel | 0:43669f623d43 | 11 | * in the Software without restriction, including without limitation the rights |
projetmacintel | 0:43669f623d43 | 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
projetmacintel | 0:43669f623d43 | 13 | * copies of the Software, and to permit persons to whom the Software is |
projetmacintel | 0:43669f623d43 | 14 | * furnished to do so, subject to the following conditions: |
projetmacintel | 0:43669f623d43 | 15 | * |
projetmacintel | 0:43669f623d43 | 16 | * The above copyright notice and this permission notice shall be included in |
projetmacintel | 0:43669f623d43 | 17 | * all copies or substantial portions of the Software. |
projetmacintel | 0:43669f623d43 | 18 | * |
projetmacintel | 0:43669f623d43 | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
projetmacintel | 0:43669f623d43 | 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
projetmacintel | 0:43669f623d43 | 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
projetmacintel | 0:43669f623d43 | 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
projetmacintel | 0:43669f623d43 | 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
projetmacintel | 0:43669f623d43 | 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
projetmacintel | 0:43669f623d43 | 25 | * THE SOFTWARE. |
projetmacintel | 0:43669f623d43 | 26 | * ============================================================================= |
projetmacintel | 0:43669f623d43 | 27 | */ |
projetmacintel | 0:43669f623d43 | 28 | |
projetmacintel | 0:43669f623d43 | 29 | #ifndef LS_Y201_H |
projetmacintel | 0:43669f623d43 | 30 | #define LS_Y201_H |
projetmacintel | 0:43669f623d43 | 31 | |
projetmacintel | 0:43669f623d43 | 32 | #include "mbed.h" |
projetmacintel | 0:43669f623d43 | 33 | #include "SerialBuffered.h" |
projetmacintel | 0:43669f623d43 | 34 | |
projetmacintel | 0:43669f623d43 | 35 | /** |
projetmacintel | 0:43669f623d43 | 36 | * Camera |
projetmacintel | 0:43669f623d43 | 37 | */ |
projetmacintel | 0:43669f623d43 | 38 | class Camera_LS_Y201 { |
projetmacintel | 0:43669f623d43 | 39 | public: |
projetmacintel | 0:43669f623d43 | 40 | |
projetmacintel | 0:43669f623d43 | 41 | /** |
projetmacintel | 0:43669f623d43 | 42 | * Create. |
projetmacintel | 0:43669f623d43 | 43 | * |
projetmacintel | 0:43669f623d43 | 44 | * @param tx Transmitter. |
projetmacintel | 0:43669f623d43 | 45 | * @param rx Receiver. |
projetmacintel | 0:43669f623d43 | 46 | */ |
projetmacintel | 0:43669f623d43 | 47 | Camera_LS_Y201(PinName tx, PinName rx); |
projetmacintel | 0:43669f623d43 | 48 | |
projetmacintel | 0:43669f623d43 | 49 | /** |
projetmacintel | 0:43669f623d43 | 50 | * Dispose. |
projetmacintel | 0:43669f623d43 | 51 | */ |
projetmacintel | 0:43669f623d43 | 52 | ~Camera_LS_Y201(); |
projetmacintel | 0:43669f623d43 | 53 | |
projetmacintel | 0:43669f623d43 | 54 | /** |
projetmacintel | 0:43669f623d43 | 55 | * Error code. |
projetmacintel | 0:43669f623d43 | 56 | */ |
projetmacintel | 0:43669f623d43 | 57 | enum ErrorCode { |
projetmacintel | 0:43669f623d43 | 58 | NoError = 0, |
projetmacintel | 0:43669f623d43 | 59 | UnexpectedReply, |
projetmacintel | 0:43669f623d43 | 60 | Timeout, |
projetmacintel | 0:43669f623d43 | 61 | SendError, |
projetmacintel | 0:43669f623d43 | 62 | RecvError, |
projetmacintel | 0:43669f623d43 | 63 | InvalidArguments |
projetmacintel | 0:43669f623d43 | 64 | }; |
projetmacintel | 0:43669f623d43 | 65 | |
projetmacintel | 0:43669f623d43 | 66 | /** |
projetmacintel | 0:43669f623d43 | 67 | * Image size. |
projetmacintel | 0:43669f623d43 | 68 | */ |
projetmacintel | 0:43669f623d43 | 69 | enum ImageSize { |
projetmacintel | 0:43669f623d43 | 70 | ImageSize160x120, /**< 160x120. */ |
projetmacintel | 0:43669f623d43 | 71 | ImageSize320x280, /**< 320x280. */ |
projetmacintel | 0:43669f623d43 | 72 | ImageSize640x480 /**< 640x480. */ |
projetmacintel | 0:43669f623d43 | 73 | }; |
projetmacintel | 0:43669f623d43 | 74 | |
projetmacintel | 0:43669f623d43 | 75 | /** |
projetmacintel | 0:43669f623d43 | 76 | * Reset module. |
projetmacintel | 0:43669f623d43 | 77 | * |
projetmacintel | 0:43669f623d43 | 78 | * @return Error code. |
projetmacintel | 0:43669f623d43 | 79 | */ |
projetmacintel | 0:43669f623d43 | 80 | ErrorCode reset(); |
projetmacintel | 0:43669f623d43 | 81 | |
projetmacintel | 0:43669f623d43 | 82 | /** |
projetmacintel | 0:43669f623d43 | 83 | * Set image size. |
projetmacintel | 0:43669f623d43 | 84 | * |
projetmacintel | 0:43669f623d43 | 85 | * @param is Image size. |
projetmacintel | 0:43669f623d43 | 86 | * @return Error code. |
projetmacintel | 0:43669f623d43 | 87 | */ |
projetmacintel | 0:43669f623d43 | 88 | ErrorCode setImageSize(ImageSize is); |
projetmacintel | 0:43669f623d43 | 89 | |
projetmacintel | 0:43669f623d43 | 90 | /** |
projetmacintel | 0:43669f623d43 | 91 | * Take picture. |
projetmacintel | 0:43669f623d43 | 92 | * |
projetmacintel | 0:43669f623d43 | 93 | * @return Error code. |
projetmacintel | 0:43669f623d43 | 94 | */ |
projetmacintel | 0:43669f623d43 | 95 | ErrorCode takePicture(); |
projetmacintel | 0:43669f623d43 | 96 | |
projetmacintel | 0:43669f623d43 | 97 | /** |
projetmacintel | 0:43669f623d43 | 98 | * Read jpeg file size. |
projetmacintel | 0:43669f623d43 | 99 | * |
projetmacintel | 0:43669f623d43 | 100 | * @param fileSize File size. |
projetmacintel | 0:43669f623d43 | 101 | * @return Error code. |
projetmacintel | 0:43669f623d43 | 102 | */ |
projetmacintel | 0:43669f623d43 | 103 | ErrorCode readJpegFileSize(int *fileSize); |
projetmacintel | 0:43669f623d43 | 104 | |
projetmacintel | 0:43669f623d43 | 105 | /** |
projetmacintel | 0:43669f623d43 | 106 | * Read jpeg file content. |
projetmacintel | 0:43669f623d43 | 107 | * |
projetmacintel | 0:43669f623d43 | 108 | * @param func A pointer to a call back function. |
projetmacintel | 0:43669f623d43 | 109 | * @return Error code. |
projetmacintel | 0:43669f623d43 | 110 | */ |
projetmacintel | 0:43669f623d43 | 111 | ErrorCode readJpegFileContent( |
projetmacintel | 0:43669f623d43 | 112 | void (*func)(int done, int total, uint8_t *buf, size_t siz, char *rep), |
projetmacintel | 0:43669f623d43 | 113 | void (*sendSocket)(char *chaine, int taille_chaine, char *reponse, int longueur_reponse_max), |
projetmacintel | 0:43669f623d43 | 114 | char *response |
projetmacintel | 0:43669f623d43 | 115 | ); |
projetmacintel | 0:43669f623d43 | 116 | |
projetmacintel | 0:43669f623d43 | 117 | /** |
projetmacintel | 0:43669f623d43 | 118 | * Stop taking pictures. |
projetmacintel | 0:43669f623d43 | 119 | * |
projetmacintel | 0:43669f623d43 | 120 | * @return Error code. |
projetmacintel | 0:43669f623d43 | 121 | */ |
projetmacintel | 0:43669f623d43 | 122 | ErrorCode stopTakingPictures(); |
projetmacintel | 0:43669f623d43 | 123 | |
projetmacintel | 0:43669f623d43 | 124 | private: |
projetmacintel | 0:43669f623d43 | 125 | SerialBuffered serial; |
projetmacintel | 0:43669f623d43 | 126 | |
projetmacintel | 0:43669f623d43 | 127 | /** |
projetmacintel | 0:43669f623d43 | 128 | * Wait init end codes. |
projetmacintel | 0:43669f623d43 | 129 | * |
projetmacintel | 0:43669f623d43 | 130 | * @return Error code. |
projetmacintel | 0:43669f623d43 | 131 | */ |
projetmacintel | 0:43669f623d43 | 132 | ErrorCode waitInitEnd(); |
projetmacintel | 0:43669f623d43 | 133 | |
projetmacintel | 0:43669f623d43 | 134 | /** |
projetmacintel | 0:43669f623d43 | 135 | * Send bytes to camera module. |
projetmacintel | 0:43669f623d43 | 136 | * |
projetmacintel | 0:43669f623d43 | 137 | * @param buf Pointer to the data buffer. |
projetmacintel | 0:43669f623d43 | 138 | * @param len Length of the data buffer. |
projetmacintel | 0:43669f623d43 | 139 | * |
projetmacintel | 0:43669f623d43 | 140 | * @return True if the data sended. |
projetmacintel | 0:43669f623d43 | 141 | */ |
projetmacintel | 0:43669f623d43 | 142 | bool sendBytes(uint8_t *buf, size_t len, int timeout_us); |
projetmacintel | 0:43669f623d43 | 143 | |
projetmacintel | 0:43669f623d43 | 144 | /** |
projetmacintel | 0:43669f623d43 | 145 | * Receive bytes from camera module. |
projetmacintel | 0:43669f623d43 | 146 | * |
projetmacintel | 0:43669f623d43 | 147 | * @param buf Pointer to the data buffer. |
projetmacintel | 0:43669f623d43 | 148 | * @param len Length of the data buffer. |
projetmacintel | 0:43669f623d43 | 149 | * |
projetmacintel | 0:43669f623d43 | 150 | * @return True if the data received. |
projetmacintel | 0:43669f623d43 | 151 | */ |
projetmacintel | 0:43669f623d43 | 152 | bool recvBytes(uint8_t *buf, size_t len, int timeout_us); |
projetmacintel | 0:43669f623d43 | 153 | |
projetmacintel | 0:43669f623d43 | 154 | /** |
projetmacintel | 0:43669f623d43 | 155 | * Wait received. |
projetmacintel | 0:43669f623d43 | 156 | * |
projetmacintel | 0:43669f623d43 | 157 | * @return True if the data received. |
projetmacintel | 0:43669f623d43 | 158 | */ |
projetmacintel | 0:43669f623d43 | 159 | bool waitRecv(); |
projetmacintel | 0:43669f623d43 | 160 | |
projetmacintel | 0:43669f623d43 | 161 | /** |
projetmacintel | 0:43669f623d43 | 162 | * Wait idle state. |
projetmacintel | 0:43669f623d43 | 163 | * |
projetmacintel | 0:43669f623d43 | 164 | * @return True if it succeed. |
projetmacintel | 0:43669f623d43 | 165 | */ |
projetmacintel | 0:43669f623d43 | 166 | bool waitIdle(); |
projetmacintel | 0:43669f623d43 | 167 | |
projetmacintel | 0:43669f623d43 | 168 | }; |
projetmacintel | 0:43669f623d43 | 169 | |
projetmacintel | 0:43669f623d43 | 170 | #endif |