/* return 1 or 0 depending on which side of a line (y=cste) is the
* robot. works in yellow or blue color. */
-uint8_t y_is_more_than(int16_t y)
+uint8_t __y_is_more_than(int16_t posy, int16_t y)
{
- int16_t posy;
-
- posy = position_get_y_s16(&mainboard.pos);
if (mainboard.our_color == I2C_COLOR_YELLOW) {
if (posy > y)
return 1;
/* return 1 or 0 depending on which side of a line (x=cste) is the
* robot. works in yellow or blue color. */
-uint8_t x_is_more_than(int16_t x)
+uint8_t __x_is_more_than(int16_t posx, int16_t x)
{
- int16_t posx;
-
- posx = position_get_x_s16(&mainboard.pos);
if (posx > x)
return 1;
else
return 0;
}
+/* return 1 or 0 depending on which side of a line (y=cste) is the
+ * robot. works in yellow or blue color. */
+uint8_t y_is_more_than(int16_t y)
+{
+ int16_t posy;
+ posy = position_get_y_s16(&mainboard.pos);
+ return __y_is_more_than(posy, y);
+}
+
+/* return 1 or 0 depending on which side of a line (x=cste) is the
+ * robot. works in yellow or blue color. */
+uint8_t x_is_more_than(int16_t x)
+{
+ int16_t posx;
+ posx = position_get_x_s16(&mainboard.pos);
+ return __x_is_more_than(posx, x);
+}
+
int16_t sin_table[] = {
0,
3211,
return I2C_COLOR_YELLOW;
}
-/* get the da pos of the opponent robot */
-int8_t get_opponent_da(int16_t *d, int16_t *a)
+/* get the xy pos of the opponent robot */
+int8_t get_opponent_xy(int16_t *x, int16_t *y)
{
uint8_t flags;
- int16_t x;
-
IRQ_LOCK(flags);
- *d = beaconboard.oppd;
- *a = beaconboard.oppa;
- x = beaconboard.oppx;
+ *x = ballboard.opponent_x;
+ *y = ballboard.opponent_y;
IRQ_UNLOCK(flags);
- if (x == I2C_OPPONENT_NOT_THERE)
+ if (*x == I2C_OPPONENT_NOT_THERE)
return -1;
return 0;
}
-/* get the xy pos of the opponent robot */
-int8_t get_opponent_xy(int16_t *x, int16_t *y)
+/* get the da pos of the opponent robot */
+int8_t get_opponent_da(int16_t *d, int16_t *a)
{
uint8_t flags;
-
+ int16_t x_tmp;
IRQ_LOCK(flags);
- *x = beaconboard.oppx;
- *y = beaconboard.oppy;
+ x_tmp = ballboard.opponent_x;
+ *d = ballboard.opponent_d;
+ *a = ballboard.opponent_a;
IRQ_UNLOCK(flags);
- if (*x == I2C_OPPONENT_NOT_THERE)
+ if (x_tmp == I2C_OPPONENT_NOT_THERE)
return -1;
-
return 0;
}
int8_t get_opponent_xyda(int16_t *x, int16_t *y, int16_t *d, int16_t *a)
{
uint8_t flags;
-
IRQ_LOCK(flags);
- *x = beaconboard.oppx;
- *y = beaconboard.oppy;
- *d = beaconboard.oppd;
- *a = beaconboard.oppa;
+ *x = ballboard.opponent_x;
+ *y = ballboard.opponent_y;
+ *d = ballboard.opponent_d;
+ *a = ballboard.opponent_a;
IRQ_UNLOCK(flags);
if (*x == I2C_OPPONENT_NOT_THERE)
return -1;
-
return 0;
}