vt100: include pgmspace.h as we use PROGMEM macro
[aversive.git] / projects / microb2010 / mainboard / i2c_protocol.c
index 442cf3a..49b707b 100644 (file)
@@ -299,6 +299,10 @@ void i2c_recvevent(uint8_t * buf, int8_t size)
                tmp = ans->rcob;
                if (tmp != I2C_COB_NONE)
                        ballboard.rcob = tmp;
+               ballboard.opponent_x = ans->opponent_x;
+               ballboard.opponent_y = ans->opponent_y;
+               ballboard.opponent_a = ans->opponent_a;
+               ballboard.opponent_d = ans->opponent_d;
                break;
        }
 
@@ -375,6 +379,10 @@ static int8_t i2c_req_ballboard_status(void)
        struct i2c_req_ballboard_status buf;
 
        buf.hdr.cmd = I2C_REQ_BALLBOARD_STATUS;
+       /* robot position */
+       buf.x = position_get_x_s16(&mainboard.pos);
+       buf.y = position_get_y_s16(&mainboard.pos);
+       buf.a = position_get_a_deg_s16(&mainboard.pos);
        return i2c_send(I2C_BALLBOARD_ADDR, (uint8_t*)&buf,
                        sizeof(buf), I2C_CTRL_GENERIC);
 }
@@ -468,3 +476,11 @@ int8_t i2c_ballboard_set_mode(uint8_t mode)
        return i2c_send_command(I2C_BALLBOARD_ADDR, (uint8_t*)&buf, sizeof(buf));
 }
 
+int8_t i2c_ballboard_set_beacon(uint8_t enable)
+{
+       struct i2c_cmd_ballboard_start_beacon buf;
+       buf.hdr.cmd = I2C_CMD_BALLBOARD_SET_BEACON;
+       buf.enable = enable;
+       return i2c_send_command(I2C_BALLBOARD_ADDR, (uint8_t*)&buf, sizeof(buf));
+}
+