git.droids-corp.org
/
aversive.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
beacon from 2009
[aversive.git]
/
projects
/
microb2010
/
ballboard
/
i2c_protocol.c
diff --git
a/projects/microb2010/ballboard/i2c_protocol.c
b/projects/microb2010/ballboard/i2c_protocol.c
index
3f5a2eb
..
8f0242d
100644
(file)
--- a/
projects/microb2010/ballboard/i2c_protocol.c
+++ b/
projects/microb2010/ballboard/i2c_protocol.c
@@
-1,6
+1,6
@@
/*
/*
- * Copyright Droids Corporation (20
07
)
- *
+ * Copyright Droids Corporation (20
10
)
+ *
* 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; either version 2 of the License, or
* 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; either version 2 of the License, or
@@
-48,6
+48,7
@@
#include "main.h"
#include "state.h"
#include "sensor.h"
#include "main.h"
#include "state.h"
#include "sensor.h"
+#include "beacon.h"
#include "actuator.h"
void i2c_protocol_init(void)
#include "actuator.h"
void i2c_protocol_init(void)
@@
-74,10
+75,14
@@
void i2c_send_status(void)
struct i2c_ans_ballboard_status ans;
i2c_flush();
ans.hdr.cmd = I2C_ANS_BALLBOARD_STATUS;
struct i2c_ans_ballboard_status ans;
i2c_flush();
ans.hdr.cmd = I2C_ANS_BALLBOARD_STATUS;
- ans.status =
0x55; /* XXX */
+ ans.status =
state_get_status();
ans.ball_count = state_get_ball_count();
ans.lcob = cob_detect_left();
ans.rcob = cob_detect_right();
ans.ball_count = state_get_ball_count();
ans.lcob = cob_detect_left();
ans.rcob = cob_detect_right();
+ ans.opponent_x = beacon.opponent_x;
+ ans.opponent_y = beacon.opponent_y;
+ ans.opponent_a = beacon.opponent_angle;
+ ans.opponent_d = beacon.opponent_dist;
i2c_send(I2C_ADD_MASTER, (uint8_t *) &ans,
sizeof(ans), I2C_CTRL_GENERIC);
i2c_send(I2C_ADD_MASTER, (uint8_t *) &ans,
sizeof(ans), I2C_CTRL_GENERIC);
@@
-124,6
+129,19
@@
void i2c_recvevent(uint8_t * buf, int8_t size)
break;
}
break;
}
+ case I2C_CMD_BALLBOARD_SET_BEACON:
+ {
+ struct i2c_cmd_ballboard_start_beacon *cmd = void_cmd;
+ if (size != sizeof (*cmd))
+ goto error;
+
+ if (cmd->enable)
+ beacon_start();
+ else
+ beacon_stop();
+ break;
+ }
+
case I2C_CMD_BALLBOARD_SET_MODE:
{
struct i2c_cmd_ballboard_set_mode *cmd = void_cmd;
case I2C_CMD_BALLBOARD_SET_MODE:
{
struct i2c_cmd_ballboard_set_mode *cmd = void_cmd;