pixy2 smart camera library www.pixycam.com

Pixy2 Library project (using UART interface)

Revision:
6:e9e3aa6f1a55
Parent:
5:28e47187bb5c
Child:
7:1163b9c3274b
--- a/pixy2.h	Mon Mar 11 17:18:25 2019 +0000
+++ b/pixy2.h	Mon Mar 11 17:28:59 2019 +0000
@@ -66,17 +66,18 @@
 #define PIXY2_SET_REVERSE   62
 #define PIXY2_ASK_VIDEO     112
 
-/**************** UTILS ****************/
+/**************** ERRORS ****************/
 
 /**
- *  \enum error_code
- *  \brief List of possible error code
+ *  \struct Pixy2ErrorCode
+ *  \brief Explicit error code list :
  *  \param PIXY2_OK :               No error
  *  \param PIXY2_MISC_ERROR :       Unknown error
  *  \param PIXY2_BUSY :             Pixy hasn't finish yet
  *  \param PIXY2_BAD_CHECKSUM :     Checksum is wrong
  *  \param PIXY2_TYPE_ERROR :       unexpected type message
  */
+typedef int             Pixy2ErrorCode;
 
 #define PIXY2_OK            0
 #define PIXY2_MISC_ERROR    -1
@@ -90,6 +91,7 @@
 
 /**************** UTILS ****************/
 
+
 /**
  *  \struct Byte    ->      Short hand for unsigned char
  *  \struct sByte   ->      Short hand for char
@@ -377,9 +379,9 @@
  * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
  * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
  * @param version (T_Pixy2Version - passed by reference) : pointer to the version data structure
- * @return int : error code.
+ * @return Pixy2ErrorCode : error code.
  */
-int pixy2_getVersion (T_Pixy2Version *version);
+Pixy2ErrorCode pixy2_getVersion (T_Pixy2Version *version);
 
 /**
  * Gets the width and height of the frames used by the current program.
@@ -387,31 +389,39 @@
  * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
  * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
  * @param resolution (T_Pixy2Resolution - passed by reference) : pointer to the resolution data structure
- * @return int : error code.
+ * @return Pixy2ErrorCode : error code.
  */
-int pixy2_getResolution (T_Pixy2Resolution *resolution);
+Pixy2ErrorCode pixy2_getResolution (T_Pixy2Resolution *resolution);
 
 /**
  * Sets the relative exposure level of Pixy2's image sensor. Higher values result in a brighter (more exposed) image. 
  * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
  * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
  * @param brightness (Byte - passed by value) : brightness level 
- * @return int : error code.
+ * @return Pixy2ErrorCode : error code.
+ */
+Pixy2ErrorCode pixy2_setCameraBrightness (Byte brightness);
+
+/**
+ * sets the servo positions of servos plugged into Pixy2's two RC servo connectors. 
+ * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide
+ * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api
+ * @param brightness (Byte - passed by value) : brightness level 
+ * @return Pixy2ErrorCode : error code.
  */
-int pixy2_setCameraBrightness (Byte brightness);
-int pixy2_setServos (Word s0, Word s1); 
-int pixy2_setLED (Byte red, Byte green, Byte blue);
-int pixy2_setLamp (Byte upper, Byte lower);
-int pixy2_getFPS (T_pixy2returnCode *framerate);
-int pixy2_getBlocks (Byte sigmap, Byte maxBloc);
-int pixy2_getMainFeature (Byte type, Byte features);
-int pixy2_getAllFeature (Byte features);
-int pixy2_setMode (Byte mode);
-int pixy2_setNexTurn (Word angle);
-int pixy2_setDefaultTurn (Word angle);
-int pixy2_setVector (Byte vectorIndex);
-int pixy2_ReverseVector (void);
-int pixy2_getRGB (Word x, Word y, Byte saturate, T_pixy2Pixel *pixel);
+Pixy2ErrorCode pixy2_setServos (Word s0, Word s1); 
+Pixy2ErrorCode pixy2_setLED (Byte red, Byte green, Byte blue);
+Pixy2ErrorCode pixy2_setLamp (Byte upper, Byte lower);
+Pixy2ErrorCode pixy2_getFPS (T_pixy2returnCode *framerate);
+Pixy2ErrorCode pixy2_getBlocks (Byte sigmap, Byte maxBloc);
+Pixy2ErrorCode pixy2_getMainFeature (Byte type, Byte features);
+Pixy2ErrorCode pixy2_getAllFeature (Byte features);
+Pixy2ErrorCode pixy2_setMode (Byte mode);
+Pixy2ErrorCode pixy2_setNexTurn (Word angle);
+Pixy2ErrorCode pixy2_setDefaultTurn (Word angle);
+Pixy2ErrorCode pixy2_setVector (Byte vectorIndex);
+Pixy2ErrorCode pixy2_ReverseVector (void);
+Pixy2ErrorCode pixy2_getRGB (Word x, Word y, Byte saturate, T_pixy2Pixel *pixel);
 
 // Variables globales Publiques
 Byte                Pixy2_numBlocks;
@@ -432,24 +442,24 @@
 Byte                frameContainChecksum;
 
 // Fonctions privées
-int pixy2_sndGetVersion (void);
-int pixy2_sndGetResolution (void);
-int pixy2_sndSetCameraBrightness (Byte brightness);
-int pixy2_sndSetServo (Word s0, Word s1);
-int pixy2_sndSetLED (Byte red, Byte green, Byte blue);
-int pixy2_sndSetLamp (Byte upper, Byte lower);
-int pixy2_sndGetFPS (void);
-int pixy2_sndGetBlocks (Byte sigmap, Byte maxBloc);
-int pixy2_sndGetMainFeature (Byte type, Byte feature);
-int pixy2_sndSetMode (Byte mode);
-int pixy2_sndSetNexTurn (Word angle);
-int pixy2_sndSetDefaultTurn (Word angle);
-int pixy2_sndSetVector (Byte vectorIndex);
-int pixy2_sndReverseVector (void);
-int pixy2_sndGetRGB (Word x, Word y, Byte saturate);
+Pixy2ErrorCode pixy2_sndGetVersion (void);
+Pixy2ErrorCode pixy2_sndGetResolution (void);
+Pixy2ErrorCode pixy2_sndSetCameraBrightness (Byte brightness);
+Pixy2ErrorCode pixy2_sndSetServo (Word s0, Word s1);
+Pixy2ErrorCode pixy2_sndSetLED (Byte red, Byte green, Byte blue);
+Pixy2ErrorCode pixy2_sndSetLamp (Byte upper, Byte lower);
+Pixy2ErrorCode pixy2_sndGetFPS (void);
+Pixy2ErrorCode pixy2_sndGetBlocks (Byte sigmap, Byte maxBloc);
+Pixy2ErrorCode pixy2_sndGetMainFeature (Byte type, Byte feature);
+Pixy2ErrorCode pixy2_sndSetMode (Byte mode);
+Pixy2ErrorCode pixy2_sndSetNexTurn (Word angle);
+Pixy2ErrorCode pixy2_sndSetDefaultTurn (Word angle);
+Pixy2ErrorCode pixy2_sndSetVector (Byte vectorIndex);
+Pixy2ErrorCode pixy2_sndReverseVector (void);
+Pixy2ErrorCode pixy2_sndGetRGB (Word x, Word y, Byte saturate);
 
 void pixy2_getByte ();
-int pixy2_validateChecksum (Byte* tab);
+Pixy2ErrorCode pixy2_validateChecksum (Byte* tab);
 };
 
 #endif        
\ No newline at end of file