FRC - Hackathon / Pixy

Dependents:   TestPixy FRC_2018 FRC2018_Bis 0hackton_08_06_18 ... more

Fork of Pixy by FRC - Hackathon

Embed: (wiki syntax)

« Back to documentation index

PIXY Class Reference

PIXY Class Reference

Pixy : CMU CAM 5 - Smart camera More informations at http://cmucam.org/projects/cmucam5. More...

#include <Pixy.h>

Public Member Functions

 PIXY (PinName tx, PinName rx, int debit=230400)
 Constructor of pixy object.
int detectedObject (int *nbNM, int *nbCC)
 Return the number of objects (normal and ColorCode) that have been received from the PIXY and stored in the FIFO during the last frame.
T_pixyCCBloc getCCBloc (void)
 Reads the oldest Color Code object from the last frame received.
T_pixyNMBloc getNMBloc (void)
 Reads the oldest Normal object from the last frame received.
void setBrightness (Byte brightness)
 Set the Brightness of the Pixy.
int checkNewImage (void)
 Gives information about a new image taken by Pixy.
int checkPixy (void)
 Gives information about a detected Pixy.

Data Fields

T_pixyCCData Pixy_CCFIFO [CC_MAXOBJECT]
 Direct access to the CC FIFO.
T_pixyNMData Pixy_NMFIFO [NM_MAXOBJECT]
 Direct access to the NM FIFO.
Byte Pixy_CCObjet
 is the number of CC object read by the library ISR from the CAM during the last frame
Byte Pixy_NMObjet
 is the number of normal object read by the library ISR from the CAM during the last frame
int FlagPixy
 A new frame as been read.
int FlagPixyOverflow
 Data have been lost.

Detailed Description

Pixy : CMU CAM 5 - Smart camera More informations at http://cmucam.org/projects/cmucam5.

Definition at line 140 of file Pixy.h.


Constructor & Destructor Documentation

PIXY ( PinName  tx,
PinName  rx,
int  debit = 230400 
)

Constructor of pixy object.

Parameters:
tx: the Mbed pin used as TX
rx: the Mbed pin used as RX
debit: the bitrate of the serial (max value is 230400 b/s)

Definition at line 3 of file Pixy.cpp.


Member Function Documentation

int checkNewImage ( void   )

Gives information about a new image taken by Pixy.

Returns:
0 if no new image or 1 if there is a new image

Definition at line 212 of file Pixy.cpp.

int checkPixy ( void   )

Gives information about a detected Pixy.

Returns:
-1 if no Pixy detected or 0 if Pixy detected

Definition at line 222 of file Pixy.cpp.

int detectedObject ( int *  nbNM,
int *  nbCC 
)

Return the number of objects (normal and ColorCode) that have been received from the PIXY and stored in the FIFO during the last frame.

Parameters:
nbNM(int - passed by reference) : number of normal object detected
nbCC(int - passed by reference) : number of color code object detected
Returns:
0 if sucessfull, -1 if no PIXY is talking, -2 sucessfull but object(s) have been lost from previous frames (missed frame) or from actual (too many objects)

Definition at line 154 of file Pixy.cpp.

T_pixyCCBloc getCCBloc ( void   )

Reads the oldest Color Code object from the last frame received.

Note:
this function also manage the read pointer of the Color Code FIFO (ie : after use function point the next object to be read)
Returns:
a T_PixyCCBloc (see .h for details)

Definition at line 163 of file Pixy.cpp.

T_pixyNMBloc getNMBloc ( void   )

Reads the oldest Normal object from the last frame received.

Note:
this function also manage the read pointer of the Normal FIFO (ie : after use function point the next object to be read)
Returns:
a T_PixyNMBloc (see .h for details)

Definition at line 184 of file Pixy.cpp.

void setBrightness ( Byte  brightness )

Set the Brightness of the Pixy.

Parameters:
brightnesslevel (between 0 and 255)

Definition at line 205 of file Pixy.cpp.


Field Documentation

A new frame as been read.

Note:
Semaphore are global variable used to communicate from ISR with main routine. All semaphores must be cleared by user.

is automaticly set after each received image frame

Definition at line 192 of file Pixy.h.

Data have been lost.

Note:
Semaphore are global variable used to communicate from ISR with main routine. All semaphores must be cleared by user.

is automaticly set if any FIFO oveflows (more than object of a kind than allowed by NM_MAXOBJECT or CC_MAXOBJECT).

Definition at line 192 of file Pixy.h.

Pixy_CCFIFO[CC_MAXOBJECT]

Direct access to the CC FIFO.

Note:
A FIFO is a circular buffer where data are stored in the order in witch they arrive and can be read in the same order. A FIFO need 2 variables (call read and write pointers) to point both read and write registers.
The library manage both read and write pointers with FIFO functions, but users can access the FIFO with their own code, users must then manage their own read pointers while write pointers (that are strictly private) can only be managed by the library functions.

is a FIFO where the Color Code objects are stored. FIFO can store up to 20 objects (CC_MAXOBJECT = 20)

Definition at line 171 of file Pixy.h.

is the number of CC object read by the library ISR from the CAM during the last frame

Note:
not Thread Safe

Definition at line 173 of file Pixy.h.

Pixy_NMFIFO[NM_MAXOBJECT]

Direct access to the NM FIFO.

Note:
A FIFO is a circular buffer where data are stored in the order in witch they arrive and can be read in the same order. A FIFO need 2 variables (call read and write pointers) to point both read and write registers.
The library manage both read and write pointers with FIFO functions, but users can access the FIFO with their own code, users must then manage their own read pointers while write pointers (that are strictly private) can only be managed by the library functions.

is a FIFO where the Normal objects are stored. FIFO can store up to 20 objects (NM_MAXOBJECT = 20)

Definition at line 172 of file Pixy.h.

is the number of normal object read by the library ISR from the CAM during the last frame

Note:
not Thread Safe

Definition at line 174 of file Pixy.h.