NXPCup_Cachan / Mbed 2 deprecated NXPCup

Dependencies:   mbed

Committer:
Wael_H
Date:
Tue Feb 11 15:41:45 2020 +0000
Revision:
0:8743b606abc3
Version direction a peu pres

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wael_H 0:8743b606abc3 1 /**
Wael_H 0:8743b606abc3 2 * @author Hugues Angelis
Wael_H 0:8743b606abc3 3 *
Wael_H 0:8743b606abc3 4 * @section LICENSE
Wael_H 0:8743b606abc3 5 *
Wael_H 0:8743b606abc3 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
Wael_H 0:8743b606abc3 7 * of this software and associated documentation files (the "Software"), to deal
Wael_H 0:8743b606abc3 8 * in the Software without restriction, including without limitation the rights
Wael_H 0:8743b606abc3 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Wael_H 0:8743b606abc3 10 * copies of the Software, and to permit persons to whom the Software is
Wael_H 0:8743b606abc3 11 * furnished to do so, subject to the following conditions:
Wael_H 0:8743b606abc3 12 *
Wael_H 0:8743b606abc3 13 * The above copyright notice and this permission notice shall be included in
Wael_H 0:8743b606abc3 14 * all copies or substantial portions of the Software.
Wael_H 0:8743b606abc3 15 *
Wael_H 0:8743b606abc3 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Wael_H 0:8743b606abc3 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Wael_H 0:8743b606abc3 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Wael_H 0:8743b606abc3 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Wael_H 0:8743b606abc3 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Wael_H 0:8743b606abc3 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Wael_H 0:8743b606abc3 22 * THE SOFTWARE.
Wael_H 0:8743b606abc3 23 *
Wael_H 0:8743b606abc3 24 * @section DESCRIPTION
Wael_H 0:8743b606abc3 25 *
Wael_H 0:8743b606abc3 26 * CMUCAM 5 - Pixy2
Wael_H 0:8743b606abc3 27 *
Wael_H 0:8743b606abc3 28 * Datasheet, FAQ and PC drivers :
Wael_H 0:8743b606abc3 29 *
Wael_H 0:8743b606abc3 30 * http://www.pixycam.com/
Wael_H 0:8743b606abc3 31 */
Wael_H 0:8743b606abc3 32
Wael_H 0:8743b606abc3 33 #ifndef _PIXY2_
Wael_H 0:8743b606abc3 34 #define _PIXY2_
Wael_H 0:8743b606abc3 35
Wael_H 0:8743b606abc3 36 /**
Wael_H 0:8743b606abc3 37 * Include : Mbed Library
Wael_H 0:8743b606abc3 38 */
Wael_H 0:8743b606abc3 39 #include "mbed.h"
Wael_H 0:8743b606abc3 40
Wael_H 0:8743b606abc3 41 /**
Wael_H 0:8743b606abc3 42 * Defines
Wael_H 0:8743b606abc3 43 */
Wael_H 0:8743b606abc3 44 #define _DEBUG_ 1
Wael_H 0:8743b606abc3 45 #define PIXY2_NCSHEADERSIZE 4
Wael_H 0:8743b606abc3 46 #define PIXY2_CSHEADERSIZE 6 // Possible erreur : Ancienne valeur 4
Wael_H 0:8743b606abc3 47 #define PIXY2_SYNC 0xC1AE
Wael_H 0:8743b606abc3 48 #define PIXY2_CSSYNC 0xC1AF
Wael_H 0:8743b606abc3 49 #define PIXY2_REP_ACK 1
Wael_H 0:8743b606abc3 50 #define PIXY2_REP_ERROR 3
Wael_H 0:8743b606abc3 51 #define PIXY2_ASK_RESOL 12
Wael_H 0:8743b606abc3 52 #define PIXY2_REP_RESOL 13
Wael_H 0:8743b606abc3 53 #define PIXY2_ASK_VERS 14
Wael_H 0:8743b606abc3 54 #define PIXY2_REP_VERS 15
Wael_H 0:8743b606abc3 55 #define PIXY2_SET_BRIGHT 16
Wael_H 0:8743b606abc3 56 #define PIXY2_SET_SERVOS 18
Wael_H 0:8743b606abc3 57 #define PIXY2_SET_LED 20
Wael_H 0:8743b606abc3 58 #define PIXY2_SET_LAMP 22
Wael_H 0:8743b606abc3 59 #define PIXY2_ASK_FPS 24
Wael_H 0:8743b606abc3 60 #define PIXY2_REP_FPS 1
Wael_H 0:8743b606abc3 61 #define PIXY2_ASK_BLOC 32
Wael_H 0:8743b606abc3 62 #define PIXY2_REP_BLOC 33
Wael_H 0:8743b606abc3 63 #define PIXY2_ASK_LINE 48
Wael_H 0:8743b606abc3 64 #define PIXY2_REP_LINE 49
Wael_H 0:8743b606abc3 65 #define PIXY2_SET_MODE 54
Wael_H 0:8743b606abc3 66 #define PIXY2_SET_TURN 58
Wael_H 0:8743b606abc3 67 #define PIXY2_SET_VECTOR 56
Wael_H 0:8743b606abc3 68 #define PIXY2_SET_DEFTURN 60
Wael_H 0:8743b606abc3 69 #define PIXY2_SET_REVERSE 62
Wael_H 0:8743b606abc3 70 #define PIXY2_ASK_VIDEO 112
Wael_H 0:8743b606abc3 71 #define PIXY2_VECTOR 1
Wael_H 0:8743b606abc3 72 #define PIXY2_INTERSECTION 2
Wael_H 0:8743b606abc3 73 #define PIXY2_BARCODE 4
Wael_H 0:8743b606abc3 74 #define PIXY2_MAX_INT_LINE 6
Wael_H 0:8743b606abc3 75
Wael_H 0:8743b606abc3 76 /**************** ERRORS ****************/
Wael_H 0:8743b606abc3 77
Wael_H 0:8743b606abc3 78 /**
Wael_H 0:8743b606abc3 79 * \struct T_pixy2ErrorCode
Wael_H 0:8743b606abc3 80 * \brief Explicit error code list :
Wael_H 0:8743b606abc3 81 * \param PIXY2_OK : No error
Wael_H 0:8743b606abc3 82 * \param PIXY2_MISC_ERROR : Generic error
Wael_H 0:8743b606abc3 83 * \param PIXY2_BUSY : Pixy is busy (the response message is not yet fully arrived)
Wael_H 0:8743b606abc3 84 * \param PIXY2_BAD_CHECKSUM : Checksum is wrong
Wael_H 0:8743b606abc3 85 * \param PIXY2_TIMEOUT : Pixy2 is not talking
Wael_H 0:8743b606abc3 86 * \param PIXY2_BUTTON_OVERRIDE : User is manualy operating the button of the Pixy2
Wael_H 0:8743b606abc3 87 * \param PIXY2_PROG_CHANGE : Checksum is wrong
Wael_H 0:8743b606abc3 88 * \param PIXY2_TYPE_ERROR : Unexpected message type
Wael_H 0:8743b606abc3 89 * @note More documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api#error-codes
Wael_H 0:8743b606abc3 90 */
Wael_H 0:8743b606abc3 91 typedef int T_pixy2ErrorCode;
Wael_H 0:8743b606abc3 92
Wael_H 0:8743b606abc3 93 #define PIXY2_OK 0
Wael_H 0:8743b606abc3 94 #define PIXY2_MISC_ERROR -1
Wael_H 0:8743b606abc3 95 #define PIXY2_BUSY -2
Wael_H 0:8743b606abc3 96 #define PIXY2_BAD_CHECKSUM -3
Wael_H 0:8743b606abc3 97 #define PIXY2_TIMEOUT -4
Wael_H 0:8743b606abc3 98 #define PIXY2_OVERRIDE -5
Wael_H 0:8743b606abc3 99 #define PIXY2_PROG_CHANGE -6
Wael_H 0:8743b606abc3 100 #define PIXY2_TYPE_ERROR -7
Wael_H 0:8743b606abc3 101
Wael_H 0:8743b606abc3 102 /**************** STATE MACHINE ****************/
Wael_H 0:8743b606abc3 103
Wael_H 0:8743b606abc3 104 typedef enum {idle, messageSent, receivingHeader, receivingData, dataReceived} T_Pixy2State;
Wael_H 0:8743b606abc3 105
Wael_H 0:8743b606abc3 106 /**************** UTILS ****************/
Wael_H 0:8743b606abc3 107
Wael_H 0:8743b606abc3 108
Wael_H 0:8743b606abc3 109 /**
Wael_H 0:8743b606abc3 110 * \struct Byte -> Short hand for unsigned char
Wael_H 0:8743b606abc3 111 * \struct sByte -> Short hand for char
Wael_H 0:8743b606abc3 112 * \struct Word -> Short hand for unsigned short
Wael_H 0:8743b606abc3 113 * \struct sWord -> Short hand for short
Wael_H 0:8743b606abc3 114 * \struct lWord -> Short hand for unsigned long
Wael_H 0:8743b606abc3 115 * \struct slWord -> Short hand for long
Wael_H 0:8743b606abc3 116 */
Wael_H 0:8743b606abc3 117 typedef unsigned char Byte;
Wael_H 0:8743b606abc3 118 typedef char sByte;
Wael_H 0:8743b606abc3 119 typedef unsigned short Word;
Wael_H 0:8743b606abc3 120 typedef short sWord;
Wael_H 0:8743b606abc3 121 typedef unsigned long lWord;
Wael_H 0:8743b606abc3 122 typedef long slWord;
Wael_H 0:8743b606abc3 123
Wael_H 0:8743b606abc3 124 /**
Wael_H 0:8743b606abc3 125 * \union T_Word
Wael_H 0:8743b606abc3 126 * \brief Structured type to switch from word to bytes
Wael_H 0:8743b606abc3 127 * \param mot (Word) : 16 bits word
Wael_H 0:8743b606abc3 128 * \param octet (Byte) : 2 bytes that overlap mot (byte access)
Wael_H 0:8743b606abc3 129 */
Wael_H 0:8743b606abc3 130 typedef union {
Wael_H 0:8743b606abc3 131 Word mot;
Wael_H 0:8743b606abc3 132 Byte octet[2];
Wael_H 0:8743b606abc3 133 }T_Word;
Wael_H 0:8743b606abc3 134
Wael_H 0:8743b606abc3 135 /**
Wael_H 0:8743b606abc3 136 * \union T_lWord
Wael_H 0:8743b606abc3 137 * \brief Structured type to switch from lword to word or bytes
Wael_H 0:8743b606abc3 138 * \param motLong (lWord) : 32 bits word
Wael_H 0:8743b606abc3 139 * \param mot (Word) : 2 x 16 bits words that overlap motLong (word access)
Wael_H 0:8743b606abc3 140 * \param octet (Byte) : 4 bytes that overlap motLong (byte access)
Wael_H 0:8743b606abc3 141 */
Wael_H 0:8743b606abc3 142 typedef union {
Wael_H 0:8743b606abc3 143 lWord motLong;
Wael_H 0:8743b606abc3 144 Word mot[2];
Wael_H 0:8743b606abc3 145 Byte octet[4];
Wael_H 0:8743b606abc3 146 }T_lWord;
Wael_H 0:8743b606abc3 147
Wael_H 0:8743b606abc3 148
Wael_H 0:8743b606abc3 149 /**************** HEADERS ****************/
Wael_H 0:8743b606abc3 150
Wael_H 0:8743b606abc3 151 /**
Wael_H 0:8743b606abc3 152 * \struct T_pixy2Header
Wael_H 0:8743b606abc3 153 * \brief Structured type that match pixy2 header without checksum (send message)
Wael_H 0:8743b606abc3 154 * \param pixSync (Word) : 16 bits synchro word - could be 0xc1ae (PIXY2_SYNC) or 0xc1af (PIXY2_CSSYNC)
Wael_H 0:8743b606abc3 155 * \param pixType (Byte) : 8 bits message type identifier
Wael_H 0:8743b606abc3 156 * \param pixLength (Byte) : 8 bits message payload length (payload doesn't include checksum)
Wael_H 0:8743b606abc3 157 */
Wael_H 0:8743b606abc3 158 typedef struct {
Wael_H 0:8743b606abc3 159 Word pixSync;
Wael_H 0:8743b606abc3 160 Byte pixType;
Wael_H 0:8743b606abc3 161 Byte pixLength;
Wael_H 0:8743b606abc3 162 }T_pixy2Header;
Wael_H 0:8743b606abc3 163
Wael_H 0:8743b606abc3 164 /**
Wael_H 0:8743b606abc3 165 * \struct T_pixy2SendFrame
Wael_H 0:8743b606abc3 166 * \brief Structured type that match frame definition for all kind of message to send to a pixy2
Wael_H 0:8743b606abc3 167 * \param header (T_pixy2Header) : 4 bytes classical header starting with PIXY2_SYNC
Wael_H 0:8743b606abc3 168 * \param data (Byte) : 5 bytes payload (to match all usage, not all byte must be used)
Wael_H 0:8743b606abc3 169 */
Wael_H 0:8743b606abc3 170 typedef struct {
Wael_H 0:8743b606abc3 171 T_pixy2Header header;
Wael_H 0:8743b606abc3 172 Byte data[5];
Wael_H 0:8743b606abc3 173 }T_pixy2SendFrame;
Wael_H 0:8743b606abc3 174
Wael_H 0:8743b606abc3 175 /**
Wael_H 0:8743b606abc3 176 * \union T_pixy2SendBuffer
Wael_H 0:8743b606abc3 177 * \brief Structured type to switch between structured type T_pixy2sendFrame and bytes
Wael_H 0:8743b606abc3 178 * \param frame (T_pixy2SendFrame) : classical frame (header + payload) starting with PIXY2_SYNC
Wael_H 0:8743b606abc3 179 * \param data (Byte) : 9 bytes that overlap frame (byte access)
Wael_H 0:8743b606abc3 180 */
Wael_H 0:8743b606abc3 181 typedef union {
Wael_H 0:8743b606abc3 182 T_pixy2SendFrame frame;
Wael_H 0:8743b606abc3 183 Byte data[9];
Wael_H 0:8743b606abc3 184 }T_pixy2SendBuffer;
Wael_H 0:8743b606abc3 185
Wael_H 0:8743b606abc3 186 /**
Wael_H 0:8743b606abc3 187 * \struct T_pixy2RcvHeader
Wael_H 0:8743b606abc3 188 * \brief Structured type that match pixy2 header with checksum (received message)
Wael_H 0:8743b606abc3 189 * \param pixSync (Word) : 16 bits synchro word - could be 0xc1ae (PIXY2_SYNC) or 0xc1af (PIXY2_CSSYNC)
Wael_H 0:8743b606abc3 190 * \param pixType (Byte) : 8 bits message type identifier
Wael_H 0:8743b606abc3 191 * \param pixLength (Byte) : 8 bits message payload length (payload doesn't include checksum)
Wael_H 0:8743b606abc3 192 * \param pixSync (Word) : 16 bits checksum (sum of all bytes of the payload)
Wael_H 0:8743b606abc3 193 */
Wael_H 0:8743b606abc3 194 typedef struct {
Wael_H 0:8743b606abc3 195 Word pixSync;
Wael_H 0:8743b606abc3 196 Byte pixType;
Wael_H 0:8743b606abc3 197 Byte pixLength;
Wael_H 0:8743b606abc3 198 Word pixChecksum;
Wael_H 0:8743b606abc3 199 }T_pixy2RcvHeader;
Wael_H 0:8743b606abc3 200
Wael_H 0:8743b606abc3 201
Wael_H 0:8743b606abc3 202 /**************** PAYLOADS ****************/
Wael_H 0:8743b606abc3 203
Wael_H 0:8743b606abc3 204 /**
Wael_H 0:8743b606abc3 205 * \struct T_pixy2ReturnCode
Wael_H 0:8743b606abc3 206 * \brief Structured type that match pixy2 error/acknowledge/reply frame (type = 1 or 3) message payload
Wael_H 0:8743b606abc3 207 * \param pixReturn (lWord) : 32 bits returned value
Wael_H 0:8743b606abc3 208 */
Wael_H 0:8743b606abc3 209 typedef struct {
Wael_H 0:8743b606abc3 210 lWord pixReturn;
Wael_H 0:8743b606abc3 211 }T_pixy2ReturnCode;
Wael_H 0:8743b606abc3 212
Wael_H 0:8743b606abc3 213 /**
Wael_H 0:8743b606abc3 214 * \struct T_pixy2Version
Wael_H 0:8743b606abc3 215 * \brief Structured type that match pixy2 version frame (type = 14/15) message payload
Wael_H 0:8743b606abc3 216 * \param pixHWVersion (Word) : 16 bits hardWare Version of pixy2
Wael_H 0:8743b606abc3 217 * \param pixFWVersionMaj (Byte) : 8 bits upper part of firmware (before the dot)
Wael_H 0:8743b606abc3 218 * \param pixFWVersionMin (Byte) : 8 bits lower part of firmware (after the dot)
Wael_H 0:8743b606abc3 219 * \param pixFWBuild (Word) : 16 bits firmware build information
Wael_H 0:8743b606abc3 220 * \param pixHFString (String) : 10 bytes user friendly pixy2 firmware type
Wael_H 0:8743b606abc3 221 */
Wael_H 0:8743b606abc3 222 typedef struct {
Wael_H 0:8743b606abc3 223 Word pixHWVersion;
Wael_H 0:8743b606abc3 224 Byte pixFWVersionMaj;
Wael_H 0:8743b606abc3 225 Byte pixFWVersionMin;
Wael_H 0:8743b606abc3 226 Word pixFWBuild;
Wael_H 0:8743b606abc3 227 char pixHFString[10];
Wael_H 0:8743b606abc3 228 }T_pixy2Version;
Wael_H 0:8743b606abc3 229
Wael_H 0:8743b606abc3 230 /**
Wael_H 0:8743b606abc3 231 * \struct T_pixy2Resolution
Wael_H 0:8743b606abc3 232 * \brief Structured type that match pixy2 resolution frame (type = 12/13) message payload
Wael_H 0:8743b606abc3 233 * \param pixFrameWidth (Word) : 16 bits width (in pixel) of an image
Wael_H 0:8743b606abc3 234 * \param pixFrameHeight (Word) : 16 bits height (in pixel) of an image
Wael_H 0:8743b606abc3 235 */
Wael_H 0:8743b606abc3 236 typedef struct {
Wael_H 0:8743b606abc3 237 Word pixFrameWidth;
Wael_H 0:8743b606abc3 238 Word pixFrameHeight;
Wael_H 0:8743b606abc3 239 }T_pixy2Resolution;
Wael_H 0:8743b606abc3 240
Wael_H 0:8743b606abc3 241 /**
Wael_H 0:8743b606abc3 242 * \struct T_pixy2Bloc
Wael_H 0:8743b606abc3 243 * \brief Structured type that match pixy2 blocks frame (type = 32/33) message payload
Wael_H 0:8743b606abc3 244 * \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)
Wael_H 0:8743b606abc3 245 * \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)
Wael_H 0:8743b606abc3 246 * \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)
Wael_H 0:8743b606abc3 247 * \param pixWidth (Word) : 16 bits width (in pixels, between 0 and 316) of color bloc
Wael_H 0:8743b606abc3 248 * \param pixHeight (Word) : 16 bits height (in pixels, between 0 and 208) of color bloc
Wael_H 0:8743b606abc3 249 * \param pixAngle (sWord) : 16 bits angle (in degree, between -180.0 and +180.0) of a color code bloc
Wael_H 0:8743b606abc3 250 * \param pixIndex (Byte) : 8 bits tracking identification of the color code bloc (set by pixy2 to ease a bloc position following program)
Wael_H 0:8743b606abc3 251 * \param pixAge (Byte) : 8 bits age (in number of frame) of a bloc (doesn't wrap around).
Wael_H 0:8743b606abc3 252 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:ccc_api
Wael_H 0:8743b606abc3 253 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:color_connected_components
Wael_H 0:8743b606abc3 254 */
Wael_H 0:8743b606abc3 255 typedef struct {
Wael_H 0:8743b606abc3 256 Word pixSignature;
Wael_H 0:8743b606abc3 257 Word pixX;
Wael_H 0:8743b606abc3 258 Word pixY;
Wael_H 0:8743b606abc3 259 Word pixWidth;
Wael_H 0:8743b606abc3 260 Word pixHeight;
Wael_H 0:8743b606abc3 261 sWord pixAngle;
Wael_H 0:8743b606abc3 262 Byte pixIndex;
Wael_H 0:8743b606abc3 263 Byte pixAge;
Wael_H 0:8743b606abc3 264 }T_pixy2Bloc;
Wael_H 0:8743b606abc3 265
Wael_H 0:8743b606abc3 266 /**
Wael_H 0:8743b606abc3 267 * \struct T_pixy2Vector
Wael_H 0:8743b606abc3 268 * \brief Structured type that match pixy2 vector definition - used in Line frame (type 48/49) - message payload
Wael_H 0:8743b606abc3 269 * \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)
Wael_H 0:8743b606abc3 270 * \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)
Wael_H 0:8743b606abc3 271 * \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)
Wael_H 0:8743b606abc3 272 * \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)
Wael_H 0:8743b606abc3 273 * \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)
Wael_H 0:8743b606abc3 274 * \param pixFlags (Byte) : 8 bits flag containing possible usefull informations (see notes)
Wael_H 0:8743b606abc3 275 * @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
Wael_H 0:8743b606abc3 276 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api
Wael_H 0:8743b606abc3 277 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 278 */
Wael_H 0:8743b606abc3 279 typedef struct {
Wael_H 0:8743b606abc3 280 Byte pixX0;
Wael_H 0:8743b606abc3 281 Byte pixY0;
Wael_H 0:8743b606abc3 282 Byte pixX1;
Wael_H 0:8743b606abc3 283 Byte pixY1;
Wael_H 0:8743b606abc3 284 Byte pixIndex;
Wael_H 0:8743b606abc3 285 Byte pixFlags;
Wael_H 0:8743b606abc3 286 }T_pixy2Vector;
Wael_H 0:8743b606abc3 287
Wael_H 0:8743b606abc3 288 /**
Wael_H 0:8743b606abc3 289 * \struct T_pixy2InterLine
Wael_H 0:8743b606abc3 290 * \brief Structured type that match pixy2 intersection line definition - used in Line frame (type 48/49) - message payload
Wael_H 0:8743b606abc3 291 * \param pixIndex (Byte) : 8 bits tracking identification of the intersection line (set by pixy2 to ease a line following program)
Wael_H 0:8743b606abc3 292 * \param pixReserved (Byte) : Not documented by manufacturer
Wael_H 0:8743b606abc3 293 * \param pixAngle (sWord) : 16 bits angle (in degree, between -180.0 and +180.0) of the intersection line
Wael_H 0:8743b606abc3 294 * @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
Wael_H 0:8743b606abc3 295 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api
Wael_H 0:8743b606abc3 296 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 297 */
Wael_H 0:8743b606abc3 298 typedef struct {
Wael_H 0:8743b606abc3 299 Byte pixIndex;
Wael_H 0:8743b606abc3 300 Byte pixReserved;
Wael_H 0:8743b606abc3 301 sWord pixAngle;
Wael_H 0:8743b606abc3 302 }T_pixy2InterLine;
Wael_H 0:8743b606abc3 303
Wael_H 0:8743b606abc3 304 /**
Wael_H 0:8743b606abc3 305 * \struct T_pixy2Intersection
Wael_H 0:8743b606abc3 306 * \brief Structured type that match pixy2 intersection definition - used in Line frame (type 48/49) - message payload
Wael_H 0:8743b606abc3 307 * \param pixX (Byte) : X axis coordinate of the intersection (in pixel, between 0 and 78)
Wael_H 0:8743b606abc3 308 * \param pixY (Byte) : Y axis coordinate of the intersection (in pixel, between 0 and 51)
Wael_H 0:8743b606abc3 309 * \param pixN (Byte) : Number of lines connected to the intersection (between 3 and 5)
Wael_H 0:8743b606abc3 310 * \param pixReserved (Byte) : Not documented by manufacturer
Wael_H 0:8743b606abc3 311 * @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
Wael_H 0:8743b606abc3 312 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api
Wael_H 0:8743b606abc3 313 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 314 */
Wael_H 0:8743b606abc3 315 typedef struct {
Wael_H 0:8743b606abc3 316 Byte pixX;
Wael_H 0:8743b606abc3 317 Byte pixY;
Wael_H 0:8743b606abc3 318 Byte pixN;
Wael_H 0:8743b606abc3 319 Byte pixReserved;
Wael_H 0:8743b606abc3 320 T_pixy2InterLine PixintLines[PIXY2_MAX_INT_LINE];
Wael_H 0:8743b606abc3 321 }T_pixy2Intersection;
Wael_H 0:8743b606abc3 322
Wael_H 0:8743b606abc3 323 /**
Wael_H 0:8743b606abc3 324 * \struct T_pixy2BarCode
Wael_H 0:8743b606abc3 325 * \brief Structured type that match pixy2 barcode definition - used in Line frame (type 48/49) - message payload
Wael_H 0:8743b606abc3 326 * \param pixX (Byte) : X axis coordinate of the barcode (in pixel, between 0 and 78)
Wael_H 0:8743b606abc3 327 * \param pixY (Byte) : Y axis coordinate of the barcode (in pixel, between 0 and 51)
Wael_H 0:8743b606abc3 328 * \param pixFlag (Byte) : Flag to indicate if barcode met filtering constraint
Wael_H 0:8743b606abc3 329 * \param pixCode (Byte) : Indicate the numeric value associated with the barcode (between 0 and 15)
Wael_H 0:8743b606abc3 330 * @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
Wael_H 0:8743b606abc3 331 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api
Wael_H 0:8743b606abc3 332 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 333 */
Wael_H 0:8743b606abc3 334 typedef struct {
Wael_H 0:8743b606abc3 335 Byte pixX;
Wael_H 0:8743b606abc3 336 Byte pixY;
Wael_H 0:8743b606abc3 337 Byte pixFlag;
Wael_H 0:8743b606abc3 338 Byte pixCode;
Wael_H 0:8743b606abc3 339 }T_pixy2BarCode;
Wael_H 0:8743b606abc3 340
Wael_H 0:8743b606abc3 341 /**
Wael_H 0:8743b606abc3 342 * \struct T_pixy2LineFeature
Wael_H 0:8743b606abc3 343 * \brief Structured type that match pixy2 feature header for Line API - used in Line frame (type 48/49) - message payload
Wael_H 0:8743b606abc3 344 * \param pixType (Byte) : Type of the feature (can be 1 -> Vector, 2 -> Intersection or 4 -> Barcode)
Wael_H 0:8743b606abc3 345 * \param pixLength (Byte) : Number of Bytes for this feature
Wael_H 0:8743b606abc3 346 * @note This structure is the header of features of Line API in Line Frames. They can be up to 4 features in a frame. Documented here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference
Wael_H 0:8743b606abc3 347 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api
Wael_H 0:8743b606abc3 348 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 349 */
Wael_H 0:8743b606abc3 350 typedef struct {
Wael_H 0:8743b606abc3 351 Byte fType;
Wael_H 0:8743b606abc3 352 Byte fLength;
Wael_H 0:8743b606abc3 353 }T_pixy2LineFeature;
Wael_H 0:8743b606abc3 354
Wael_H 0:8743b606abc3 355 /**
Wael_H 0:8743b606abc3 356 * \struct T_pixy2Pixel
Wael_H 0:8743b606abc3 357 * \brief Structured type that match pixy2 video API - used in Video frame (type 112/1) - message payload
Wael_H 0:8743b606abc3 358 * \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)
Wael_H 0:8743b606abc3 359 * \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)
Wael_H 0:8743b606abc3 360 * \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)
Wael_H 0:8743b606abc3 361 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video_api
Wael_H 0:8743b606abc3 362 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video
Wael_H 0:8743b606abc3 363 */
Wael_H 0:8743b606abc3 364 typedef struct {
Wael_H 0:8743b606abc3 365 Byte pixBlue;
Wael_H 0:8743b606abc3 366 Byte pixGreen;
Wael_H 0:8743b606abc3 367 Byte pixRed;
Wael_H 0:8743b606abc3 368 }T_pixy2Pixel;
Wael_H 0:8743b606abc3 369
Wael_H 0:8743b606abc3 370 /**
Wael_H 0:8743b606abc3 371 * Pixy2 : CMU CAM 5 - Smart camera
Wael_H 0:8743b606abc3 372 * More informations at http://www.pixycam.com/
Wael_H 0:8743b606abc3 373 * Use pointer to pointer in order to connect pointer adress (passed by ref by user)
Wael_H 0:8743b606abc3 374 * to the address of the buffer that contains the received message : see example below
Wael_H 0:8743b606abc3 375 * \code
Wael_H 0:8743b606abc3 376 * // Creation of Pixy2 object
Wael_H 0:8743b606abc3 377 * PIXY2 myPixy(UART_TX, UART_RX);
Wael_H 0:8743b606abc3 378 * ...
Wael_H 0:8743b606abc3 379 * // Creation of a pointer to the structure T_pixy2Version
Wael_H 0:8743b606abc3 380 * T_pixy2Version *pixyVersion;
Wael_H 0:8743b606abc3 381 * ...
Wael_H 0:8743b606abc3 382 * // Call for version on Pixy2 (that will be put inside the pointing structure)
Wael_H 0:8743b606abc3 383 * if (myPixy.pixy2_getVersion(&pixyVersion) == PIXY2_OK)
Wael_H 0:8743b606abc3 384 * ...
Wael_H 0:8743b606abc3 385 * // Printing Human friendly string (see Pixy2 doc for details)
Wael_H 0:8743b606abc3 386 * printf("myPixy's version : %s\n\r", pixyVersion->pixHFString);
Wael_H 0:8743b606abc3 387 * ...
Wael_H 0:8743b606abc3 388 * \endcode
Wael_H 0:8743b606abc3 389 */
Wael_H 0:8743b606abc3 390 class PIXY2 {
Wael_H 0:8743b606abc3 391
Wael_H 0:8743b606abc3 392 protected :
Wael_H 0:8743b606abc3 393
Wael_H 0:8743b606abc3 394 Serial* _Pixy2;
Wael_H 0:8743b606abc3 395
Wael_H 0:8743b606abc3 396 public :
Wael_H 0:8743b606abc3 397 /**
Wael_H 0:8743b606abc3 398 * Constructor of pixy2 UART object.
Wael_H 0:8743b606abc3 399 *
Wael_H 0:8743b606abc3 400 * @param tx : the Mbed pin used as TX
Wael_H 0:8743b606abc3 401 * @param rx : the Mbed pin used as RX
Wael_H 0:8743b606abc3 402 * @param debit : the bitrate of the serial (max value is 230 kbaud/s)
Wael_H 0:8743b606abc3 403 */
Wael_H 0:8743b606abc3 404 PIXY2(PinName tx, PinName rx, int debit = 230000);
Wael_H 0:8743b606abc3 405
Wael_H 0:8743b606abc3 406 /**
Wael_H 0:8743b606abc3 407 * Destructor of pixy2 UART object.
Wael_H 0:8743b606abc3 408 */
Wael_H 0:8743b606abc3 409 ~PIXY2();
Wael_H 0:8743b606abc3 410
Wael_H 0:8743b606abc3 411 // POUR DEBUG //
Wael_H 0:8743b606abc3 412 T_Pixy2State getEtat();
Wael_H 0:8743b606abc3 413 void affDataSize();
Wael_H 0:8743b606abc3 414
Wael_H 0:8743b606abc3 415 // Fonctions publiques
Wael_H 0:8743b606abc3 416
Wael_H 0:8743b606abc3 417 /**
Wael_H 0:8743b606abc3 418 * Queries and receives the firmware and hardware version of Pixy2, which is put in the version member variable.
Wael_H 0:8743b606abc3 419 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 420 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 421 * @param ptrVersion (T_pixy2Version - passed by reference) : pointer to a pointer of the version data structure
Wael_H 0:8743b606abc3 422 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 423 */
Wael_H 0:8743b606abc3 424 T_pixy2ErrorCode pixy2_getVersion (T_pixy2Version **ptrVersion); // fonctionnelle
Wael_H 0:8743b606abc3 425
Wael_H 0:8743b606abc3 426 /**
Wael_H 0:8743b606abc3 427 * Gets the width and height of the frames used by the current program.
Wael_H 0:8743b606abc3 428 * After calling this function, the width and height can be found in the frameWidth and frameHeight member variables.
Wael_H 0:8743b606abc3 429 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 430 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 431 * @param ptrResolution (T_pixy2Resolution - passed by reference) : pointer to a pointer of the resolution data structure
Wael_H 0:8743b606abc3 432 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 433 */
Wael_H 0:8743b606abc3 434 T_pixy2ErrorCode pixy2_getResolution (T_pixy2Resolution **ptrResolution); // fonctionnelle
Wael_H 0:8743b606abc3 435
Wael_H 0:8743b606abc3 436 /**
Wael_H 0:8743b606abc3 437 * Sets the relative exposure level of Pixy2's image sensor.
Wael_H 0:8743b606abc3 438 * Higher values result in a brighter (more exposed) image.
Wael_H 0:8743b606abc3 439 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 440 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 441 * @param brightness (Byte - passed by value) : brightness level
Wael_H 0:8743b606abc3 442 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 443 */
Wael_H 0:8743b606abc3 444 T_pixy2ErrorCode pixy2_setCameraBrightness (Byte brightness); // fonctionnelle
Wael_H 0:8743b606abc3 445
Wael_H 0:8743b606abc3 446 /**
Wael_H 0:8743b606abc3 447 * Sets the servo positions of servos plugged into Pixy2's two RC servo connectors.
Wael_H 0:8743b606abc3 448 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 449 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 450 * @param s0 (Word - passed by value) : value between 0 and 511
Wael_H 0:8743b606abc3 451 * @param s1 (Word - passed by value) : value between 0 and 511
Wael_H 0:8743b606abc3 452 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 453 */
Wael_H 0:8743b606abc3 454 T_pixy2ErrorCode pixy2_setServos (Word s0, Word s1); // plus tard
Wael_H 0:8743b606abc3 455
Wael_H 0:8743b606abc3 456 /**
Wael_H 0:8743b606abc3 457 * Sets Pixy2's RGB LED value. The three arguments sets the brightness of the red, green and blue sections of the LED.
Wael_H 0:8743b606abc3 458 * It will override Pixy2's own setting of the RGB LED.
Wael_H 0:8743b606abc3 459 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 460 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 461 * @param red (Byte - passed by value) : Red component value (between 0 and 255)
Wael_H 0:8743b606abc3 462 * @param green (Byte - passed by value) : Green component value (between 0 and 255)
Wael_H 0:8743b606abc3 463 * @param blue (Byte - passed by value) : Blue component value (between 0 and 255)
Wael_H 0:8743b606abc3 464 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 465 */
Wael_H 0:8743b606abc3 466 T_pixy2ErrorCode pixy2_setLED (Byte red, Byte green, Byte blue); // fonctionnelle
Wael_H 0:8743b606abc3 467
Wael_H 0:8743b606abc3 468 /**
Wael_H 0:8743b606abc3 469 * Sets on/off Pixy2's integrated light source.
Wael_H 0:8743b606abc3 470 * 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.
Wael_H 0:8743b606abc3 471 * It will override Pixy2's own setting of the RGB LED.
Wael_H 0:8743b606abc3 472 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 473 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 474 * @param upper (Byte - passed by value) : switch on or off the upper lamps (boolean : zero or non-zero)
Wael_H 0:8743b606abc3 475 * @param lower (Byte - passed by value) : switch on or off the lower lamp (boolean : zero or non-zero)
Wael_H 0:8743b606abc3 476 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 477 */
Wael_H 0:8743b606abc3 478 T_pixy2ErrorCode pixy2_setLamp (Byte upper, Byte lower); // fonctionnelle
Wael_H 0:8743b606abc3 479
Wael_H 0:8743b606abc3 480 /**
Wael_H 0:8743b606abc3 481 * Gets Pixy2's framerate.
Wael_H 0:8743b606abc3 482 * 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.
Wael_H 0:8743b606abc3 483 * 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
Wael_H 0:8743b606abc3 484 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 485 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 486 * @param framerate (T_pixy2ReturnCode - passed by reference) : number of frame per second (between 2 and 62)
Wael_H 0:8743b606abc3 487 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 488 */
Wael_H 0:8743b606abc3 489 T_pixy2ErrorCode pixy2_getFPS (T_pixy2ReturnCode **framerate); // fonctionnelle
Wael_H 0:8743b606abc3 490
Wael_H 0:8743b606abc3 491 /**
Wael_H 0:8743b606abc3 492 * Gets all detected color blocks in the most recent frame.
Wael_H 0:8743b606abc3 493 * 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.
Wael_H 0:8743b606abc3 494 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:color_connected_components
Wael_H 0:8743b606abc3 495 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 496 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__ccc_api
Wael_H 0:8743b606abc3 497 * @param sigmap (Byte - passed by value) : signature filtering
Wael_H 0:8743b606abc3 498 * @param maxBloc (Byte - passed by value) : maximum number of blocks to return
Wael_H 0:8743b606abc3 499 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 500 * @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.
Wael_H 0:8743b606abc3 501 * @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.
Wael_H 0:8743b606abc3 502 * @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 (1 + 16).
Wael_H 0:8743b606abc3 503 */
Wael_H 0:8743b606abc3 504 T_pixy2ErrorCode pixy2_getBlocks (Byte sigmap, Byte maxBloc);
Wael_H 0:8743b606abc3 505
Wael_H 0:8743b606abc3 506 /**
Wael_H 0:8743b606abc3 507 * Gets the latest main features of Line tracking in the most recent frame.
Wael_H 0:8743b606abc3 508 * The results are returned in the variables vectors, intersections, and barcodes, respectively.
Wael_H 0:8743b606abc3 509 * The main feature is the feature that is the most likely to be relevant for line traking.
Wael_H 0:8743b606abc3 510 * 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.
Wael_H 0:8743b606abc3 511 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 512 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 513 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 514 * @param feature (Byte - passed by value) : feature filtering
Wael_H 0:8743b606abc3 515 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 516 * @note There are 3 possible features (vectors, intersections and barcodes).
Wael_H 0:8743b606abc3 517 * @note Filtering is based on ORing codes : 1 for vectors, 2 for intersections, 4 for barcodes.
Wael_H 0:8743b606abc3 518 * @note So 7 = accept all, 0 = reject all. For example filtering to get only vectors and barcode means using feature = 5 (1 + 4).
Wael_H 0:8743b606abc3 519 */
Wael_H 0:8743b606abc3 520 T_pixy2ErrorCode pixy2_getMainFeature (Byte features); // fonctionnelle
Wael_H 0:8743b606abc3 521
Wael_H 0:8743b606abc3 522 /**
Wael_H 0:8743b606abc3 523 * Gets all the latest features of Line tracking in the most recent frame.
Wael_H 0:8743b606abc3 524 * The results are returned in the variables vectors[], intersections[], and barcodes[], respectively.
Wael_H 0:8743b606abc3 525 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 526 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 527 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 528 * @param feature (Byte - passed by value) : feature filtering
Wael_H 0:8743b606abc3 529 * @return T_pixy2ErrorCode : error code (if negative) or ORing of feature detected (if positive).
Wael_H 0:8743b606abc3 530 * @note There are 3 possible features (vectors, intersections and barcodes).
Wael_H 0:8743b606abc3 531 * @note Filtering or detected feature are based on ORing codes : 1 for vectors, 2 for intersections, 4 for barcodes.
Wael_H 0:8743b606abc3 532 * @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).
Wael_H 0:8743b606abc3 533 * @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.
Wael_H 0:8743b606abc3 534 */
Wael_H 0:8743b606abc3 535 T_pixy2ErrorCode pixy2_getAllFeature (Byte features); // fonctionnelle
Wael_H 0:8743b606abc3 536
Wael_H 0:8743b606abc3 537 /**
Wael_H 0:8743b606abc3 538 * Sets various modes in the line tracking algorithm.
Wael_H 0:8743b606abc3 539 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 540 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 541 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 542 * @param mode (Byte - passed by value) : ORing of required feature
Wael_H 0:8743b606abc3 543 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 544 * @note There are 3 possible features :
Wael_H 0:8743b606abc3 545 * @note * LINE_MODE_TURN_DELAYED : Normally, the line tracking algorithm will choose the straightest path (branch) when encountering an intersection. Setting LINE_MODE_TURN_DELAYED will prevent the line tracking algorithm from choosing the path automatically. This is useful if your program doesn't know beforehand which path it wants to take at the next intersection.
Wael_H 0:8743b606abc3 546 * @note * LINE_MODE_MANUAL_SELECT_VECTOR : Normally, the line tracking algorithm will choose what it thinks is the best Vector line automatically. Setting LINE_MODE_MANUAL_SELECT_VECTOR will prevent the line tracking algorithm from choosing the Vector automatically. Instead, your program will need to set the Vector by calling setVector().
Wael_H 0:8743b606abc3 547 * @note * LINE_MODE_WHITE_LINE : Normally, the line tracking algorithm will try to find dark lines on a light background (black lines). Setting LINE_MODE_WHITE_LINE will instruct the line tracking algorithm to look for light lines on a dark background (white lines).
Wael_H 0:8743b606abc3 548 */
Wael_H 0:8743b606abc3 549 T_pixy2ErrorCode pixy2_setMode (Byte mode); // plus tard
Wael_H 0:8743b606abc3 550
Wael_H 0:8743b606abc3 551 /**
Wael_H 0:8743b606abc3 552 * Tells the line tracking algorithm which path it should take at the next intersection.
Wael_H 0:8743b606abc3 553 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 554 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 555 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 556 * @param angle (sWord - passed by value) : angle closest to the next turn (in degree, between -180 and 180)
Wael_H 0:8743b606abc3 557 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 558 * @note Turn angles are specified in degrees, with 0 being straight ahead, left being 90 and right being -90, although any valid angle value can be used.
Wael_H 0:8743b606abc3 559 * @note setNextTurn() will remember the turn angle you give it, and execute it at the next intersection. The line tracking algorithm will then go back to the default turn angle for subsequent intersections.
Wael_H 0:8743b606abc3 560 * @note Upon encountering an intersection, the line tracking algorithm will find the path in the intersection that matches the turn angle most closely.
Wael_H 0:8743b606abc3 561 */
Wael_H 0:8743b606abc3 562 T_pixy2ErrorCode pixy2_setNextTurn (sWord angle); // plus tard
Wael_H 0:8743b606abc3 563
Wael_H 0:8743b606abc3 564 /**
Wael_H 0:8743b606abc3 565 * Tells the line tracking algorithm which path to choose by default upon encountering an intersection.
Wael_H 0:8743b606abc3 566 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 567 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 568 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 569 * @param angle (sWord - passed by value) : angle closest to the default turn (in degree, between -180 and 180)
Wael_H 0:8743b606abc3 570 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 571 * @note Turn angles are specified in degrees, with 0 being straight ahead, left being 90 and right being -90, although any valid angle value can be used.
Wael_H 0:8743b606abc3 572 * @note The line tracking algorithm will find the path in the intersection that matches the default turn angle most closely.
Wael_H 0:8743b606abc3 573 * @note A call to setNextTurn() will supercede the default turn angle for the next intersection.
Wael_H 0:8743b606abc3 574 */
Wael_H 0:8743b606abc3 575 T_pixy2ErrorCode pixy2_setDefaultTurn (sWord angle); // plus tard
Wael_H 0:8743b606abc3 576
Wael_H 0:8743b606abc3 577 /**
Wael_H 0:8743b606abc3 578 * Tells witch vector the tracking algorithm must choose as default route upon encountering an intersection.
Wael_H 0:8743b606abc3 579 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 580 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 581 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 582 * @param index (Byte - passed by value) : index of the line to follow
Wael_H 0:8743b606abc3 583 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 584 * @note If the LINE_MODE_MANUAL_SELECT_VECTOR mode bit is set, the line tracking algorithm will no longer choose the Vector automatically. Instead, setVector() will set the Vector by providing the index of the line.
Wael_H 0:8743b606abc3 585 */
Wael_H 0:8743b606abc3 586 T_pixy2ErrorCode pixy2_setVector (Byte vectorIndex); // plus tard
Wael_H 0:8743b606abc3 587
Wael_H 0:8743b606abc3 588 /**
Wael_H 0:8743b606abc3 589 * Reverse the head and the tail of vectors
Wael_H 0:8743b606abc3 590 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 591 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 592 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 593 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 594 * @note The Vector has a direction. It normally points up, from the bottom of the camera frame to the top of the camera frame for a forward-moving robot. Calling reverseVector() will invert the vector. This will typically cause your robot to back-up and change directions.
Wael_H 0:8743b606abc3 595 */
Wael_H 0:8743b606abc3 596 T_pixy2ErrorCode pixy2_ReverseVector (void); // fonctionnelle
Wael_H 0:8743b606abc3 597
Wael_H 0:8743b606abc3 598 /**
Wael_H 0:8743b606abc3 599 * Returns the average RGB components of a square of 5x5 pixels centered on the given pixel coordinate
Wael_H 0:8743b606abc3 600 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video
Wael_H 0:8743b606abc3 601 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 602 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video_api
Wael_H 0:8743b606abc3 603 * @param x (Word - passed by value) : X coordinate of the center of de 5x5 pixels square (in pixel, between 0 and 315)
Wael_H 0:8743b606abc3 604 * @param y (Word - passed by value) : Y coordinate of the center of de 5x5 pixels square (in pixel, between 0 and 207)
Wael_H 0:8743b606abc3 605 * @param saturate (Byte - passed by value) : scale the 3 RGB components so that the highest one of the 3 RGB components is set to 255 (boolean : zero or non-zero)
Wael_H 0:8743b606abc3 606 * @param pixel (T_pixy2Pixel - passed by reference) : RGB pixel.
Wael_H 0:8743b606abc3 607 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 608 */
Wael_H 0:8743b606abc3 609 T_pixy2ErrorCode pixy2_getRGB (Word x, Word y, Byte saturate, T_pixy2Pixel **pixel); // fonctionnelle
Wael_H 0:8743b606abc3 610
Wael_H 0:8743b606abc3 611 // Variables globales Publiques
Wael_H 0:8743b606abc3 612 /**
Wael_H 0:8743b606abc3 613 * @var Pixy2_numBlocks (Byte) number of color blocks in Pixy2_blocks
Wael_H 0:8743b606abc3 614 * @var Pixy2_blocks[] (T_pixy2Bloc) color blocks detected in the last frame
Wael_H 0:8743b606abc3 615 * @var Pixy2_numVectors (Byte) number of vectors in Pixy2_vectors
Wael_H 0:8743b606abc3 616 * @var Pixy2_vectors[] (T_pixy2Vector) vectors detected in the last frame
Wael_H 0:8743b606abc3 617 * @var Pixy2_numIntersections (Byte) number of intersections in Pixy2_intersections
Wael_H 0:8743b606abc3 618 * @var Pixy2_intersections[] (T_pixy2Intersection) intersections detected in the last frame
Wael_H 0:8743b606abc3 619 * @var Pixy2_intersLine[] (T_pixy2IntLines) lines detected in the last frame
Wael_H 0:8743b606abc3 620 * @var Pixy2_numVectors (Byte) number of vectors in Pixy2_blocks
Wael_H 0:8743b606abc3 621 * @var Pixy2_vectors[] (T_pixy2Vector) vectors detected in the last frame
Wael_H 0:8743b606abc3 622 */
Wael_H 0:8743b606abc3 623 Byte Pixy2_numBlocks;
Wael_H 0:8743b606abc3 624 T_pixy2Bloc *Pixy2_blocks;
Wael_H 0:8743b606abc3 625 Byte Pixy2_numVectors;
Wael_H 0:8743b606abc3 626 T_pixy2Vector *Pixy2_vectors;
Wael_H 0:8743b606abc3 627 Byte Pixy2_numIntersections;
Wael_H 0:8743b606abc3 628 T_pixy2Intersection *Pixy2_intersections;
Wael_H 0:8743b606abc3 629 Byte Pixy2_numBarcodes;
Wael_H 0:8743b606abc3 630 T_pixy2BarCode *Pixy2_barcodes;
Wael_H 0:8743b606abc3 631
Wael_H 0:8743b606abc3 632 private :
Wael_H 0:8743b606abc3 633 // Variables globales Privées
Wael_H 0:8743b606abc3 634 /**
Wael_H 0:8743b606abc3 635 * @var etat (T_Pixy2State) state of the pixy2 cam (idle = No action, messageSent = Query or Set message sent, receivingHeader = Camera is respondig to the query/set, receivingData = Header received, dataReceived = All data has been recovered)
Wael_H 0:8743b606abc3 636 * @var Pixy2_buffer (Array of Byte) bytes received from camera
Wael_H 0:8743b606abc3 637 * @var wPointer (Byte) write pointer, pointing the next free cell of the array of received bytes
Wael_H 0:8743b606abc3 638 * @var hPointer (Byte) header pointer, pointing on the begining of the header field in the array of received bytes
Wael_H 0:8743b606abc3 639 * @var dPointer (Byte) data pointer, pointing on the begining of the data field in the array of received bytes
Wael_H 0:8743b606abc3 640 * @var dataSize (Byte) number of bytes in the data field
Wael_H 0:8743b606abc3 641 * @var frameContainChecksum (Byte) indicate if the received frame contains a checksum
Wael_H 0:8743b606abc3 642 */
Wael_H 0:8743b606abc3 643 T_Pixy2State etat;
Wael_H 0:8743b606abc3 644 Byte* Pixy2_buffer;
Wael_H 0:8743b606abc3 645 Byte wPointer, hPointer, dPointer, dataSize;
Wael_H 0:8743b606abc3 646 Byte frameContainChecksum;
Wael_H 0:8743b606abc3 647
Wael_H 0:8743b606abc3 648 // Fonctions privées
Wael_H 0:8743b606abc3 649
Wael_H 0:8743b606abc3 650 /**
Wael_H 0:8743b606abc3 651 * Queries the firmware and hardware version of Pixy2.
Wael_H 0:8743b606abc3 652 * This function is part of the pixy2_getVersion function who treat the reply to this query.
Wael_H 0:8743b606abc3 653 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 654 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 655 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 656 */
Wael_H 0:8743b606abc3 657 T_pixy2ErrorCode pixy2_sndGetVersion (void);
Wael_H 0:8743b606abc3 658
Wael_H 0:8743b606abc3 659 /**
Wael_H 0:8743b606abc3 660 * Queries width and height of the frames used by the current program.
Wael_H 0:8743b606abc3 661 * This function is part of the pixy2_getResolution function who treat the reply to this query.
Wael_H 0:8743b606abc3 662 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 663 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 664 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 665 */
Wael_H 0:8743b606abc3 666 T_pixy2ErrorCode pixy2_sndGetResolution (void);
Wael_H 0:8743b606abc3 667
Wael_H 0:8743b606abc3 668 /**
Wael_H 0:8743b606abc3 669 * Sends the relative exposure level of Pixy2's image sensor.
Wael_H 0:8743b606abc3 670 * Higher values result in a brighter (more exposed) image.
Wael_H 0:8743b606abc3 671 * This function is part of the pixy2_setCameraBrightness function who treat the acknowledge of this frame.
Wael_H 0:8743b606abc3 672 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 673 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 674 * @param brightness (Byte - passed by value) : brightness level
Wael_H 0:8743b606abc3 675 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 676 */
Wael_H 0:8743b606abc3 677 T_pixy2ErrorCode pixy2_sndSetCameraBrightness (Byte brightness);
Wael_H 0:8743b606abc3 678
Wael_H 0:8743b606abc3 679 /**
Wael_H 0:8743b606abc3 680 * Sends the servo positions of servos plugged into Pixy2's two RC servo connectors.
Wael_H 0:8743b606abc3 681 * This function is part of the pixy2_setServo function who treat the acknowledge of this frame.
Wael_H 0:8743b606abc3 682 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 683 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 684 * @param s0 (Word - passed by value) : value between 0 and 511
Wael_H 0:8743b606abc3 685 * @param s1 (Word - passed by value) : value between 0 and 511
Wael_H 0:8743b606abc3 686 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 687 */
Wael_H 0:8743b606abc3 688 T_pixy2ErrorCode pixy2_sndSetServo (Word s0, Word s1);
Wael_H 0:8743b606abc3 689
Wael_H 0:8743b606abc3 690 /**
Wael_H 0:8743b606abc3 691 * Sends Pixy2's RGB LED value. The three arguments sets the brightness of the red, green and blue sections of the LED.
Wael_H 0:8743b606abc3 692 * It will override Pixy2's own setting of the RGB LED.
Wael_H 0:8743b606abc3 693 * This function is part of the pixy2_setLED function who treat the acknowledge of this frame.
Wael_H 0:8743b606abc3 694 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 695 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 696 * @param red (Byte - passed by value) : Red component value (between 0 and 255)
Wael_H 0:8743b606abc3 697 * @param green (Byte - passed by value) : Green component value (between 0 and 255)
Wael_H 0:8743b606abc3 698 * @param blue (Byte - passed by value) : Blue component value (between 0 and 255)
Wael_H 0:8743b606abc3 699 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 700 */
Wael_H 0:8743b606abc3 701 T_pixy2ErrorCode pixy2_sndSetLED (Byte red, Byte green, Byte blue);
Wael_H 0:8743b606abc3 702
Wael_H 0:8743b606abc3 703 /**
Wael_H 0:8743b606abc3 704 * Sends command that turns on/off Pixy2's integrated light source.
Wael_H 0:8743b606abc3 705 * 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.
Wael_H 0:8743b606abc3 706 * It will override Pixy2's own setting of the RGB LED.
Wael_H 0:8743b606abc3 707 * This function is part of the pixy2_setLamp function who treat the acknowledge of this frame.
Wael_H 0:8743b606abc3 708 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 709 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 710 * @param upper (Byte - passed by value) : switch on or off the upper lamps (boolean : zero or non-zero)
Wael_H 0:8743b606abc3 711 * @param lower (Byte - passed by value) : switch on or off the lower lamp (boolean : zero or non-zero)
Wael_H 0:8743b606abc3 712 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 713 */
Wael_H 0:8743b606abc3 714 T_pixy2ErrorCode pixy2_sndSetLamp (Byte upper, Byte lower);
Wael_H 0:8743b606abc3 715
Wael_H 0:8743b606abc3 716 /**
Wael_H 0:8743b606abc3 717 * Queries Pixy2's framerate.
Wael_H 0:8743b606abc3 718 * This function is part of the pixy2_getFPS function who treat the reply to this query.
Wael_H 0:8743b606abc3 719 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 720 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
Wael_H 0:8743b606abc3 721 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 722 */
Wael_H 0:8743b606abc3 723 T_pixy2ErrorCode pixy2_sndGetFPS (void);
Wael_H 0:8743b606abc3 724
Wael_H 0:8743b606abc3 725 /**
Wael_H 0:8743b606abc3 726 * Queries all detected color blocks in the most recent frame.
Wael_H 0:8743b606abc3 727 * This function is part of the pixy2_getBlocks function who treat the reply to this query.
Wael_H 0:8743b606abc3 728 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:color_connected_components
Wael_H 0:8743b606abc3 729 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 730 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__ccc_api
Wael_H 0:8743b606abc3 731 * @param sigmap (Byte - passed by value) : signature filtering
Wael_H 0:8743b606abc3 732 * @param maxBloc (Byte - passed by value) : maximum number of blocks to return
Wael_H 0:8743b606abc3 733 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 734 * @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.
Wael_H 0:8743b606abc3 735 * @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.
Wael_H 0:8743b606abc3 736 * @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).
Wael_H 0:8743b606abc3 737 */
Wael_H 0:8743b606abc3 738 T_pixy2ErrorCode pixy2_sndGetBlocks (Byte sigmap, Byte maxBloc);
Wael_H 0:8743b606abc3 739
Wael_H 0:8743b606abc3 740 /**
Wael_H 0:8743b606abc3 741 * Queries the latest features of Line tracking in the most recent frame.
Wael_H 0:8743b606abc3 742 * The results are returned in the variables vectors, intersections, and barcodes, respectively.
Wael_H 0:8743b606abc3 743 * This function is part of the pixy2_getMainFeature or pixy2_getAllFeature function who treat the reply to this query.
Wael_H 0:8743b606abc3 744 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 745 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 746 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 747 * @param type (Byte - passed by value) : select between Main or All features (0 for main feature only, 1 for all features)
Wael_H 0:8743b606abc3 748 * @param feature (Byte - passed by value) : feature filtering
Wael_H 0:8743b606abc3 749 * @return T_pixy2ErrorCode : error code (if negative) or ORing of feature detected (if positive).
Wael_H 0:8743b606abc3 750 * @note There are 3 possible features (vectors, intersections and barcodes).
Wael_H 0:8743b606abc3 751 * @note Filtering or detected feature are based on ORing codes : 1 for vectors, 2 for intersections, 4 for barcodes.
Wael_H 0:8743b606abc3 752 * @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).
Wael_H 0:8743b606abc3 753 * @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.
Wael_H 0:8743b606abc3 754 */
Wael_H 0:8743b606abc3 755 T_pixy2ErrorCode pixy2_sndGetLineFeature (Byte type, Byte feature);
Wael_H 0:8743b606abc3 756
Wael_H 0:8743b606abc3 757 /**
Wael_H 0:8743b606abc3 758 * Sets various modes in the line tracking algorithm.
Wael_H 0:8743b606abc3 759 * This function is part of the pixy2_setMode function who treat the acknowledge of this frame.
Wael_H 0:8743b606abc3 760 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 761 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 762 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 763 * @param mode (Byte - passed by value) : ORing of required feature
Wael_H 0:8743b606abc3 764 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 765 * @note There are 3 possible features :
Wael_H 0:8743b606abc3 766 * @note * LINE_MODE_TURN_DELAYED : Normally, the line tracking algorithm will choose the straightest path (branch) when encountering an intersection. Setting LINE_MODE_TURN_DELAYED will prevent the line tracking algorithm from choosing the path automatically. This is useful if your program doesn't know beforehand which path it wants to take at the next intersection.
Wael_H 0:8743b606abc3 767 * @note * LINE_MODE_MANUAL_SELECT_VECTOR : Normally, the line tracking algorithm will choose what it thinks is the best Vector line automatically. Setting LINE_MODE_MANUAL_SELECT_VECTOR will prevent the line tracking algorithm from choosing the Vector automatically. Instead, your program will need to set the Vector by calling setVector().
Wael_H 0:8743b606abc3 768 * @note * LINE_MODE_WHITE_LINE : Normally, the line tracking algorithm will try to find dark lines on a light background (black lines). Setting LINE_MODE_WHITE_LINE will instruct the line tracking algorithm to look for light lines on a dark background (white lines).
Wael_H 0:8743b606abc3 769 */
Wael_H 0:8743b606abc3 770 T_pixy2ErrorCode pixy2_sndSetMode (Byte mode);
Wael_H 0:8743b606abc3 771
Wael_H 0:8743b606abc3 772 /**
Wael_H 0:8743b606abc3 773 * Tells the line tracking algorithm which path it should take at the next intersection.
Wael_H 0:8743b606abc3 774 * This function is part of the pixy2_setNextTurn function who treat the acknowledge of this frame.
Wael_H 0:8743b606abc3 775 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 776 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 777 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 778 * @param angle (sWord - passed by value) : angle closest to the next turn (in degree, between -180 and 180)
Wael_H 0:8743b606abc3 779 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 780 * @note Turn angles are specified in degrees, with 0 being straight ahead, left being 90 and right being -90, although any valid angle value can be used.
Wael_H 0:8743b606abc3 781 * @note setNextTurn() will remember the turn angle you give it, and execute it at the next intersection. The line tracking algorithm will then go back to the default turn angle for subsequent intersections.
Wael_H 0:8743b606abc3 782 * @note Upon encountering an intersection, the line tracking algorithm will find the path in the intersection that matches the turn angle most closely.
Wael_H 0:8743b606abc3 783 */
Wael_H 0:8743b606abc3 784 T_pixy2ErrorCode pixy2_sndSetNextTurn (Word angle);
Wael_H 0:8743b606abc3 785
Wael_H 0:8743b606abc3 786 /**
Wael_H 0:8743b606abc3 787 * Tells the line tracking algorithm which path to choose by default upon encountering an intersection.
Wael_H 0:8743b606abc3 788 * This function is part of the pixy2_setDefaultTurn function who treat the acknowledge of this frame.
Wael_H 0:8743b606abc3 789 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 790 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 791 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 792 * @param angle (sWord - passed by value) : angle closest to the default turn (in degree, between -180 and 180)
Wael_H 0:8743b606abc3 793 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 794 * @note Turn angles are specified in degrees, with 0 being straight ahead, left being 90 and right being -90, although any valid angle value can be used.
Wael_H 0:8743b606abc3 795 * @note The line tracking algorithm will find the path in the intersection that matches the default turn angle most closely.
Wael_H 0:8743b606abc3 796 * @note A call to setNextTurn() will supercede the default turn angle for the next intersection.
Wael_H 0:8743b606abc3 797 */
Wael_H 0:8743b606abc3 798 T_pixy2ErrorCode pixy2_sndSetDefaultTurn (Word angle);
Wael_H 0:8743b606abc3 799
Wael_H 0:8743b606abc3 800 /**
Wael_H 0:8743b606abc3 801 * Tells witch vector the tracking algorithm must choose as default route upon encountering an intersection.
Wael_H 0:8743b606abc3 802 * This function is part of the pixy2_setVector function who treat the acknowledge of this frame.
Wael_H 0:8743b606abc3 803 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 804 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 805 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 806 * @param vectorindex (Byte - passed by value) : index of the vector to follow
Wael_H 0:8743b606abc3 807 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 808 * @note If the LINE_MODE_MANUAL_SELECT_VECTOR mode bit is set, the line tracking algorithm will no longer choose the Vector automatically. Instead, setVector() will set the Vector by providing the index of the line.
Wael_H 0:8743b606abc3 809 */
Wael_H 0:8743b606abc3 810 T_pixy2ErrorCode pixy2_sndSetVector (Byte vectorIndex);
Wael_H 0:8743b606abc3 811
Wael_H 0:8743b606abc3 812 /**
Wael_H 0:8743b606abc3 813 * Reverse the head and the tail of vectors
Wael_H 0:8743b606abc3 814 * This function is part of the pixy2_reverseVector function who treat the acknowledge of this frame.
Wael_H 0:8743b606abc3 815 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 816 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 817 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 818 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 819 * @note The Vector has a direction. It normally points up, from the bottom of the camera frame to the top of the camera frame for a forward-moving robot. Calling reverseVector() will invert the vector. This will typically cause your robot to back-up and change directions.
Wael_H 0:8743b606abc3 820 */
Wael_H 0:8743b606abc3 821 T_pixy2ErrorCode pixy2_sndReverseVector (void);
Wael_H 0:8743b606abc3 822
Wael_H 0:8743b606abc3 823 /**
Wael_H 0:8743b606abc3 824 * Queries the average RGB components of a square of 5x5 pixels centered on the given pixel coordinate
Wael_H 0:8743b606abc3 825 * This function is part of the pixy2_getRGB function who treat the reply to this query.
Wael_H 0:8743b606abc3 826 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video
Wael_H 0:8743b606abc3 827 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 828 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video_api
Wael_H 0:8743b606abc3 829 * @param x (Word - passed by value) : X coordinate of the center of de 5x5 pixels square (in pixel, between 0 and 315)
Wael_H 0:8743b606abc3 830 * @param y (Word - passed by value) : Y coordinate of the center of de 5x5 pixels square (in pixel, between 0 and 207)
Wael_H 0:8743b606abc3 831 * @param saturate (Byte - passed by value) : scale the 3 RGB components so that the highest one of the 3 RGB components is set to 255 (boolean : zero or non-zero)
Wael_H 0:8743b606abc3 832 * @param pixel (T_pixy2Pixel - passed by reference) : RGB pixel.
Wael_H 0:8743b606abc3 833 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 834 */
Wael_H 0:8743b606abc3 835 T_pixy2ErrorCode pixy2_sndGetRGB (Word x, Word y, Byte saturate);
Wael_H 0:8743b606abc3 836
Wael_H 0:8743b606abc3 837 /**
Wael_H 0:8743b606abc3 838 * Gets all the latest features of Line tracking in the most recent frame.
Wael_H 0:8743b606abc3 839 * The results are returned in the variables vectors, intersections, and barcodes, respectively.
Wael_H 0:8743b606abc3 840 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking
Wael_H 0:8743b606abc3 841 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
Wael_H 0:8743b606abc3 842 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api
Wael_H 0:8743b606abc3 843 * @param feature (Byte - passed by value) : feature filtering
Wael_H 0:8743b606abc3 844 * @return T_pixy2ErrorCode : error code.
Wael_H 0:8743b606abc3 845 * @note There are 3 possible features (vectors, intersections and barcodes).
Wael_H 0:8743b606abc3 846 * @note Filtering is based on ORing codes : 1 for vectors, 2 for intersections, 4 for barcodes.
Wael_H 0:8743b606abc3 847 * @note So 7 = accept all, 0 = reject all. For example filtering to get only vectors and barcode means using feature = 5 (1 + 4).
Wael_H 0:8743b606abc3 848 */
Wael_H 0:8743b606abc3 849 T_pixy2ErrorCode pixy2_getFeatures (void);
Wael_H 0:8743b606abc3 850
Wael_H 0:8743b606abc3 851 void pixy2_getByte ();
Wael_H 0:8743b606abc3 852 T_pixy2ErrorCode pixy2_validateChecksum (Byte* tab);
Wael_H 0:8743b606abc3 853 }; // End Class
Wael_H 0:8743b606abc3 854
Wael_H 0:8743b606abc3 855 #endif