From d7211fc08b077030cf7f065d3834e201d17c18a5 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Tue, 13 Apr 2010 00:21:48 +0200 Subject: digital/io/src: refactor position and angle macros --- digital/io/src/playground.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'digital/io/src/playground.h') diff --git a/digital/io/src/playground.h b/digital/io/src/playground.h index 0ff7a11c..1ec6e47e 100644 --- a/digital/io/src/playground.h +++ b/digital/io/src/playground.h @@ -34,6 +34,7 @@ * see it with the two start zone at the top of the scheme). */ +#include "defs.h" #include "bot.h" /** @@ -55,15 +56,25 @@ * Considering there is a symmetry axis on X, this macro will compute the * value for on the X axis depending on the color. */ -#define PG_X_VALUE_COMPUTING(x) \ - (bot_color ? (x) : PG_WIDTH - (x)) +#define PG_X(x) (bot_color ? (x) : PG_WIDTH - (x)) + +/** Same as PG_Y, but for Y coordinate. Actually nothing is done, there is no + * symmetry. */ +#define PG_Y(y) (y) /** * Considering there is a symmetry axis on X, this macro will compute the * value of the angle depending on the color. + * + * Takes degrees as input. */ -#define PG_A_VALUE_COMPUTING(a) \ - (bot_color ? (a) : (BOT_ANGLE_DEGREE * 180) - (a)) +#define PG_A_DEG(a) \ + (bot_color ? POSITION_A_DEG (a) : POSITION_A_DEG (180 - (a))) + +/** Initialiser for position_t applying symmetry according to color. Takes + * degrees for angle. */ +#define PG_POSITION_DEG(x, y, a) \ + { { PG_X (x), PG_Y (y) }, PG_A_DEG (a) } /** * Start zone. -- cgit v1.2.3