Pixy: A fast, easy to use, vision sensor
 All Classes Files Functions Variables Macros Pages
Classes | Macros | Functions
pixy.h File Reference
#include <stdint.h>
#include <unistd.h>
#include <pixydefs.h>

Go to the source code of this file.

Classes

struct  Block
 

Macros

#define TYPE_NORMAL   0
 
#define TYPE_COLOR_CODE   1
 

Functions

int pixy_init ()
 Creates a connection with Pixy and listens for Pixy messages. More...
 
int pixy_blocks_are_new ()
 Indicates when new block data from Pixy is received. More...
 
int pixy_get_blocks (uint16_t max_blocks, struct Block *blocks)
 Copies up to 'max_blocks' number of Blocks to the address pointed to by 'blocks'. More...
 
int pixy_command (const char *name,...)
 Send a command to Pixy. More...
 
void pixy_close ()
 Terminates connection with Pixy. More...
 
void pixy_error (int error_code)
 Send description of pixy error to stdout. More...
 
int pixy_led_set_RGB (uint8_t red, uint8_t green, uint8_t blue)
 Set color of pixy LED. More...
 
int pixy_led_set_max_current (uint32_t current)
 Set pixy LED maximum current. More...
 
int pixy_led_get_max_current ()
 Get pixy LED maximum current. More...
 
int pixy_cam_set_auto_white_balance (uint8_t value)
 Enable or disable pixy camera auto white balance. More...
 
int pixy_cam_get_auto_white_balance ()
 Get pixy camera auto white balance setting. More...
 
uint32_t pixy_cam_get_white_balance_value ()
 Get pixy camera white balance() More...
 
int pixy_cam_set_white_balance_value (uint8_t red, uint8_t green, uint8_t blue)
 Set pixy camera white balance. More...
 
int pixy_cam_set_auto_exposure_compensation (uint8_t enable)
 Enable or disable pixy camera auto exposure compensation. More...
 
int pixy_cam_get_auto_exposure_compensation ()
 Get pixy camera auto exposure compensation setting. More...
 
int pixy_cam_set_exposure_compensation (uint8_t gain, uint16_t compensation)
 Set pixy camera exposure compensation. More...
 
int pixy_cam_get_exposure_compensation (uint8_t *gain, uint16_t *compensation)
 Get pixy camera exposure compensation. More...
 
int pixy_cam_set_brightness (uint8_t brightness)
 Set pixy camera brightness. More...
 
int pixy_cam_get_brightness ()
 Get pixy camera brightness. More...
 
int pixy_rcs_get_position (uint8_t channel)
 Get pixy servo axis position. More...
 
int pixy_rcs_set_position (uint8_t channel, uint16_t position)
 Set pixy servo axis position. More...
 
int pixy_rcs_set_frequency (uint16_t frequency)
 Set pixy servo pulse width modulation (PWM) frequency. More...
 
int pixy_get_firmware_version (uint16_t *major, uint16_t *minor, uint16_t *build)
 Get pixy firmware version. More...
 

Macro Definition Documentation

#define TYPE_COLOR_CODE   1

Definition at line 31 of file pixy.h.

#define TYPE_NORMAL   0

Definition at line 30 of file pixy.h.

Function Documentation

int pixy_blocks_are_new ( )

Indicates when new block data from Pixy is received.

Returns
1 New Data: Block data has been updated.
0 Stale Data: Block data has not changed since pixy_get_blocks() was last called.

Definition at line 106 of file pixy.cpp.

int pixy_cam_get_auto_exposure_compensation ( )

Get pixy camera auto exposure compensation setting.

Returns
1 Auto exposure compensation enabled.
0 Auto exposure compensation disabled.
Negative Error

Definition at line 252 of file pixy.cpp.

int pixy_cam_get_auto_white_balance ( )

Get pixy camera auto white balance setting.

Returns
1 Auto white balance is enabled.
0 Auto white balance is disabled.
Negative Error

Definition at line 203 of file pixy.cpp.

int pixy_cam_get_brightness ( )

Get pixy camera brightness.

Returns
Non-negative Brightness value.
Negative Error

Definition at line 316 of file pixy.cpp.

int pixy_cam_get_exposure_compensation ( uint8_t *  gain,
uint16_t *  compensation 
)

Get pixy camera exposure compensation.

Parameters
[out]gainCamera gain.
[out]compCamera exposure compensation.
Returns
0 Success
Negative Error

Definition at line 281 of file pixy.cpp.

uint32_t pixy_cam_get_white_balance_value ( )

Get pixy camera white balance()

Returns
Composite value for RGB white balance: white balance = green_value + (red_value << 8) + (blue << 16)

Definition at line 219 of file pixy.cpp.

int pixy_cam_set_auto_exposure_compensation ( uint8_t  enable)

Enable or disable pixy camera auto exposure compensation.

Parameters
[in]enable0: Disable auto exposure compensation. 1: Enable auto exposure compensation.
Returns
0 Success
Negative Error

Definition at line 242 of file pixy.cpp.

int pixy_cam_set_auto_white_balance ( uint8_t  value)

Enable or disable pixy camera auto white balance.

Parameters
enable1: Enable white balance. 0: Disable white balance.
Returns
0 Success
Negative Error

Definition at line 193 of file pixy.cpp.

int pixy_cam_set_brightness ( uint8_t  brightness)

Set pixy camera brightness.

Parameters
[in]brightnessBrightness value.
Returns
0 Success
Negative Error

Definition at line 306 of file pixy.cpp.

int pixy_cam_set_exposure_compensation ( uint8_t  gain,
uint16_t  compensation 
)

Set pixy camera exposure compensation.

Parameters
[in]gainCamera gain.
[in]compCamera exposure compensation.
Returns
0 Success
Negative Error

Definition at line 268 of file pixy.cpp.

int pixy_cam_set_white_balance_value ( uint8_t  red,
uint8_t  green,
uint8_t  blue 
)

Set pixy camera white balance.

Parameters
[in]redRed white balance value.
[in]greenGreen white balance value.
[in]blueBlue white balance value.
Returns
0 Success
Negative Error

Definition at line 229 of file pixy.cpp.

void pixy_close ( )

Terminates connection with Pixy.

Definition at line 125 of file pixy.cpp.

int pixy_command ( const char *  name,
  ... 
)

Send a command to Pixy.

Parameters
[in]nameChirp remote procedure call identifier string.
Returns
-1 Error

Definition at line 111 of file pixy.cpp.

void pixy_error ( int  error_code)

Send description of pixy error to stdout.

Parameters
[in]error_codePixy error code

Definition at line 132 of file pixy.cpp.

int pixy_get_blocks ( uint16_t  max_blocks,
struct Block blocks 
)

Copies up to 'max_blocks' number of Blocks to the address pointed to by 'blocks'.

Parameters
[in]max_blocksMaximum number of Blocks to copy to the address pointed to by 'blocks'.
[out]blocksAddress of an array in which to copy the blocks to. The array must be large enough to write 'max_blocks' number of Blocks to.
Returns
Non-negative Success: Number of blocks copied
PIXY_ERROR_USB_IO USB Error: I/O
PIXY_ERROR_NOT_FOUND USB Error: Pixy not found
PIXY_ERROR_USB_BUSY USB Error: Busy
PIXY_ERROR_USB_NO_DEVICE USB Error: No device
PIXY_ERROR_INVALID_PARAMETER Invalid pararmeter specified

Definition at line 101 of file pixy.cpp.

int pixy_get_firmware_version ( uint16_t *  major,
uint16_t *  minor,
uint16_t *  build 
)

Get pixy firmware version.

Parameters
[out]majorMajor version component
[out]minorMinor version component
[out]buildBuild identifier
Returns
0 Success
Negative Error

Definition at line 376 of file pixy.cpp.

int pixy_init ( )

Creates a connection with Pixy and listens for Pixy messages.

Returns
0 Success
PIXY_ERROR_USB_IO USB Error: I/O
PIXY_ERROR_NOT_FOUND USB Error: Pixy not found
PIXY_ERROR_USB_BUSY USB Error: Busy
PIXY_ERROR_USB_NO_DEVICE USB Error: No device

Definition at line 87 of file pixy.cpp.

int pixy_led_get_max_current ( )

Get pixy LED maximum current.

Returns
Non-negative Maximum LED current value (microamps).
Negative Error

Definition at line 177 of file pixy.cpp.

int pixy_led_set_max_current ( uint32_t  current)

Set pixy LED maximum current.

Parameters
[in]currentMaximum current (microamps).
Returns
0 Success
Negative Error

Definition at line 167 of file pixy.cpp.

int pixy_led_set_RGB ( uint8_t  red,
uint8_t  green,
uint8_t  blue 
)

Set color of pixy LED.

Parameters
[in]redBrightness value for red LED element. [0, 255] 0 = Off, 255 = On
[in]greenBrightness value for green LED element. [0, 255] 0 = Off, 255 = On
[in]blueBrightness value for blue LED element. [0, 255] 0 = Off, 255 = On
Returns
0 Success
Negative Error

Definition at line 153 of file pixy.cpp.

int pixy_rcs_get_position ( uint8_t  channel)

Get pixy servo axis position.

Parameters
channelChannel value. Range: [0, 1]
Returns
Position of channel. Range: [0, 999]
Negative Error

Definition at line 332 of file pixy.cpp.

int pixy_rcs_set_frequency ( uint16_t  frequency)

Set pixy servo pulse width modulation (PWM) frequency.

Parameters
frequencyRange: [20, 300] Hz Default: 50 Hz

Definition at line 362 of file pixy.cpp.

int pixy_rcs_set_position ( uint8_t  channel,
uint16_t  position 
)

Set pixy servo axis position.

Parameters
channelChannel value. Range: [0, 1]
positionPosition value of the channel. Range: [0, 999]
Returns
0 Success
Negative Error

Definition at line 348 of file pixy.cpp.