pixy2 smart camera library www.pixycam.com

Pixy2 Library project (using UART interface)

Committer:
haarkon
Date:
Tue Mar 12 16:53:22 2019 +0000
Revision:
13:478380d73e80
Parent:
12:7493191dd1dc
Child:
14:c0eda1e35a00
none

Who changed what in which revision?

UserRevisionLine numberNew contents of line
haarkon 0:dde1b9d6c9d6 1 /**
haarkon 0:dde1b9d6c9d6 2 * @author Hugues Angelis
haarkon 0:dde1b9d6c9d6 3 *
haarkon 0:dde1b9d6c9d6 4 * @section LICENSE
haarkon 0:dde1b9d6c9d6 5 *
haarkon 0:dde1b9d6c9d6 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
haarkon 0:dde1b9d6c9d6 7 * of this software and associated documentation files (the "Software"), to deal
haarkon 0:dde1b9d6c9d6 8 * in the Software without restriction, including without limitation the rights
haarkon 0:dde1b9d6c9d6 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
haarkon 0:dde1b9d6c9d6 10 * copies of the Software, and to permit persons to whom the Software is
haarkon 0:dde1b9d6c9d6 11 * furnished to do so, subject to the following conditions:
haarkon 0:dde1b9d6c9d6 12 *
haarkon 0:dde1b9d6c9d6 13 * The above copyright notice and this permission notice shall be included in
haarkon 0:dde1b9d6c9d6 14 * all copies or substantial portions of the Software.
haarkon 0:dde1b9d6c9d6 15 *
haarkon 0:dde1b9d6c9d6 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
haarkon 0:dde1b9d6c9d6 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
haarkon 0:dde1b9d6c9d6 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
haarkon 0:dde1b9d6c9d6 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
haarkon 0:dde1b9d6c9d6 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
haarkon 0:dde1b9d6c9d6 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
haarkon 0:dde1b9d6c9d6 22 * THE SOFTWARE.
haarkon 0:dde1b9d6c9d6 23 *
haarkon 0:dde1b9d6c9d6 24 * @section DESCRIPTION
haarkon 0:dde1b9d6c9d6 25 *
haarkon 0:dde1b9d6c9d6 26 * CMUCAM 5 - Pixy2
haarkon 0:dde1b9d6c9d6 27 *
haarkon 0:dde1b9d6c9d6 28 * Datasheet, FAQ and PC drivers :
haarkon 0:dde1b9d6c9d6 29 *
haarkon 0:dde1b9d6c9d6 30 * http://www.pixycam.com/
haarkon 0:dde1b9d6c9d6 31 */
haarkon 0:dde1b9d6c9d6 32
haarkon 0:dde1b9d6c9d6 33 #ifndef _PIXY2_
haarkon 0:dde1b9d6c9d6 34 #define _PIXY2_
haarkon 0:dde1b9d6c9d6 35
haarkon 0:dde1b9d6c9d6 36 /**
haarkon 0:dde1b9d6c9d6 37 * Include : Mbed Library
haarkon 0:dde1b9d6c9d6 38 */
haarkon 0:dde1b9d6c9d6 39 #include "mbed.h"
haarkon 0:dde1b9d6c9d6 40
haarkon 0:dde1b9d6c9d6 41 /**
haarkon 0:dde1b9d6c9d6 42 * Defines
haarkon 0:dde1b9d6c9d6 43 */
haarkon 0:dde1b9d6c9d6 44 #define PIXY2_NCSHEADERSIZE 4
haarkon 0:dde1b9d6c9d6 45 #define PIXY2_CSHEADERSIZE 4
haarkon 0:dde1b9d6c9d6 46 #define PIXY2_SYNC 0xC1AE
haarkon 0:dde1b9d6c9d6 47 #define PIXY2_CSSYNC 0xC1AF
haarkon 0:dde1b9d6c9d6 48 #define PIXY2_ACK 1
haarkon 10:ea759846c2d5 49 #define PIXY2_ERROR 3
haarkon 0:dde1b9d6c9d6 50 #define PIXY2_ASK_RESOL 12
haarkon 0:dde1b9d6c9d6 51 #define PIXY2_REP_RESOL 13
haarkon 0:dde1b9d6c9d6 52 #define PIXY2_ASK_VERS 14
haarkon 0:dde1b9d6c9d6 53 #define PIXY2_REP_VERS 15
haarkon 0:dde1b9d6c9d6 54 #define PIXY2_SET_BRIGHT 16
haarkon 0:dde1b9d6c9d6 55 #define PIXY2_SET_SERVOS 18
haarkon 0:dde1b9d6c9d6 56 #define PIXY2_SET_LED 20
haarkon 0:dde1b9d6c9d6 57 #define PIXY2_SET_LAMP 22
haarkon 0:dde1b9d6c9d6 58 #define PIXY2_ASK_FPS 24
haarkon 0:dde1b9d6c9d6 59 #define PIXY2_ASK_BLOC 32
haarkon 0:dde1b9d6c9d6 60 #define PIXY2_REP_BLOC 33
haarkon 0:dde1b9d6c9d6 61 #define PIXY2_ASK_LINE 48
haarkon 0:dde1b9d6c9d6 62 #define PIXY2_REP_LINE 49
haarkon 0:dde1b9d6c9d6 63 #define PIXY2_SET_MODE 54
haarkon 0:dde1b9d6c9d6 64 #define PIXY2_SET_TURN 58
haarkon 0:dde1b9d6c9d6 65 #define PIXY2_SET_VECTOR 56
haarkon 0:dde1b9d6c9d6 66 #define PIXY2_SET_DEFTURN 60
haarkon 0:dde1b9d6c9d6 67 #define PIXY2_SET_REVERSE 62
haarkon 0:dde1b9d6c9d6 68 #define PIXY2_ASK_VIDEO 112
haarkon 1:dd81f4065b6b 69
haarkon 6:e9e3aa6f1a55 70 /**************** ERRORS ****************/
haarkon 5:28e47187bb5c 71
haarkon 5:28e47187bb5c 72 /**
haarkon 13:478380d73e80 73 * \struct T_pixy2ErrorCode
haarkon 6:e9e3aa6f1a55 74 * \brief Explicit error code list :
haarkon 5:28e47187bb5c 75 * \param PIXY2_OK : No error
haarkon 5:28e47187bb5c 76 * \param PIXY2_MISC_ERROR : Unknown error
haarkon 5:28e47187bb5c 77 * \param PIXY2_BUSY : Pixy hasn't finish yet
haarkon 5:28e47187bb5c 78 * \param PIXY2_BAD_CHECKSUM : Checksum is wrong
haarkon 8:c93e1d706c0e 79 * \param PIXY2_TYPE_ERROR : Unexpected message type
haarkon 7:1163b9c3274b 80 * @note More documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api#error-codes
haarkon 5:28e47187bb5c 81 */
haarkon 11:68ef9f85e40e 82 typedef int T_pixy2ErrorCode;
haarkon 5:28e47187bb5c 83
haarkon 8:c93e1d706c0e 84 #define PIXY2_OK 0
haarkon 5:28e47187bb5c 85 #define PIXY2_MISC_ERROR -1
haarkon 5:28e47187bb5c 86 #define PIXY2_BUSY -2
haarkon 5:28e47187bb5c 87 #define PIXY2_BAD_CHECKSUM -3
haarkon 5:28e47187bb5c 88 #define PIXY2_TYPE_ERROR -7
haarkon 1:dd81f4065b6b 89
haarkon 1:dd81f4065b6b 90 /**************** STATE MACHINE ****************/
haarkon 1:dd81f4065b6b 91
haarkon 1:dd81f4065b6b 92 typedef enum {idle, messageSent, receivingHeader, headerReceived, receivingData, dataReceived} T_Pixy2State;
haarkon 1:dd81f4065b6b 93
haarkon 1:dd81f4065b6b 94 /**************** UTILS ****************/
haarkon 1:dd81f4065b6b 95
haarkon 6:e9e3aa6f1a55 96
haarkon 0:dde1b9d6c9d6 97 /**
haarkon 0:dde1b9d6c9d6 98 * \struct Byte -> Short hand for unsigned char
haarkon 2:5281a6289e8b 99 * \struct sByte -> Short hand for char
haarkon 0:dde1b9d6c9d6 100 * \struct Word -> Short hand for unsigned short
haarkon 2:5281a6289e8b 101 * \struct sWord -> Short hand for short
haarkon 0:dde1b9d6c9d6 102 * \struct lWord -> Short hand for unsigned long
haarkon 2:5281a6289e8b 103 * \struct slWord -> Short hand for long
haarkon 0:dde1b9d6c9d6 104 */
haarkon 0:dde1b9d6c9d6 105 typedef unsigned char Byte;
haarkon 2:5281a6289e8b 106 typedef char sByte;
haarkon 0:dde1b9d6c9d6 107 typedef unsigned short Word;
haarkon 2:5281a6289e8b 108 typedef short sWord;
haarkon 0:dde1b9d6c9d6 109 typedef unsigned long lWord;
haarkon 2:5281a6289e8b 110 typedef long slWord;
haarkon 0:dde1b9d6c9d6 111
haarkon 1:dd81f4065b6b 112 /**
haarkon 1:dd81f4065b6b 113 * \union T_Word
haarkon 1:dd81f4065b6b 114 * \brief Structured type to switch from word to bytes
haarkon 1:dd81f4065b6b 115 * \param mot (Word) : 16 bits word
haarkon 1:dd81f4065b6b 116 * \param octet (Byte) : 2 bytes that overlap mot (byte access)
haarkon 1:dd81f4065b6b 117 */
haarkon 0:dde1b9d6c9d6 118 typedef union {
haarkon 0:dde1b9d6c9d6 119 Word mot;
haarkon 0:dde1b9d6c9d6 120 Byte octet[2];
haarkon 0:dde1b9d6c9d6 121 }T_Word;
haarkon 0:dde1b9d6c9d6 122
haarkon 1:dd81f4065b6b 123 /**
haarkon 1:dd81f4065b6b 124 * \union T_lWord
haarkon 1:dd81f4065b6b 125 * \brief Structured type to switch from lword to word or bytes
haarkon 1:dd81f4065b6b 126 * \param motLong (lWord) : 32 bits word
haarkon 1:dd81f4065b6b 127 * \param mot (Word) : 2 x 16 bits words that overlap motLong (word access)
haarkon 1:dd81f4065b6b 128 * \param octet (Byte) : 4 bytes that overlap motLong (byte access)
haarkon 1:dd81f4065b6b 129 */
haarkon 0:dde1b9d6c9d6 130 typedef union {
haarkon 0:dde1b9d6c9d6 131 lWord motLong;
haarkon 0:dde1b9d6c9d6 132 Word mot[2];
haarkon 0:dde1b9d6c9d6 133 Byte octet[4];
haarkon 0:dde1b9d6c9d6 134 }T_lWord;
haarkon 0:dde1b9d6c9d6 135
haarkon 1:dd81f4065b6b 136
haarkon 1:dd81f4065b6b 137 /**************** HEADERS ****************/
haarkon 1:dd81f4065b6b 138
haarkon 1:dd81f4065b6b 139 /**
haarkon 1:dd81f4065b6b 140 * \struct T_pixy2Header
haarkon 1:dd81f4065b6b 141 * \brief Structured type that match pixy2 header without checksum (send message)
haarkon 1:dd81f4065b6b 142 * \param pixSync (Word) : 16 bits synchro word - could be 0xc1ae (PIXY2_SYNC) or 0xc1af (PIXY2_CSSYNC)
haarkon 1:dd81f4065b6b 143 * \param pixType (Byte) : 8 bits message type identifier
haarkon 1:dd81f4065b6b 144 * \param pixLength (Byte) : 8 bits message payload length (payload doesn't include checksum)
haarkon 1:dd81f4065b6b 145 */
haarkon 0:dde1b9d6c9d6 146 typedef struct {
haarkon 0:dde1b9d6c9d6 147 Word pixSync;
haarkon 0:dde1b9d6c9d6 148 Byte pixType;
haarkon 0:dde1b9d6c9d6 149 Byte pixLength;
haarkon 0:dde1b9d6c9d6 150 }T_pixy2Header;
haarkon 0:dde1b9d6c9d6 151
haarkon 1:dd81f4065b6b 152 /**
haarkon 12:7493191dd1dc 153 * \struct T_pixy2SendFrame
haarkon 1:dd81f4065b6b 154 * \brief Structured type that match frame definition for all kind of message to send to a pixy2
haarkon 1:dd81f4065b6b 155 * \param header (T_pixy2Header) : 4 bytes classical header starting with PIXY2_SYNC
haarkon 1:dd81f4065b6b 156 * \param data (Byte) : 5 bytes payload (to match all usage, not all byte must be used)
haarkon 1:dd81f4065b6b 157 */
haarkon 0:dde1b9d6c9d6 158 typedef struct {
haarkon 0:dde1b9d6c9d6 159 T_pixy2Header header;
haarkon 0:dde1b9d6c9d6 160 Byte data[5];
haarkon 10:ea759846c2d5 161 }T_pixy2SendFrame;
haarkon 0:dde1b9d6c9d6 162
haarkon 1:dd81f4065b6b 163 /**
haarkon 12:7493191dd1dc 164 * \union T_pixy2SendBuffer
haarkon 1:dd81f4065b6b 165 * \brief Structured type to switch between structured type T_pixy2sendFrame and bytes
haarkon 12:7493191dd1dc 166 * \param frame (T_pixy2SendFrame) : classical frame (header + payload) starting with PIXY2_SYNC
haarkon 1:dd81f4065b6b 167 * \param data (Byte) : 9 bytes that overlap frame (byte access)
haarkon 1:dd81f4065b6b 168 */
haarkon 0:dde1b9d6c9d6 169 typedef union {
haarkon 10:ea759846c2d5 170 T_pixy2SendFrame frame;
haarkon 0:dde1b9d6c9d6 171 Byte data[9];
haarkon 10:ea759846c2d5 172 }T_pixy2SendBuffer;
haarkon 0:dde1b9d6c9d6 173
haarkon 1:dd81f4065b6b 174 /**
haarkon 1:dd81f4065b6b 175 * \struct T_pixy2RcvHeader
haarkon 1:dd81f4065b6b 176 * \brief Structured type that match pixy2 header with checksum (received message)
haarkon 1:dd81f4065b6b 177 * \param pixSync (Word) : 16 bits synchro word - could be 0xc1ae (PIXY2_SYNC) or 0xc1af (PIXY2_CSSYNC)
haarkon 1:dd81f4065b6b 178 * \param pixType (Byte) : 8 bits message type identifier
haarkon 1:dd81f4065b6b 179 * \param pixLength (Byte) : 8 bits message payload length (payload doesn't include checksum)
haarkon 1:dd81f4065b6b 180 * \param pixSync (Word) : 16 bits checksum (sum of all bytes of the payload)
haarkon 1:dd81f4065b6b 181 */
haarkon 0:dde1b9d6c9d6 182 typedef struct {
haarkon 0:dde1b9d6c9d6 183 Word pixSync;
haarkon 0:dde1b9d6c9d6 184 Byte pixType;
haarkon 0:dde1b9d6c9d6 185 Byte pixLength;
haarkon 0:dde1b9d6c9d6 186 Word pixChecksum;
haarkon 0:dde1b9d6c9d6 187 }T_pixy2RcvHeader;
haarkon 0:dde1b9d6c9d6 188
haarkon 1:dd81f4065b6b 189
haarkon 1:dd81f4065b6b 190 /**************** PAYLOADS ****************/
haarkon 1:dd81f4065b6b 191
haarkon 1:dd81f4065b6b 192 /**
haarkon 12:7493191dd1dc 193 * \struct T_pixy2ReturnCode
haarkon 1:dd81f4065b6b 194 * \brief Structured type that match pixy2 error/acknowledge/reply frame (type = 1 or 3) message payload
haarkon 1:dd81f4065b6b 195 * \param pixReturn (lWord) : 32 bits returned value
haarkon 1:dd81f4065b6b 196 */
haarkon 0:dde1b9d6c9d6 197 typedef struct {
haarkon 1:dd81f4065b6b 198 lWord pixReturn;
haarkon 10:ea759846c2d5 199 }T_pixy2ReturnCode;
haarkon 0:dde1b9d6c9d6 200
haarkon 1:dd81f4065b6b 201 /**
haarkon 1:dd81f4065b6b 202 * \struct T_Pixy2Version
haarkon 1:dd81f4065b6b 203 * \brief Structured type that match pixy2 version frame (type = 14/15) message payload
haarkon 1:dd81f4065b6b 204 * \param pixHWVersion (Word) : 16 bits hardWare Version of pixy2
haarkon 1:dd81f4065b6b 205 * \param pixFWVersionMaj (Byte) : 8 bits upper part of firmware (before the dot)
haarkon 1:dd81f4065b6b 206 * \param pixFWVersionMin (Byte) : 8 bits lower part of firmware (after the dot)
haarkon 1:dd81f4065b6b 207 * \param pixFWBuild (Word) : 16 bits firmware build information
haarkon 1:dd81f4065b6b 208 * \param pixHFString (String) : 10 bytes user friendly pixy2 firmware type
haarkon 1:dd81f4065b6b 209 */
haarkon 0:dde1b9d6c9d6 210 typedef struct {
haarkon 0:dde1b9d6c9d6 211 Word pixHWVersion;
haarkon 0:dde1b9d6c9d6 212 Byte pixFWVersionMaj;
haarkon 0:dde1b9d6c9d6 213 Byte pixFWVersionMin;
haarkon 0:dde1b9d6c9d6 214 Word pixFWBuild;
haarkon 0:dde1b9d6c9d6 215 char pixHFString[10];
haarkon 11:68ef9f85e40e 216 }T_pixy2Version;
haarkon 0:dde1b9d6c9d6 217
haarkon 1:dd81f4065b6b 218 /**
haarkon 1:dd81f4065b6b 219 * \struct T_Pixy2Resolution
haarkon 1:dd81f4065b6b 220 * \brief Structured type that match pixy2 resolution frame (type = 12/13) message payload
haarkon 1:dd81f4065b6b 221 * \param pixFrameWidth (Word) : 16 bits width (in pixel) of an image
haarkon 5:28e47187bb5c 222 * \param pixFrameHeight (Word) : 16 bits height (in pixel) of an image
haarkon 1:dd81f4065b6b 223 */
haarkon 0:dde1b9d6c9d6 224 typedef struct {
haarkon 0:dde1b9d6c9d6 225 Word pixFrameWidth;
haarkon 5:28e47187bb5c 226 Word pixFrameHeight;
haarkon 11:68ef9f85e40e 227 }T_pixy2Resolution;
haarkon 0:dde1b9d6c9d6 228
haarkon 1:dd81f4065b6b 229 /**
haarkon 1:dd81f4065b6b 230 * \struct T_pixy2Bloc
haarkon 1:dd81f4065b6b 231 * \brief Structured type that match pixy2 blocks frame (type = 32/33) message payload
haarkon 1:dd81f4065b6b 232 * \param pixSignature (Word) : 16 bits signature or color code of the color bloc (signature are between 1 and 7, color code are composed of signature of 2, up to 5, tags so over 10)
haarkon 1:dd81f4065b6b 233 * \param pixX (Word) : 16 bits X (horizontal axis) position of color bloc center, relative to the left of the image (in pixels, between 0 and 315)
haarkon 1:dd81f4065b6b 234 * \param pixY (Word) : 16 bits Y (vertical axis) position of color bloc center, relative to the top of the image (in pixels, between 0 and 207)
haarkon 1:dd81f4065b6b 235 * \param pixWidth (Word) : 16 bits width (in pixels, between 0 and 316) of color bloc
haarkon 1:dd81f4065b6b 236 * \param pixHeight (Word) : 16 bits height (in pixels, between 0 and 208) of color bloc
haarkon 2:5281a6289e8b 237 * \param pixAngle (sWord) : 16 bits angle (in degree, between -180.0 and +180.0) of a color code bloc
haarkon 1:dd81f4065b6b 238 * \param pixIndex (Byte) : 8 bits tracking identification of the color code bloc (set by pixy2 to ease a bloc position following program)
haarkon 1:dd81f4065b6b 239 * \param pixAge (Byte) : 8 bits age (in number of frame) of a bloc (doesn't wrap around).
haarkon 1:dd81f4065b6b 240 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:ccc_api
haarkon 1:dd81f4065b6b 241 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:color_connected_components
haarkon 1:dd81f4065b6b 242 */
haarkon 0:dde1b9d6c9d6 243 typedef struct {
haarkon 0:dde1b9d6c9d6 244 Word pixSignature;
haarkon 0:dde1b9d6c9d6 245 Word pixX;
haarkon 0:dde1b9d6c9d6 246 Word pixY;
haarkon 0:dde1b9d6c9d6 247 Word pixWidth;
haarkon 0:dde1b9d6c9d6 248 Word pixHeight;
haarkon 2:5281a6289e8b 249 sWord pixAngle;
haarkon 0:dde1b9d6c9d6 250 Byte pixIndex;
haarkon 0:dde1b9d6c9d6 251 Byte pixAge;
haarkon 0:dde1b9d6c9d6 252 }T_pixy2Bloc;
haarkon 0:dde1b9d6c9d6 253
haarkon 1:dd81f4065b6b 254 /**
haarkon 1:dd81f4065b6b 255 * \struct T_Pixy2Vector
haarkon 1:dd81f4065b6b 256 * \brief Structured type that match pixy2 vector definition - used in Line frame (type 48/49) - message payload
haarkon 2:5281a6289e8b 257 * \param pixX0 (Byte) : 8 bits X (horizontal, relative to the left of image) position of the tail of the vector (number between 0 and 78)
haarkon 2:5281a6289e8b 258 * \param pixY0 (Byte) : 8 bits Y (vertical, relative to the top of image) position of the tail of the vector (number between 0 and 51)
haarkon 2:5281a6289e8b 259 * \param pixX1 (Byte) : 8 bits X (horizontal, relative to the left of image) position of the head of the vector (number between 0 and 78)
haarkon 2:5281a6289e8b 260 * \param pixY1 (Byte) : 8 bits Y (vertical, relative to the top of image) position of the head of the vector (number between 0 and 51)
haarkon 2:5281a6289e8b 261 * \param pixIndex (Byte) : 8 bits tracking identification of the vector (set by pixy2 to ease a vector identification in case of multiple vector in a line following program)
haarkon 2:5281a6289e8b 262 * \param pixFlags (Byte) : 8 bits flag containing possible usefull informations (see notes)
haarkon 4:eed638064b42 263 * @note This structure is a feature of Line API, packed as a feature in a Line Frame, documented here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference
haarkon 2:5281a6289e8b 264 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api
haarkon 2:5281a6289e8b 265 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
haarkon 1:dd81f4065b6b 266 */
haarkon 0:dde1b9d6c9d6 267 typedef struct {
haarkon 0:dde1b9d6c9d6 268 Byte pixX0;
haarkon 0:dde1b9d6c9d6 269 Byte pixY0;
haarkon 0:dde1b9d6c9d6 270 Byte pixX1;
haarkon 0:dde1b9d6c9d6 271 Byte pixY1;
haarkon 0:dde1b9d6c9d6 272 Byte pixIndex;
haarkon 0:dde1b9d6c9d6 273 Byte pixFlags;
haarkon 11:68ef9f85e40e 274 }T_pixy2Vector;
haarkon 0:dde1b9d6c9d6 275
haarkon 2:5281a6289e8b 276 /**
haarkon 2:5281a6289e8b 277 * \struct T_Pixy2InterLine
haarkon 2:5281a6289e8b 278 * \brief Structured type that match pixy2 intersection line definition - used in Line frame (type 48/49) - message payload
haarkon 2:5281a6289e8b 279 * \param pixIndex (Byte) : 8 bits tracking identification of the intersection line (set by pixy2 to ease a line following program)
haarkon 2:5281a6289e8b 280 * \param pixReserved (Byte) : Not documented by manufacturer
haarkon 2:5281a6289e8b 281 * \param pixAngle (sWord) : 16 bits angle (in degree, between -180.0 and +180.0) of the intersection line
haarkon 4:eed638064b42 282 * @note This structure is a sub feature of Line API, packed as a sub feature of intersection feature in a Line Frame, documented here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference
haarkon 2:5281a6289e8b 283 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api
haarkon 2:5281a6289e8b 284 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
haarkon 2:5281a6289e8b 285 */
haarkon 0:dde1b9d6c9d6 286 typedef struct {
haarkon 0:dde1b9d6c9d6 287 Byte pixIndex;
haarkon 0:dde1b9d6c9d6 288 Byte pixReserved;
haarkon 2:5281a6289e8b 289 sWord pixAngle;
haarkon 11:68ef9f85e40e 290 }T_pixy2InterLine;
haarkon 0:dde1b9d6c9d6 291
haarkon 3:6ba43af28440 292 /**
haarkon 3:6ba43af28440 293 * \struct T_pixy2Intersection
haarkon 3:6ba43af28440 294 * \brief Structured type that match pixy2 intersection definition - used in Line frame (type 48/49) - message payload
haarkon 3:6ba43af28440 295 * \param pixX (Byte) : X axis coordinate of the intersection (in pixel, between 0 and 78)
haarkon 3:6ba43af28440 296 * \param pixY (Byte) : Y axis coordinate of the intersection (in pixel, between 0 and 51)
haarkon 3:6ba43af28440 297 * \param pixN (Byte) : Number of lines connected to the intersection (between 3 and 5)
haarkon 3:6ba43af28440 298 * \param pixReserved (Byte) : Not documented by manufacturer
haarkon 4:eed638064b42 299 * @note This structure is a feature of Line API, packed as a feature in a Line Frame, documented here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference
haarkon 3:6ba43af28440 300 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api
haarkon 3:6ba43af28440 301 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
haarkon 3:6ba43af28440 302 */
haarkon 0:dde1b9d6c9d6 303 typedef struct {
haarkon 0:dde1b9d6c9d6 304 Byte pixX;
haarkon 0:dde1b9d6c9d6 305 Byte pixY;
haarkon 0:dde1b9d6c9d6 306 Byte pixN;
haarkon 0:dde1b9d6c9d6 307 Byte pixReserved;
haarkon 0:dde1b9d6c9d6 308 }T_pixy2Intersection;
haarkon 0:dde1b9d6c9d6 309
haarkon 3:6ba43af28440 310 /**
haarkon 3:6ba43af28440 311 * \struct T_pixy2BarCode
haarkon 3:6ba43af28440 312 * \brief Structured type that match pixy2 barcode definition - used in Line frame (type 48/49) - message payload
haarkon 3:6ba43af28440 313 * \param pixX (Byte) : X axis coordinate of the barcode (in pixel, between 0 and 78)
haarkon 3:6ba43af28440 314 * \param pixY (Byte) : Y axis coordinate of the barcode (in pixel, between 0 and 51)
haarkon 3:6ba43af28440 315 * \param pixFlag (Byte) : Flag to indicate if barcode met filtering constraint
haarkon 3:6ba43af28440 316 * \param pixCode (Byte) : Indicate the numeric value associated with the barcode (between 0 and 15)
haarkon 4:eed638064b42 317 * @note This structure is a feature of Line API, packed as a feature in a Line Frame, documented here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference
haarkon 3:6ba43af28440 318 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api
haarkon 3:6ba43af28440 319 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
haarkon 3:6ba43af28440 320 */
haarkon 0:dde1b9d6c9d6 321 typedef struct {
haarkon 0:dde1b9d6c9d6 322 Byte pixX;
haarkon 0:dde1b9d6c9d6 323 Byte pixY;
haarkon 0:dde1b9d6c9d6 324 Byte pixFlag;
haarkon 0:dde1b9d6c9d6 325 Byte pixCode;
haarkon 0:dde1b9d6c9d6 326 }T_pixy2BarCode;
haarkon 0:dde1b9d6c9d6 327
haarkon 4:eed638064b42 328 /**
haarkon 4:eed638064b42 329 * \struct T_pixy2LineFeature
haarkon 4:eed638064b42 330 * \brief Structured type that match pixy2 feature header for Line API - used in Line frame (type 48/49) - message payload
haarkon 4:eed638064b42 331 * \param pixType (Byte) : Type of the feature (can be 1 -> Vector, 2 -> Intersection or 4 -> Barcode)
haarkon 4:eed638064b42 332 * \param pixLength (Byte) : Number of Bytes for this feature
haarkon 4:eed638064b42 333 * @note This structure is the header of features of Line API in Line Frames. Ther can be up to 4 features in a frame. Documented here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference
haarkon 4:eed638064b42 334 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api
haarkon 4:eed638064b42 335 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
haarkon 4:eed638064b42 336 */
haarkon 0:dde1b9d6c9d6 337 typedef struct {
haarkon 0:dde1b9d6c9d6 338 Byte pixType;
haarkon 0:dde1b9d6c9d6 339 Byte pixLength;
haarkon 0:dde1b9d6c9d6 340 }T_pixy2LineFeature;
haarkon 0:dde1b9d6c9d6 341
haarkon 4:eed638064b42 342 /**
haarkon 4:eed638064b42 343 * \struct T_pixy2Pixel
haarkon 4:eed638064b42 344 * \brief Structured type that match pixy2 video API - used in Video frame (type 112/1) - message payload
haarkon 4:eed638064b42 345 * \param pixBlue (Byte) : Blue RGB value of the average blue component of the 5x5 pixels square centered on X param passes to the function (value between 0 and 255)
haarkon 4:eed638064b42 346 * \param pixGreen (Byte) : Green RGB value of the average blue component of the 5x5 pixels square centered on X param passes to the function (value between 0 and 255)
haarkon 4:eed638064b42 347 * \param pixRed (Byte) : Red RGB value of the average blue component of the 5x5 pixels square centered on X param passes to the function (value between 0 and 255)
haarkon 4:eed638064b42 348 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video_api
haarkon 4:eed638064b42 349 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video
haarkon 4:eed638064b42 350 */
haarkon 0:dde1b9d6c9d6 351 typedef struct {
haarkon 0:dde1b9d6c9d6 352 Byte pixBlue;
haarkon 0:dde1b9d6c9d6 353 Byte pixGreen;
haarkon 0:dde1b9d6c9d6 354 Byte pixRed;
haarkon 0:dde1b9d6c9d6 355 }T_pixy2Pixel;
haarkon 0:dde1b9d6c9d6 356
haarkon 0:dde1b9d6c9d6 357 /**
haarkon 0:dde1b9d6c9d6 358 * Pixy2 : CMU CAM 5 - Smart camera
haarkon 0:dde1b9d6c9d6 359 * More informations at http://www.pixycam.com/
haarkon 0:dde1b9d6c9d6 360 */
haarkon 0:dde1b9d6c9d6 361 class PIXY2 {
haarkon 0:dde1b9d6c9d6 362
haarkon 0:dde1b9d6c9d6 363 protected :
haarkon 0:dde1b9d6c9d6 364
haarkon 0:dde1b9d6c9d6 365 Serial* _Pixy2;
haarkon 0:dde1b9d6c9d6 366
haarkon 0:dde1b9d6c9d6 367 public :
haarkon 0:dde1b9d6c9d6 368 /**
haarkon 0:dde1b9d6c9d6 369 * Constructor of pixy2 object.
haarkon 0:dde1b9d6c9d6 370 *
haarkon 0:dde1b9d6c9d6 371 * @param tx : the Mbed pin used as TX
haarkon 0:dde1b9d6c9d6 372 * @param rx : the Mbed pin used as RX
haarkon 0:dde1b9d6c9d6 373 * @param debit : the bitrate of the serial (max value is 230400 b/s)
haarkon 0:dde1b9d6c9d6 374 */
haarkon 0:dde1b9d6c9d6 375 PIXY2(PinName tx, PinName rx, int debit = 230400);
haarkon 0:dde1b9d6c9d6 376
haarkon 0:dde1b9d6c9d6 377 // Fonctions publiques
haarkon 3:6ba43af28440 378
haarkon 3:6ba43af28440 379 /**
haarkon 5:28e47187bb5c 380 * Queries and receives the firmware and hardware version of Pixy2, which is put in the version member variable.
haarkon 5:28e47187bb5c 381 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
haarkon 5:28e47187bb5c 382 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
haarkon 12:7493191dd1dc 383 * @param version (T_pixy2Version - passed by reference) : pointer to the version data structure
haarkon 12:7493191dd1dc 384 * @return T_pixy2ErrorCode : error code.
haarkon 3:6ba43af28440 385 */
haarkon 11:68ef9f85e40e 386 T_pixy2ErrorCode pixy2_getVersion (T_pixy2Version *version);
haarkon 4:eed638064b42 387
haarkon 4:eed638064b42 388 /**
haarkon 5:28e47187bb5c 389 * Gets the width and height of the frames used by the current program.
haarkon 9:764075b514bf 390 * After calling this function, the width and height can be found in the frameWidth and frameHeight member variables.
haarkon 5:28e47187bb5c 391 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
haarkon 5:28e47187bb5c 392 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
haarkon 12:7493191dd1dc 393 * @param resolution (T_pixy2Resolution - passed by reference) : pointer to the resolution data structure
haarkon 12:7493191dd1dc 394 * @return T_pixy2ErrorCode : error code.
haarkon 4:eed638064b42 395 */
haarkon 11:68ef9f85e40e 396 T_pixy2ErrorCode pixy2_getResolution (T_pixy2Resolution *resolution);
haarkon 5:28e47187bb5c 397
haarkon 5:28e47187bb5c 398 /**
haarkon 9:764075b514bf 399 * Sets the relative exposure level of Pixy2's image sensor.
haarkon 9:764075b514bf 400 * Higher values result in a brighter (more exposed) image.
haarkon 5:28e47187bb5c 401 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
haarkon 5:28e47187bb5c 402 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
haarkon 5:28e47187bb5c 403 * @param brightness (Byte - passed by value) : brightness level
haarkon 12:7493191dd1dc 404 * @return T_pixy2ErrorCode : error code.
haarkon 6:e9e3aa6f1a55 405 */
haarkon 11:68ef9f85e40e 406 T_pixy2ErrorCode pixy2_setCameraBrightness (Byte brightness);
haarkon 6:e9e3aa6f1a55 407
haarkon 6:e9e3aa6f1a55 408 /**
haarkon 8:c93e1d706c0e 409 * Sets the servo positions of servos plugged into Pixy2's two RC servo connectors.
haarkon 6:e9e3aa6f1a55 410 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
haarkon 6:e9e3aa6f1a55 411 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
haarkon 7:1163b9c3274b 412 * @param s0 (Word - passed by value) : value between 0 and 511
haarkon 7:1163b9c3274b 413 * @param s1 (Word - passed by value) : value between 0 and 511
haarkon 12:7493191dd1dc 414 * @return T_pixy2ErrorCode : error code.
haarkon 5:28e47187bb5c 415 */
haarkon 11:68ef9f85e40e 416 T_pixy2ErrorCode pixy2_setServos (Word s0, Word s1);
haarkon 8:c93e1d706c0e 417
haarkon 8:c93e1d706c0e 418 /**
haarkon 8:c93e1d706c0e 419 * Sets Pixy2's RGB LED value. The three arguments sets the brightness of the red, green and blue sections of the LED.
haarkon 9:764075b514bf 420 * It will override Pixy2's own setting of the RGB LED.
haarkon 8:c93e1d706c0e 421 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
haarkon 8:c93e1d706c0e 422 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
haarkon 8:c93e1d706c0e 423 * @param red (Byte - passed by value) : Red component value (between 0 and 255)
haarkon 8:c93e1d706c0e 424 * @param green (Byte - passed by value) : Green component value (between 0 and 255)
haarkon 8:c93e1d706c0e 425 * @param blue (Byte - passed by value) : Blue component value (between 0 and 255)
haarkon 12:7493191dd1dc 426 * @return T_pixy2ErrorCode : error code.
haarkon 8:c93e1d706c0e 427 */
haarkon 11:68ef9f85e40e 428 T_pixy2ErrorCode pixy2_setLED (Byte red, Byte green, Byte blue);
haarkon 8:c93e1d706c0e 429
haarkon 8:c93e1d706c0e 430 /**
haarkon 8:c93e1d706c0e 431 * Turns on/off Pixy2's integrated light source.
haarkon 9:764075b514bf 432 * The upper argument controls the two white LEDs along the top edge of Pixy2's PCB. The lower argument sets the RGB LED, causing it to turn on all three color channels at full brightness, resulting in white light.
haarkon 9:764075b514bf 433 * It will override Pixy2's own setting of the RGB LED.
haarkon 8:c93e1d706c0e 434 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
haarkon 8:c93e1d706c0e 435 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
haarkon 8:c93e1d706c0e 436 * @param upper (Byte - passed by value) : binary, zero or non-zero
haarkon 8:c93e1d706c0e 437 * @param lower (Byte - passed by value) : binary, zero or non-zero
haarkon 12:7493191dd1dc 438 * @return T_pixy2ErrorCode : error code.
haarkon 8:c93e1d706c0e 439 */
haarkon 11:68ef9f85e40e 440 T_pixy2ErrorCode pixy2_setLamp (Byte upper, Byte lower);
haarkon 8:c93e1d706c0e 441
haarkon 8:c93e1d706c0e 442 /**
haarkon 8:c93e1d706c0e 443 * Gets Pixy2's framerate.
haarkon 8:c93e1d706c0e 444 * The framerate can range between 2 and 62 frames per second depending on the amount of light in the environment and the min frames per second setting in the Camera configuration tab.
haarkon 9:764075b514bf 445 * This function can also serve as a simple indicator of the amount of light in the environment. That is, low framerates necessarily imply lower lighting levels
haarkon 8:c93e1d706c0e 446 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
haarkon 8:c93e1d706c0e 447 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
haarkon 12:7493191dd1dc 448 * @param framerate (T_pixy2ReturnCode - passed by reference) : number of frame per second (between 2 and 62)
haarkon 12:7493191dd1dc 449 * @return T_pixy2ErrorCode : error code.
haarkon 8:c93e1d706c0e 450 */
haarkon 11:68ef9f85e40e 451 T_pixy2ErrorCode pixy2_getFPS (T_pixy2ReturnCode *framerate);
haarkon 9:764075b514bf 452
haarkon 9:764075b514bf 453 /**
haarkon 9:764075b514bf 454 * Gets all detected blocks in the most recent frame.
haarkon 9:764075b514bf 455 * The new data is then available in the blocks member variable. The returned blocks are sorted by area, with the largest blocks appearing first in the blocks array.
haarkon 9:764075b514bf 456 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:color_connected_components
haarkon 9:764075b514bf 457 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
haarkon 9:764075b514bf 458 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__ccc_api
haarkon 9:764075b514bf 459 * @param sigmap (Byte - passed by value) : signature filtering
haarkon 9:764075b514bf 460 * @param maxBloc (Byte - passed by value) : maximum number of blocks to return
haarkon 12:7493191dd1dc 461 * @return T_pixy2ErrorCode : error code.
haarkon 10:ea759846c2d5 462 * @note There are 7 different signatures definition (sig1 to sig7). Color codes are made of a combination of signature and can be filtered as well.
haarkon 10:ea759846c2d5 463 * @note Filtering is based on ORing codes : 1 for sig1, 2 for sig2, 4 for sig3, 8 for sig4, 16 for sig5, 32 for sig6, 64 sor sig7 and 128 for color code.
haarkon 10:ea759846c2d5 464 * @note So sigmap = 255 means accept all and sigmap = 0 means reject all. For example filtering to get only sig1 and sig5 means using sigmap = 17 (16 + 1).
haarkon 9:764075b514bf 465 */
haarkon 11:68ef9f85e40e 466 T_pixy2ErrorCode pixy2_getBlocks (Byte sigmap, Byte maxBloc);
haarkon 10:ea759846c2d5 467
haarkon 10:ea759846c2d5 468 /**
haarkon 10:ea759846c2d5 469 * This function gets the latest main features of Line tracking (including the Vector, any intersection that connects to the Vector, and barcodes).
haarkon 10:ea759846c2d5 470 * The results are returned in the variables vectors, intersections, and barcodes, respectively.
haarkon 10:ea759846c2d5 471 * The main feature is the feature that is the most likely to be the most relevant for line traking.
haarkon 10:ea759846c2d5 472 * In case of multiple vector (for example 2 lines unconnected), the function will return only the vector of the line you are the most likely to follow.
haarkon 10:ea759846c2d5 473 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
haarkon 10:ea759846c2d5 474 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
haarkon 10:ea759846c2d5 475 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
haarkon 10:ea759846c2d5 476 * @param feature (Byte - passed by value) : feature filtering
haarkon 12:7493191dd1dc 477 * @return T_pixy2ErrorCode : error code.
haarkon 10:ea759846c2d5 478 * @note There are 3 possible features (vectors, intersections and barcodes).
haarkon 10:ea759846c2d5 479 * @note Filtering is based on ORing codes : 1 for vectors, 2 for intersections, 4 for barcodes.
haarkon 10:ea759846c2d5 480 * @note So 7 = accept all, 0 = reject all. For example filtering to get only vectors and barcode means using feature = 5 (1 + 4).
haarkon 10:ea759846c2d5 481 */
haarkon 11:68ef9f85e40e 482 T_pixy2ErrorCode pixy2_getMainFeature (Byte features);
haarkon 10:ea759846c2d5 483
haarkon 10:ea759846c2d5 484 /**
haarkon 10:ea759846c2d5 485 * This function gets all the latest features of Line tracking (including the Vector, any intersection that connects to the Vector, and barcodes).
haarkon 10:ea759846c2d5 486 * The results are returned in the variables vectors, intersections, and barcodes, respectively.
haarkon 10:ea759846c2d5 487 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
haarkon 10:ea759846c2d5 488 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
haarkon 10:ea759846c2d5 489 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
haarkon 10:ea759846c2d5 490 * @param feature (Byte - passed by value) : feature filtering
haarkon 12:7493191dd1dc 491 * @return T_pixy2ErrorCode : error code (if negative) or ORing of feature detected (if positive).
haarkon 10:ea759846c2d5 492 * @note There are 3 possible features (vectors, intersections and barcodes).
haarkon 10:ea759846c2d5 493 * @note Filtering or the feature detected are based on ORing codes : 1 for vectors, 2 for intersections, 4 for barcodes.
haarkon 10:ea759846c2d5 494 * @note So for filtering : 7 = accept all, 0 = reject all. For example filtering to get only vectors and barcode means using feature = 5 (1 + 4).
haarkon 10:ea759846c2d5 495 * @note So for return value : 1 means only vector(s) detected, 2 means only intersection(s) detected, 3 vector(s) and intersection(s) detected and so on.
haarkon 10:ea759846c2d5 496 */
haarkon 11:68ef9f85e40e 497 T_pixy2ErrorCode pixy2_getAllFeature (Byte features);
haarkon 12:7493191dd1dc 498
haarkon 12:7493191dd1dc 499 /**
haarkon 12:7493191dd1dc 500 * This function sets various modes in the line tracking algorithm.
haarkon 12:7493191dd1dc 501 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
haarkon 12:7493191dd1dc 502 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
haarkon 12:7493191dd1dc 503 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
haarkon 12:7493191dd1dc 504 * @param mode (Byte - passed by value) : feature filtering
haarkon 12:7493191dd1dc 505 * @return T_pixy2ErrorCode : error code.
haarkon 12:7493191dd1dc 506 * @note There are 3 possible features (vectors, intersections and barcodes).
haarkon 12:7493191dd1dc 507 * @note Filtering or the feature detected are based on ORing codes : 1 for vectors, 2 for intersections, 4 for barcodes.
haarkon 12:7493191dd1dc 508 * @note So for filtering : 7 = accept all, 0 = reject all. For example filtering to get only vectors and barcode means using feature = 5 (1 + 4).
haarkon 12:7493191dd1dc 509 * @note So for return value : 1 means only vector(s) detected, 2 means only intersection(s) detected, 3 vector(s) and intersection(s) detected and so on.
haarkon 12:7493191dd1dc 510 */
haarkon 11:68ef9f85e40e 511 T_pixy2ErrorCode pixy2_setMode (Byte mode);
haarkon 11:68ef9f85e40e 512 T_pixy2ErrorCode pixy2_setNexTurn (Word angle);
haarkon 11:68ef9f85e40e 513 T_pixy2ErrorCode pixy2_setDefaultTurn (Word angle);
haarkon 11:68ef9f85e40e 514 T_pixy2ErrorCode pixy2_setVector (Byte vectorIndex);
haarkon 11:68ef9f85e40e 515 T_pixy2ErrorCode pixy2_ReverseVector (void);
haarkon 11:68ef9f85e40e 516 T_pixy2ErrorCode pixy2_getRGB (Word x, Word y, Byte saturate, T_pixy2Pixel *pixel);
haarkon 0:dde1b9d6c9d6 517
haarkon 0:dde1b9d6c9d6 518 // Variables globales Publiques
haarkon 0:dde1b9d6c9d6 519 Byte Pixy2_numBlocks;
haarkon 0:dde1b9d6c9d6 520 T_pixy2Bloc Pixy2_blocks[];
haarkon 0:dde1b9d6c9d6 521 Byte Pixy2_numVectors;
haarkon 11:68ef9f85e40e 522 T_pixy2Vector Pixy2_vectors[];
haarkon 0:dde1b9d6c9d6 523 Byte Pixy2_numIntersections;
haarkon 0:dde1b9d6c9d6 524 T_pixy2Intersection Pixy2_intersections[];
haarkon 11:68ef9f85e40e 525 T_pixy2InterLine Pixy2_intLines[];
haarkon 0:dde1b9d6c9d6 526 Byte Pixy2_numBarcodes;
haarkon 0:dde1b9d6c9d6 527 T_pixy2BarCode Pixy2_barcodes[];
haarkon 0:dde1b9d6c9d6 528
haarkon 0:dde1b9d6c9d6 529 private :
haarkon 0:dde1b9d6c9d6 530 // Variables globales Privées
haarkon 0:dde1b9d6c9d6 531 T_Pixy2State etat;
haarkon 0:dde1b9d6c9d6 532 Byte* Pixy2_buffer;
haarkon 0:dde1b9d6c9d6 533 Byte wPointer, rPointer, dataSize;
haarkon 0:dde1b9d6c9d6 534 Byte frameContainChecksum;
haarkon 0:dde1b9d6c9d6 535
haarkon 0:dde1b9d6c9d6 536 // Fonctions privées
haarkon 11:68ef9f85e40e 537 T_pixy2ErrorCode pixy2_sndGetVersion (void);
haarkon 11:68ef9f85e40e 538 T_pixy2ErrorCode pixy2_sndGetResolution (void);
haarkon 11:68ef9f85e40e 539 T_pixy2ErrorCode pixy2_sndSetCameraBrightness (Byte brightness);
haarkon 11:68ef9f85e40e 540 T_pixy2ErrorCode pixy2_sndSetServo (Word s0, Word s1);
haarkon 11:68ef9f85e40e 541 T_pixy2ErrorCode pixy2_sndSetLED (Byte red, Byte green, Byte blue);
haarkon 11:68ef9f85e40e 542 T_pixy2ErrorCode pixy2_sndSetLamp (Byte upper, Byte lower);
haarkon 11:68ef9f85e40e 543 T_pixy2ErrorCode pixy2_sndGetFPS (void);
haarkon 11:68ef9f85e40e 544 T_pixy2ErrorCode pixy2_sndGetBlocks (Byte sigmap, Byte maxBloc);
haarkon 11:68ef9f85e40e 545 T_pixy2ErrorCode pixy2_sndGetMainFeature (Byte type, Byte feature);
haarkon 11:68ef9f85e40e 546 T_pixy2ErrorCode pixy2_sndSetMode (Byte mode);
haarkon 11:68ef9f85e40e 547 T_pixy2ErrorCode pixy2_sndSetNexTurn (Word angle);
haarkon 11:68ef9f85e40e 548 T_pixy2ErrorCode pixy2_sndSetDefaultTurn (Word angle);
haarkon 11:68ef9f85e40e 549 T_pixy2ErrorCode pixy2_sndSetVector (Byte vectorIndex);
haarkon 11:68ef9f85e40e 550 T_pixy2ErrorCode pixy2_sndReverseVector (void);
haarkon 11:68ef9f85e40e 551 T_pixy2ErrorCode pixy2_sndGetRGB (Word x, Word y, Byte saturate);
haarkon 0:dde1b9d6c9d6 552
haarkon 0:dde1b9d6c9d6 553 void pixy2_getByte ();
haarkon 11:68ef9f85e40e 554 T_pixy2ErrorCode pixy2_validateChecksum (Byte* tab);
haarkon 0:dde1b9d6c9d6 555 };
haarkon 0:dde1b9d6c9d6 556
haarkon 0:dde1b9d6c9d6 557 #endif