From 092057218111adb25119f0099c5ad951a5b10d69 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 2 May 2011 22:48:05 +0200 Subject: digital/{ai,io}: move defines to ai --- digital/io/src/Makefile | 2 +- digital/io/src/bot.h | 14 ------ digital/io/src/debug.host.h | 42 ------------------ digital/io/src/defs.h | 46 ------------------- digital/io/src/init.c | 4 +- digital/io/src/main.c | 4 +- digital/io/src/playground.h | 96 ---------------------------------------- digital/io/src/playground_2010.h | 46 +++++++++++++++++++ digital/io/src/radar.c | 3 +- digital/io/src/switch.avr.c | 2 +- digital/io/src/switch.h | 3 +- digital/io/src/top.c | 1 + 12 files changed, 56 insertions(+), 207 deletions(-) delete mode 100644 digital/io/src/debug.host.h delete mode 100644 digital/io/src/defs.h delete mode 100644 digital/io/src/playground.h create mode 100644 digital/io/src/playground_2010.h (limited to 'digital/io/src') diff --git a/digital/io/src/Makefile b/digital/io/src/Makefile index 8e9a6888..7ac4eefe 100644 --- a/digital/io/src/Makefile +++ b/digital/io/src/Makefile @@ -12,7 +12,7 @@ io_SOURCES = main.c servo.avr.c eeprom.avr.c pwm.c \ # Modules needed for IO. MODULES = proto uart twi utils adc math/fixed math/geometry path/astar \ trace flash spi -AI_MODULES = twi_master +AI_MODULES = twi_master common # Configuration file. CONFIGFILE = avrconfig.h # IO board use an ATMega128. diff --git a/digital/io/src/bot.h b/digital/io/src/bot.h index 06f6559b..01515574 100644 --- a/digital/io/src/bot.h +++ b/digital/io/src/bot.h @@ -128,18 +128,4 @@ /** Gate stroke in steps. */ #define BOT_GATE_STROKE_STEP -0x203e -/** - * Definition of the colors. - */ -enum team_color_e -{ - RED_TEAM = 0, - BLUE_TEAM = 1 -}; - -/** - * Our color. - */ -extern enum team_color_e bot_color; - #endif /* bot_h */ diff --git a/digital/io/src/debug.host.h b/digital/io/src/debug.host.h deleted file mode 100644 index 4930b937..00000000 --- a/digital/io/src/debug.host.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef debug_host_h -#define debug_host_h -/* debug.host.h */ -/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{ - * - * Copyright (C) 2008 Dufour Jérémy - * - * APBTeam: - * Web: http://apbteam.org/ - * Email: team AT apbteam DOT org - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * }}} */ - -/** - * @file Debug printf functions. - * This module include a macro to add some debug functions to printf a message - * under host target. It does nothing under avr target. - */ - -#ifdef HOST -#include -#define DPRINTF(format, args...) \ - do { fprintf (stderr, (format), ## args); } while (0) -#else /* HOST */ -#define DPRINTF(format, args...) -#endif /* HOST */ - -#endif /* debug_host_h */ diff --git a/digital/io/src/defs.h b/digital/io/src/defs.h deleted file mode 100644 index d80ff96d..00000000 --- a/digital/io/src/defs.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef defs_h -#define defs_h -/* defs.h */ -/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{ - * - * Copyright (C) 2010 Nicolas Schodet - * - * APBTeam: - * Web: http://apbteam.org/ - * Email: team AT apbteam DOT org - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * }}} */ -#include "modules/math/geometry/geometry.h" -#include "modules/math/geometry/vect.h" - -/** General purpose defines. */ - -/** Structure defining a position with an angle. */ -struct position_t -{ - /** Cartesian position in millimeters, (0, 0) is at bottom left. */ - vect_t v; - /** Angle, counter-clockwise, [0, 1), f0.16. - * For example, 0x8000 means 0.5, which means 180 degrees. */ - uint16_t a; -}; -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) - -#endif /* defs_h */ diff --git a/digital/io/src/init.c b/digital/io/src/init.c index 4cb2bcd9..58c94333 100644 --- a/digital/io/src/init.c +++ b/digital/io/src/init.c @@ -28,7 +28,7 @@ #include "fsm.h" #include "asserv.h" #include "init.h" -#include "playground.h" +#include "playground_2010.h" #include "main.h" #include "bot.h" #include "switch.h" @@ -107,7 +107,7 @@ FSM_TRANS (INIT_WAIT_FIRST_JACK_OUT, /* Initialize trace module (erase the flash). */ trace_init (); /* Get the color. */ - bot_color = switch_get_color (); + team_color = switch_get_color (); return FSM_NEXT (INIT_WAIT_FIRST_JACK_OUT, jack_removed_from_bot); } diff --git a/digital/io/src/main.c b/digital/io/src/main.c index dc98d12d..b29d1fea 100644 --- a/digital/io/src/main.c +++ b/digital/io/src/main.c @@ -54,7 +54,7 @@ #include "radar.h" #include "chrono.h" /* chrono_end_match */ #include "pwm.h" -#include "playground.h" +#include "playground_2010.h" #include "contact.h" #include "init.h" #include "move.h" @@ -76,7 +76,7 @@ static void main_loop (void); /** * Our color. */ -enum team_color_e bot_color; +enum team_color_e team_color; /** Maximum number of events in post queue. */ #define MAIN_POST_EVENT_QUEUE_SIZE 8 diff --git a/digital/io/src/playground.h b/digital/io/src/playground.h deleted file mode 100644 index 5c251ce5..00000000 --- a/digital/io/src/playground.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef playground_h -#define playground_h -// playground.h -// io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{ -// -// Copyright (C) 2008 Dufour Jérémy -// -// Robot APB Team/Efrei 2004. -// Web: http://assos.efrei.fr/robot/ -// Email: robot AT efrei DOT fr -// -// 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 -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// }}} - -/** - * @file Some defines for the playground. - * For example, you can find the size of the table, the positions of the - * distributors, ... - * A few important remarks: - * - the (0,0) position is the bottom left position on the table (when you - * see it with the two start zone at the top of the scheme). - */ - -#include "defs.h" -#include "bot.h" - -/** - * The width of the table, in millimeters. - */ -#define PG_WIDTH 3000 - -/** - * The length of the table, in millimeters. - */ -#define PG_LENGTH 2100 - -/** - * The distance from table border for movements. - */ -#define PG_BORDER_DISTANCE 250 - -/** - * 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(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_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) } - -/** Initialiser for vect_t applying symmetry according to color. */ -#define PG_VECT(x, y) \ - (vect_t) { PG_X (x), PG_Y (y) } - -/** - * Start zone. - */ -#define PG_START_ZONE_LENGTH 500 -#define PG_START_ZONE_WIDTH 500 - -/** Size of the unclimbable slope zone (Eurobot 2010). */ -#define PG_SLOPE_WIDTH (500 + 519 + 500) -#define PG_SLOPE_LENGTH (500 + 22) - -/** Start of field zone. */ -#define PG_FIELD_Y_MAX 1128 - -#endif // playground_h diff --git a/digital/io/src/playground_2010.h b/digital/io/src/playground_2010.h new file mode 100644 index 00000000..11682c5e --- /dev/null +++ b/digital/io/src/playground_2010.h @@ -0,0 +1,46 @@ +#ifndef playground_2010_h +#define playground_2010_h +/* playground_2010.h */ +/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{ + * + * Copyright (C) 2008 Dufour Jérémy + * + * APBTeam: + * Web: http://apbteam.org/ + * Email: team AT apbteam DOT org + * + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * }}} */ +#include "playground.h" + +/** + * Eurobot 2010 specific defines. + */ + +/** + * Start zone. + */ +#define PG_START_ZONE_LENGTH 500 +#define PG_START_ZONE_WIDTH 500 + +/** Size of the unclimbable slope zone. */ +#define PG_SLOPE_WIDTH (500 + 519 + 500) +#define PG_SLOPE_LENGTH (500 + 22) + +/** Start of field zone. */ +#define PG_FIELD_Y_MAX 1128 + +#endif /* playground_2010_h */ diff --git a/digital/io/src/radar.c b/digital/io/src/radar.c index 1ba2a437..1ac982c7 100644 --- a/digital/io/src/radar.c +++ b/digital/io/src/radar.c @@ -25,7 +25,8 @@ #include "common.h" #include "radar.h" -#include "playground.h" +#include "playground_2010.h" +#include "bot.h" #include "usdist.h" #include "modules/math/geometry/geometry.h" diff --git a/digital/io/src/switch.avr.c b/digital/io/src/switch.avr.c index 659b597a..9907a86f 100644 --- a/digital/io/src/switch.avr.c +++ b/digital/io/src/switch.avr.c @@ -22,10 +22,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * }}} */ +#include "common.h" #include "switch.h" -#include "common.h" #include "modules/utils/utils.h" /* set_bit */ #include "io.h" /* PORT/PIN, bit_is_set */ diff --git a/digital/io/src/switch.h b/digital/io/src/switch.h index ac8d7dbc..9a804d1b 100644 --- a/digital/io/src/switch.h +++ b/digital/io/src/switch.h @@ -29,8 +29,7 @@ * @file Module to manage 'switchs'. For example, colors selector and jack. */ -#include "bot.h" -#include "common.h" +#include "defs.h" /** * Initialize the switch module. diff --git a/digital/io/src/top.c b/digital/io/src/top.c index bc6eb20e..e899d718 100644 --- a/digital/io/src/top.c +++ b/digital/io/src/top.c @@ -35,6 +35,7 @@ #include "move.h" #include "chrono.h" #include "playground.h" +#include "bot.h" #include "modules/utils/utils.h" -- cgit v1.2.3