FRC - Hackathon Pixy

Revision:
5:d395fe0fb0e0
Parent:
2:90355c600404
Child:
6:f16f250fe2cb
diff -r 90355c600404 -r d395fe0fb0e0 Pixy.h
--- a/Pixy.h	Tue May 22 17:15:30 2018 +0000
+++ b/Pixy.h	Thu May 31 17:24:52 2018 +0000
@@ -97,7 +97,7 @@
     
     /**
      *  \union T_pixyCCData
-     *  \brief Structured type to match pixy Color Code bloc organisation
+     *  \brief Overlaped type to access a structured pixy Color Code bloc type with both byte and structured 
      *  \param CCBloc (T_pixyCCBloc) : Color Code bloc structured element
      *  \param tab[14] (Byte) : Byte access to the Color Code bloc 
      */
@@ -108,8 +108,8 @@
     
     /**
      *  \union T_pixyNMData
-     *  \brief Structured type to match pixy normal bloc organisation
-     *  \param CCBloc (T_pixyCCBloc) : Normal bloc structured element
+     *  \brief Overlaped type to access a structured pixy Normal bloc type with both byte and structured
+     *  \param NMBloc (T_pixyNMBloc) : Normal bloc structured element
      *  \param tab[12] (Byte) : Byte access to the normal bloc 
      */
     typedef union {
@@ -117,20 +117,19 @@
         T_pixyNMBloc    NMbloc;
     } T_pixyNMData;
 
-    typedef enum {none, begin, normal, colorCode, doubleZero} T_pixyState;
+    typedef enum {none, begin, normal, colorCode, doubleZero, waitForStart} T_pixyState;
     
     typedef union {
-        lWord   mot;
-        Byte    tab[4];
-    } T_tmpBuffer;
+        lWord   motlong;
+        Word    mot[2];
+        Byte    octet[4];
+    } T_msgBuffer;
     
     typedef union {
         Word    mot;
-        Byte    tab[2];
-    } T_structBuffer;
+        Byte    octet[2];
+    } T_wordBuffer;
     
-
-
 /**
  * Pixy : CMU CAM 5 - Smart camera
  * More informations at http://cmucam.org/projects/cmucam5
@@ -139,7 +138,7 @@
 
 protected :
 
-    Serial*  _cmucam;
+    Serial*  _Pixy;
 
 public :
 
@@ -201,13 +200,13 @@
 
     /**
      * Return the number of objects (normal and ColorCode) that have been
-     * received from the PIXY during the last frame
+     * received from the PIXY and stored in the FIFO during the last frame
      *
-     * @param nbNM (passed by reference) : number of normal object detected
-     * @param nbCC (passed by reference) : number of color code object detected
+     * @param nbNM (int - passed by reference) : number of normal object detected
+     * @param nbCC (int - passed by reference) : number of color code object detected
      * @return   0 if sucessfull,
      *          -1 if no PIXY is talking,
-     *          -2 if object(s) have been lost (from previous frame or from actual) 
+     *          -2 sucessfull but object(s) have been lost from previous frames (missed frame) or from actual (too many objects) 
      */
     int detectedObject (int* nbNM, int* nbCC);
 
@@ -233,9 +232,20 @@
      * Set the Brightness of the Pixy
      *
      * @param   brightness level (between 0 and 255)
-     * @return  0 if successfull, else -1
+     */
+    void setBrightness (Byte brightness); 
+
+    /**
+     * Gives information about a new image taken by Pixy.
+     * @return  0 if no new image or  1 if there is a new image
      */
-    int setBrightness (Byte brightness); 
+    int checkNewImage (void);
+
+    /**
+     * Gives information about a detected Pixy.
+     * @return  -1 if no Pixy detected or  0 if Pixy detected
+     */
+    int checkPixy (void);
 
 private :