-
Notifications
You must be signed in to change notification settings - Fork 0
/
camduino.h
88 lines (74 loc) · 2.41 KB
/
camduino.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* @file camduino.h
*
* @section desc File description
*
* Librairy to get some data from an Arduino over I2C.
* CMUcam4 must be connected on it and Arduino must run "CMU_Tracker_I2C" program,
* distance sensors must be connected to the board too.
*
* @section copyright Copyright
*
* Trampoline is copyright (c) IRCCyN 2005-2014
* Trampoline is protected by the French intellectual property law.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @section infos File informations
*
* @date 2014/07/18
* @author Benjamin Sientzoff
* @version 0.1
*/
#ifndef __CAMDUINO_H__
#define __CAMDUINO_H__
#include "i2c.h"
/** list of presence sensors connected to the Arduino board */
enum psensor {
/** the first presence sensor on the left */
PSENSOR_A = 0x1,
/** the second presence sensor on the left */
PSENSOR_B = 0x2,
/** presence sensor on the middle */
PSENSOR_C = 0x4,
/** the second sensor of the right */
PSENSOR_D = 0x8,
/** the last sensor (on the right) */
PSENSOR_E = 0x10
};
/** state of (all) presence sensors when there is no object */
#define NO_DETECTED_OBJECT 31
/** store ball position */
struct position {
/** x coordinate of the ball */
int x;
/** y coordinate of the ball */
int y; /* y coordinate of the ball */
};
/** buffers storing I2C data */
extern u8 i2c_data[I2C_PORT_N][I2C_DATA_N];
/** NXT port connected to Arduino board */
int arduino_port;
/** global state of presence sensors */
int pstate = NO_DETECTED_OBJECT;
/** Initiate Arduino driver */
void init_camduino(int);
/** Fill a position strucuture to get ball position */
void get_ball_position(struct position*);
/** Get global presence sensors state, consider the five sensors as one */
int object_detected();
/** get an given presence sensor state */
int get_pstate(enum psensor);
#endif // __CAMDUINO_H__