discoverpixy
pixyinterpreter.hpp
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 __PIXYINTERPRETER_HPP__
17 #define __PIXYINTERPRETER_HPP__
18 
19 #include <vector>
20 #include "pixytypes.h"
21 #include "pixy.h"
22 #include "pixydefs.h"
23 #include "usblink.h"
24 #include "interpreter.hpp"
25 #include "chirpreceiver.hpp"
26 
27 #define PIXY_BLOCK_CAPACITY 250
28 
29 class PixyInterpreter : public Interpreter
30 {
31  public:
32 
34  ~PixyInterpreter();
35 
48  int init();
49 
54  void close();
55 
62  int blocks_are_new();
63 
79  int get_blocks(int max_blocks, Block * blocks);
80 
87  int send_command(const char * name, va_list arguments);
88 
94  int send_command(const char * name, ...);
95 
96 
97 
98  int service();
99 
100  private:
101 
102  ChirpReceiver * receiver_;
103  USBLink link_;
104  std::vector<Block> blocks_;
105  bool blocks_are_new_;
106  bool init_;
107 
108 
114  void interpret_data(const void * chrip_data[]);
115 
121  void interpret_CCB1(const void * data[]);
122 
128  void interpret_CCB2(const void * data[]);
129 
137  void add_normal_blocks(const BlobA * blocks, uint32_t count);
138 
146  void add_color_code_blocks(const BlobB * blocks, uint32_t count);
147 };
148 
149 #endif
int send_command(const char *name, va_list arguments)
Sends a command to Pixy.
Definition: pixyinterpreter.cpp:100
int get_blocks(int max_blocks, Block *blocks)
Copies up to 'max_blocks' number of Blocks to the address pointed to by 'blocks'. ...
Definition: pixyinterpreter.cpp:64
void close()
Terminates the USB connection to Pixy and the 'iterpreter' thread.
Definition: pixyinterpreter.cpp:54
Definition: pixytypes.h:133
Definition: chirpreceiver.hpp:23
Definition: pixytypes.h:156
int init()
Spawns an 'interpreter' thread which attempts to connect to Pixy using the USB interface. On successful connection, this thread will capture and store Pixy 'block' object data which can be retreived using the getBlocks() method.
Definition: pixyinterpreter.cpp:31
Definition: pixyinterpreter.hpp:29
Definition: interpreter.hpp:19
int blocks_are_new()
Get status of the block data received from Pixy.
Definition: pixyinterpreter.cpp:289
Definition: pixy.h:47