Theo Le Paih / Mbed 2 deprecated Lib_Pixy2

Dependencies:   mbed

Revision:
11:68ef9f85e40e
Parent:
10:ea759846c2d5
Child:
12:7493191dd1dc
--- a/pixy2.cpp	Tue Mar 12 14:06:53 2019 +0000
+++ b/pixy2.cpp	Tue Mar 12 14:16:53 2019 +0000
@@ -65,7 +65,7 @@
     }
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndGetVersion (void){
+T_pixy2ErrorCode PIXY2::pixy2_sndGetVersion (void){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 0;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -79,7 +79,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndGetResolution (void){
+T_pixy2ErrorCode PIXY2::pixy2_sndGetResolution (void){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 1;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -94,7 +94,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndSetCameraBrightness (Byte brightness){
+T_pixy2ErrorCode PIXY2::pixy2_sndSetCameraBrightness (Byte brightness){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 1;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -109,7 +109,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndSetServo (Word s0, Word s1){
+T_pixy2ErrorCode PIXY2::pixy2_sndSetServo (Word s0, Word s1){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 4;
     T_Word              tmp;
@@ -130,7 +130,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndSetLED (Byte red, Byte green, Byte blue){
+T_pixy2ErrorCode PIXY2::pixy2_sndSetLED (Byte red, Byte green, Byte blue){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 3;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -147,7 +147,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndSetLamp (Byte upper, Byte lower){
+T_pixy2ErrorCode PIXY2::pixy2_sndSetLamp (Byte upper, Byte lower){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 2;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -163,7 +163,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndGetFPS (void){
+T_pixy2ErrorCode PIXY2::pixy2_sndGetFPS (void){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 0;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -177,7 +177,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndGetBlocks (Byte sigmap, Byte maxBloc){
+T_pixy2ErrorCode PIXY2::pixy2_sndGetBlocks (Byte sigmap, Byte maxBloc){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 2;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -193,7 +193,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndGetMainFeature (Byte type, Byte feature){
+T_pixy2ErrorCode PIXY2::pixy2_sndGetMainFeature (Byte type, Byte feature){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 2;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -209,7 +209,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndSetMode (Byte mode){
+T_pixy2ErrorCode PIXY2::pixy2_sndSetMode (Byte mode){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 1;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -224,7 +224,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndSetNexTurn (Word angle){
+T_pixy2ErrorCode PIXY2::pixy2_sndSetNexTurn (Word angle){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 2;
     T_Word              tmp;
@@ -243,7 +243,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndSetDefaultTurn (Word angle){
+T_pixy2ErrorCode PIXY2::pixy2_sndSetDefaultTurn (Word angle){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 2;
     T_Word              tmp;
@@ -262,7 +262,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndSetVector (Byte vectorIndex){
+T_pixy2ErrorCode PIXY2::pixy2_sndSetVector (Byte vectorIndex){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 1;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -277,7 +277,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndReverseVector (void){
+T_pixy2ErrorCode PIXY2::pixy2_sndReverseVector (void){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 0;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -291,7 +291,7 @@
     return PIXY2_OK;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_sndGetRGB (Word x, Word y, Byte saturate){
+T_pixy2ErrorCode PIXY2::pixy2_sndGetRGB (Word x, Word y, Byte saturate){
     T_pixy2SendBuffer   msg;
     int                 i = 0, dataSize = 3;
     msg.frame.header.pixSync = PIXY2_SYNC;
@@ -311,10 +311,10 @@
 /*  La fonction est bloquante à l'envoi (pas vraiment le choix), mais elle est non bloquante en réception. On essayera de faire une fonction non bloquante en envoi avec write, mais c'est pas la priorité.
 Le principe c'est de stocker dans un buffer circulaire les données au fur et à mesure qu'elle sont reçues et de traiter uniquement en castant les infos. Pour cela, il faut recevoir et stocker. */
 
-Pixy2ErrorCode PIXY2::pixy2_getVersion (T_Pixy2Version *version){
+T_pixy2ErrorCode PIXY2::pixy2_getVersion (T_pixy2Version *version){
 
     T_pixy2RcvHeader    *msg = (T_pixy2RcvHeader*) &Pixy2_buffer[rPointer];
-    Pixy2ErrorCode      cr = PIXY2_OK;
+    T_pixy2ErrorCode    cr = PIXY2_OK;
     
     switch (etat) {
         case idle :                                                                 // Si la caméra est inactive
@@ -328,24 +328,24 @@
             if (frameContainChecksum) {                                             // Si la trame contient un checksum
                 if ( pixy2_validateChecksum (&Pixy2_buffer[rPointer]) ) {           // On lance la validation du checksum           
                     if (msg->pixType == PIXY2_REP_VERS) {                           // On vérifie que la trame est du type convenable
-                        version = (T_Pixy2Version*) &Pixy2_buffer[rPointer + PIXY2_CSHEADERSIZE];
+                        version = (T_pixy2Version*) &Pixy2_buffer[rPointer + PIXY2_CSHEADERSIZE];
                                                                                     // On mappe le pointeur de version sur la donnée stockée dans la FIFO (ligne précédente)                        
                         etat = idle;                                                // Et on annoce que la pixy est libre
                     } else {
                         if (msg->pixType == PIXY2_ERROR) {                          // Si on reçoit une trame d'erreur
-                            cr = *(Pixy2ErrorCode*) &Pixy2_buffer[rPointer + PIXY2_CSHEADERSIZE];
+                            cr = *(T_pixy2ErrorCode*) &Pixy2_buffer[rPointer + PIXY2_CSHEADERSIZE];
                                                                                     // On mappe le résultat sur la donnée stockée dans la FIFO (ligne précédente)    
                         }else cr = PIXY2_TYPE_ERROR;                                // Si le type ne correspond à rien de normal on signale une erreur
                     }                                   
                 } else cr = PIXY2_BAD_CHECKSUM;                                     // Si le checksum est faux on retourne une erreur aussi !
             } else {                                                                // S'il n'y a pas de checksum (pas normal mais on ne sait jamais)
                 if (msg->pixType == PIXY2_REP_VERS) {                               // On vérifie que la trame est du type convenable                               
-                    version = (T_Pixy2Version*) &Pixy2_buffer[rPointer + PIXY2_NCSHEADERSIZE];
+                    version = (T_pixy2Version*) &Pixy2_buffer[rPointer + PIXY2_NCSHEADERSIZE];
                                                                                     // Si le checksum et le type sont bon, on mappe le pointeur de résultat sur la FIFO (ligne précédente)                        
                     etat = idle;                                                    // Et on annoce que la pixy est libre
                 } else {
                     if (msg->pixType == PIXY2_ERROR) {                              // Si on reçoit une trame d'erreur
-                        cr = *(Pixy2ErrorCode*) &Pixy2_buffer[rPointer + PIXY2_NCSHEADERSIZE];
+                        cr = *(T_pixy2ErrorCode*) &Pixy2_buffer[rPointer + PIXY2_NCSHEADERSIZE];
                                                                                     // On mappe le résultat sur la donnée stockée dans la FIFO (ligne précédente)    
                     }else cr = PIXY2_TYPE_ERROR;                                    // Si le type ne correspond à rien de normal on signale une erreur
                 }
@@ -359,10 +359,10 @@
     return cr;
 }
 
-Pixy2ErrorCode PIXY2::pixy2_getResolution (T_Pixy2Resolution *resolution){
+T_pixy2ErrorCode PIXY2::pixy2_getResolution (T_pixy2Resolution *resolution){
 
     T_pixy2RcvHeader    *msg = (T_pixy2RcvHeader*) &Pixy2_buffer[rPointer];
-    Pixy2ErrorCode      cr = PIXY2_OK;
+    T_pixy2ErrorCode    cr = PIXY2_OK;
     
     switch (etat) {
         case idle :                                                                 // Si la caméra est inactive
@@ -376,24 +376,24 @@
             if (frameContainChecksum) {                                             // Si la trame contient un checksum
                 if ( pixy2_validateChecksum (&Pixy2_buffer[rPointer]) ) {           // On lance la validation du checksum           
                     if (msg->pixType == PIXY2_REP_RESOL) {                          // On vérifie que la trame est du type convenable
-                        resolution = (T_Pixy2Resolution*) &Pixy2_buffer[rPointer + PIXY2_CSHEADERSIZE];
+                        resolution = (T_pixy2Resolution*) &Pixy2_buffer[rPointer + PIXY2_CSHEADERSIZE];
                                                                                     // Si le checksum et le type sont bon, on mappe le pointeur de résultat sur la FIFO (ligne précédente)                        
                         etat = idle;                                                // Et on annoce que la pixy est libre
                     } else {
                         if (msg->pixType == PIXY2_ERROR) {                          // Si on reçoit une trame d'erreur
-                            cr = *(Pixy2ErrorCode*) &Pixy2_buffer[rPointer + PIXY2_CSHEADERSIZE];
+                            cr = *(T_pixy2ErrorCode*) &Pixy2_buffer[rPointer + PIXY2_CSHEADERSIZE];
                                                                                     // On mappe le résultat sur la donnée stockée dans la FIFO (ligne précédente)    
                         }else cr = PIXY2_TYPE_ERROR;                                // Si le type ne correspond à rien de normal on signale une erreur
                     }                                   
                 } else cr = PIXY2_BAD_CHECKSUM;                                     // Si le checksum est faux on retourne une erreur aussi !
             } else {                                                                // S'il n'y a pas de checksum (pas normal mais on ne sait jamais)
                 if (msg->pixType == PIXY2_REP_RESOL) {                              // On vérifie que la trame est du type convenable                               
-                    resolution = (T_Pixy2Resolution*) &Pixy2_buffer[rPointer + PIXY2_NCSHEADERSIZE];
+                    resolution = (T_pixy2Resolution*) &Pixy2_buffer[rPointer + PIXY2_NCSHEADERSIZE];
                                                                                     // Si le checksum et le type sont bon, on mappe le pointeur de résultat sur la FIFO (ligne précédente)                        
                     etat = idle;                                                    // Et on annoce que la pixy est libre
                 } else {
                     if (msg->pixType == PIXY2_ERROR) {                              // Si on reçoit une trame d'erreur
-                        cr = *(Pixy2ErrorCode*) &Pixy2_buffer[rPointer + PIXY2_NCSHEADERSIZE];
+                        cr = *(T_pixy2ErrorCode*) &Pixy2_buffer[rPointer + PIXY2_NCSHEADERSIZE];
                                                                                     // On mappe le résultat sur la donnée stockée dans la FIFO (ligne précédente)    
                     }else cr = PIXY2_TYPE_ERROR;                                    // Si le type ne correspond à rien de normal on signale une erreur
                 }
@@ -408,22 +408,22 @@
 }
 
 
-Pixy2ErrorCode PIXY2::pixy2_setCameraBrightness (Byte brightness){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_setServos (Word s0, Word s1){return 0;} 
-Pixy2ErrorCode PIXY2::pixy2_setLED (Byte red, Byte green, Byte blue){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_setLamp (Byte upper, Byte lower){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_getFPS (T_pixy2ReturnCode *framerate){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_getBlocks (Byte sigmap, Byte maxBloc){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_getMainFeature (Byte features){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_getAllFeature (Byte features){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_setMode (Byte mode){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_setNexTurn (Word angle){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_setDefaultTurn (Word angle){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_setVector (Byte vectorIndex){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_ReverseVector (void){return 0;}
-Pixy2ErrorCode PIXY2::pixy2_getRGB (Word x, Word y, Byte saturate, T_pixy2Pixel *pixel){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_setCameraBrightness (Byte brightness){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_setServos (Word s0, Word s1){return 0;} 
+T_pixy2ErrorCode PIXY2::pixy2_setLED (Byte red, Byte green, Byte blue){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_setLamp (Byte upper, Byte lower){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_getFPS (T_pixy2ReturnCode *framerate){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_getBlocks (Byte sigmap, Byte maxBloc){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_getMainFeature (Byte features){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_getAllFeature (Byte features){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_setMode (Byte mode){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_setNexTurn (Word angle){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_setDefaultTurn (Word angle){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_setVector (Byte vectorIndex){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_ReverseVector (void){return 0;}
+T_pixy2ErrorCode PIXY2::pixy2_getRGB (Word x, Word y, Byte saturate, T_pixy2Pixel *pixel){return 0;}
 
-Pixy2ErrorCode PIXY2::pixy2_validateChecksum (Byte* tab){
+T_pixy2ErrorCode PIXY2::pixy2_validateChecksum (Byte* tab){
     Word    i, sum = 0;
     T_Word  *tmp;