Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: pixy2.h
- Revision:
- 22:5f76404e2cbc
- Parent:
- 21:aeb9fb464ef9
- Child:
- 23:d6bbc4ec1f22
--- a/pixy2.h Mon Apr 08 13:41:43 2019 +0000
+++ b/pixy2.h Thu Nov 21 08:31:58 2019 +0000
@@ -24,7 +24,7 @@
* @section DESCRIPTION
*
* CMUCAM 5 - Pixy2
- *
+ *
* Datasheet, FAQ and PC drivers :
*
* http://www.pixycam.com/
@@ -41,8 +41,9 @@
/**
* Defines
*/
+#define _DEBUG_ 0
#define PIXY2_NCSHEADERSIZE 4
-#define PIXY2_CSHEADERSIZE 4
+#define PIXY2_CSHEADERSIZE 6 // Possible erreur : Ancienne valeur 4
#define PIXY2_SYNC 0xC1AE
#define PIXY2_CSSYNC 0xC1AF
#define PIXY2_REP_ACK 1
@@ -121,7 +122,7 @@
typedef long slWord;
/**
- * \union T_Word
+ * \union T_Word
* \brief Structured type to switch from word to bytes
* \param mot (Word) : 16 bits word
* \param octet (Byte) : 2 bytes that overlap mot (byte access)
@@ -369,6 +370,19 @@
/**
* Pixy2 : CMU CAM 5 - Smart camera
* More informations at http://www.pixycam.com/
+ * Use pointer to pointer in order to connect pointer adress (passed by ref by user)
+ * to the address of the buffer that contains the received message : see example below
+ * \code{.cpp}
+ * PIXY2 myPixy(UART_TX, UART_RX);
+ * T_pixy2Version *pixyVersion;
+ *
+ * while(1) {
+ * if( myPixy.pixy2_getVersion(&pixyVersion) == PIXY2_OK ) {
+ * printf("myPixy's version : %s\n\r", pixyVersion->pixHFString);
+ * break;
+ * }
+ * }
+ * \endcode
*/
class PIXY2 {
@@ -382,9 +396,9 @@
*
* @param tx : the Mbed pin used as TX
* @param rx : the Mbed pin used as RX
- * @param debit : the bitrate of the serial (max value is 230400 b/s)
+ * @param debit : the bitrate of the serial (max value is 230 kbaud/s)
*/
-PIXY2(PinName tx, PinName rx, int debit = 230400);
+PIXY2(PinName tx, PinName rx, int debit = 230000);
/**
* Destructor of pixy2 UART object.
@@ -397,20 +411,20 @@
* Queries and receives the firmware and hardware version of Pixy2, which is put in the version member variable.
* @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
+ * @param ptrVersion (T_pixy2Version - passed by reference) : pointer to a pointer of the version data structure
* @return T_pixy2ErrorCode : error code.
*/
-T_pixy2ErrorCode pixy2_getVersion (T_pixy2Version *version);
+T_pixy2ErrorCode pixy2_getVersion (T_pixy2Version **ptrVersion);
/**
* Gets the width and height of the frames used by the current program.
* After calling this function, the width and height can be found in the frameWidth and frameHeight member variables.
* @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
+ * @param ptrResolution (T_pixy2Resolution - passed by reference) : pointer to a pointer of the resolution data structure
* @return T_pixy2ErrorCode : error code.
*/
-T_pixy2ErrorCode pixy2_getResolution (T_pixy2Resolution *resolution);
+T_pixy2ErrorCode pixy2_getResolution (T_pixy2Resolution **ptrResolution);
/**
* Sets the relative exposure level of Pixy2's image sensor.
@@ -478,7 +492,7 @@
* @return T_pixy2ErrorCode : error code.
* @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.
* @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.
- * @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).
+ * @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).
*/
T_pixy2ErrorCode pixy2_getBlocks (Byte sigmap, Byte maxBloc);
@@ -608,7 +622,7 @@
Byte Pixy2_numBarcodes;
T_pixy2BarCode *Pixy2_barcodes;
-private :
+//private :
// Variables globales Privées
/**
* @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)