-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathPVision.h
66 lines (51 loc) · 1.13 KB
/
PVision.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// PVision library for interaction with the Pixart sensor on a WiiMote
// This work was derived from Kako's excellent Japanese website
// http://www.kako.com/neta/2007-001/2007-001.html
// Steve Hobley 2009 - www.stephenhobley.com
#ifndef PVision_h
#define PVision_h
#include <Arduino.h>
#include <Wire.h>
// bit flags for blobs
#define BLOB1 0x01
#define BLOB2 0x02
#define BLOB3 0x04
#define BLOB4 0x08
// Returned structure from a call to readSample()
struct Blob
{
int X;
int Y;
int Size;
byte number;
};
class PVision
{
public:
PVision();
void init(); // returns true if the connection to the sensor established correctly
byte read(); // updated the blobs, and returns the number of blobs detected
// Make these public
Blob Blob1;
Blob Blob2;
Blob Blob3;
Blob Blob4;
private:
// per object data
int IRsensorAddress;
int IRslaveAddress;
byte data_buf[16];
int i;
int s;
void Write_2bytes(byte d1, byte d2);
byte blobcount; // returns the number of blobs found - reads the sensor
};
// Arduino 0012 workaround
#undef int
#undef char
#undef long
#undef byte
#undef float
#undef abs
#undef round
#endif