Pixy: A fast, easy to use, vision sensor
 All Classes Files Functions Variables Macros Pages
pixy.h
Go to the documentation of this file.
1 //
2 // begin license header
3 //
4 // This file is part of Pixy CMUcam5 or "Pixy" for short
5 //
6 // All Pixy source code is provided under the terms of the
7 // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html).
8 // Those wishing to use Pixy source code, software and/or
9 // technologies under different licensing terms should contact us at
10 // cmucam@cs.cmu.edu. Such licensing terms are available for
11 // all portions of the Pixy codebase presented here.
12 //
13 // end license header
14 //
15 
16 #ifndef __PIXY_H__
17 #define __PIXY_H__
18 
19 #include <stdint.h>
20 #include <unistd.h>
21 #include <pixydefs.h>
22 
23 // Pixy C API //
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif
29 
30  #define TYPE_NORMAL 0
31  #define TYPE_COLOR_CODE 1
32 
33  struct Block
34  {
35  uint16_t type;
36  uint16_t signature;
37  uint16_t x;
38  uint16_t y;
39  uint16_t width;
40  uint16_t height;
41  int16_t angle;
42  };
43 
52  int pixy_init();
53 
61  int pixy_blocks_are_new();
62 
78  int pixy_get_blocks(uint16_t max_blocks, struct Block * blocks);
79 
86  int pixy_command(const char *name, ...);
87 
91  void pixy_close();
92 
97  void pixy_error(int error_code);
98 
107  int pixy_led_set_RGB(uint8_t red, uint8_t green, uint8_t blue);
108 
115  int pixy_led_set_max_current(uint32_t current);
116 
123 
131  int pixy_cam_set_auto_white_balance(uint8_t value);
132 
140 
147 
156  int pixy_cam_set_white_balance_value(uint8_t red, uint8_t green, uint8_t blue);
157 
165  int pixy_cam_set_auto_exposure_compensation(uint8_t enable);
166 
174 
182  int pixy_cam_set_exposure_compensation(uint8_t gain, uint16_t compensation);
183 
191  int pixy_cam_get_exposure_compensation(uint8_t * gain, uint16_t * compensation);
192 
199  int pixy_cam_set_brightness(uint8_t brightness);
200 
207 
214  int pixy_rcs_get_position(uint8_t channel);
215 
223  int pixy_rcs_set_position(uint8_t channel, uint16_t position);
224 
229  int pixy_rcs_set_frequency(uint16_t frequency);
230 
239  int pixy_get_firmware_version(uint16_t * major, uint16_t * minor, uint16_t * build);
240 
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 
246 #endif
int pixy_rcs_set_position(uint8_t channel, uint16_t position)
Set pixy servo axis position.
Definition: pixy.cpp:348
int pixy_cam_set_brightness(uint8_t brightness)
Set pixy camera brightness.
Definition: pixy.cpp:306
void pixy_close()
Terminates connection with Pixy.
Definition: pixy.cpp:125
int pixy_get_firmware_version(uint16_t *major, uint16_t *minor, uint16_t *build)
Get pixy firmware version.
Definition: pixy.cpp:376
int pixy_cam_set_auto_white_balance(uint8_t value)
Enable or disable pixy camera auto white balance.
Definition: pixy.cpp:193
uint32_t pixy_cam_get_white_balance_value()
Get pixy camera white balance()
Definition: pixy.cpp:219
uint16_t signature
Definition: pixy.h:36
uint16_t width
Definition: pixy.h:39
int pixy_rcs_get_position(uint8_t channel)
Get pixy servo axis position.
Definition: pixy.cpp:332
int pixy_cam_get_auto_exposure_compensation()
Get pixy camera auto exposure compensation setting.
Definition: pixy.cpp:252
int pixy_cam_set_exposure_compensation(uint8_t gain, uint16_t compensation)
Set pixy camera exposure compensation.
Definition: pixy.cpp:268
uint16_t x
Definition: pixy.h:37
int pixy_cam_set_white_balance_value(uint8_t red, uint8_t green, uint8_t blue)
Set pixy camera white balance.
Definition: pixy.cpp:229
int pixy_cam_set_auto_exposure_compensation(uint8_t enable)
Enable or disable pixy camera auto exposure compensation.
Definition: pixy.cpp:242
int pixy_led_set_RGB(uint8_t red, uint8_t green, uint8_t blue)
Set color of pixy LED.
Definition: pixy.cpp:153
int pixy_led_get_max_current()
Get pixy LED maximum current.
Definition: pixy.cpp:177
int pixy_cam_get_auto_white_balance()
Get pixy camera auto white balance setting.
Definition: pixy.cpp:203
int pixy_led_set_max_current(uint32_t current)
Set pixy LED maximum current.
Definition: pixy.cpp:167
int16_t angle
Definition: pixy.h:41
uint16_t type
Definition: pixy.h:35
int pixy_cam_get_exposure_compensation(uint8_t *gain, uint16_t *compensation)
Get pixy camera exposure compensation.
Definition: pixy.cpp:281
uint16_t y
Definition: pixy.h:38
int pixy_command(const char *name,...)
Send a command to Pixy.
Definition: pixy.cpp:111
uint16_t height
Definition: pixy.h:40
int pixy_cam_get_brightness()
Get pixy camera brightness.
Definition: pixy.cpp:316
int pixy_blocks_are_new()
Indicates when new block data from Pixy is received.
Definition: pixy.cpp:106
Definition: pixy.h:33
int pixy_init()
Creates a connection with Pixy and listens for Pixy messages.
Definition: pixy.cpp:87
void pixy_error(int error_code)
Send description of pixy error to stdout.
Definition: pixy.cpp:132
int pixy_rcs_set_frequency(uint16_t frequency)
Set pixy servo pulse width modulation (PWM) frequency.
Definition: pixy.cpp:362
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'. ...
Definition: pixy.cpp:101