From 60d3060306a09f301b09201cfaefc9a1f88096c4 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Tue, 10 May 2011 19:37:43 +0200 Subject: digital/{ai,io}: add define for backward/forward --- digital/ai/src/common/defs.h | 7 +++++++ digital/ai/src/twi_master/asserv.c | 6 +++--- digital/ai/src/twi_master/asserv.h | 8 ++++---- 3 files changed, 14 insertions(+), 7 deletions(-) (limited to 'digital/ai/src') diff --git a/digital/ai/src/common/defs.h b/digital/ai/src/common/defs.h index f16e9e52..beec5608 100644 --- a/digital/ai/src/common/defs.h +++ b/digital/ai/src/common/defs.h @@ -43,6 +43,13 @@ typedef struct position_t position_t; /** Convert degrees to an angle usable in position_t. */ #define POSITION_A_DEG(a) G_ANGLE_UF016_DEG (a) +/** No particular direction. */ +#define DIRECTION_NONE 0 +/** Forward direction, along the robot X axis. */ +#define DIRECTION_FORWARD 1 +/** Backward, opposite the robot X axis. */ +#define DIRECTION_BACKWARD 2 + /** Team color, determine the start zone side. */ enum team_color_e { diff --git a/digital/ai/src/twi_master/asserv.c b/digital/ai/src/twi_master/asserv.c index d066737b..d9ae9330 100644 --- a/digital/ai/src/twi_master/asserv.c +++ b/digital/ai/src/twi_master/asserv.c @@ -202,12 +202,12 @@ asserv_get_moving_direction (void) { /* Foward move? */ if (asserv_status.status & _BV (asserv_status_flag_move_forward)) - return 1; + return DIRECTION_FORWARD; /* Backward move? */ if (asserv_status.status & _BV (asserv_status_flag_move_backward)) - return 2; + return DIRECTION_BACKWARD; /* Not moving */ - return 0; + return DIRECTION_NONE; } uint8_t diff --git a/digital/ai/src/twi_master/asserv.h b/digital/ai/src/twi_master/asserv.h index 0d29ba96..2aa7a6f8 100644 --- a/digital/ai/src/twi_master/asserv.h +++ b/digital/ai/src/twi_master/asserv.h @@ -121,16 +121,16 @@ asserv_get_motor1_position (void); /** * Are we moving forward/backward? * @return - * - 0 we are not moving; - * - 1 we are moving forward; - * - 2 we are moving backward. + * - DIRECTION_NONE we are not moving; + * - DIRECTION_FORWARD we are moving forward; + * - DIRECTION_BACKWARD we are moving backward. */ uint8_t asserv_get_moving_direction (void); /** * Get the last moving direction of the bot. - * @return 1 is forward, 2 is backward. + * @return DIRECTION_FORWARD or DIRECTION_BACKWARD. */ uint8_t asserv_get_last_moving_direction (void); -- cgit v1.2.3