X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=projects%2Fmicrob2010%2Fmainboard%2Fstrat_db.c;h=c3608d640897d5e00cf5db2fa14ce55ac2244235;hb=28da5858ac871c626153f47566e968ecb05ff52b;hp=d2835fe76a6022a247bbb49a367bba92d564686a;hpb=17aadc4c8c3e60c2b5e6bbba91c8542849addbd7;p=aversive.git diff --git a/projects/microb2010/mainboard/strat_db.c b/projects/microb2010/mainboard/strat_db.c index d2835fe..c3608d6 100644 --- a/projects/microb2010/mainboard/strat_db.c +++ b/projects/microb2010/mainboard/strat_db.c @@ -60,6 +60,7 @@ #include "main.h" #include "strat.h" #include "strat_base.h" +#include "strat_avoid.h" #include "strat_corn.h" #include "strat_db.h" #include "strat_utils.h" @@ -87,7 +88,9 @@ static const uint8_t corn_sym[] = { 8, 9, 6, 7, 3, 4, 5, 0, 1, 2 }; -#if 0 /* XXX maybe useless */ +#ifdef HOST_VERSION +#define SIDE_CONF 0 +#define CENTER_CONF 0 /* the 10 possible configurations for corn on the side */ static const uint8_t corn_side_confs[9][2] = { { 1, 4 }, @@ -149,7 +152,10 @@ int8_t ijcoord_to_xycoord(uint8_t i, uint8_t j, int16_t *x, int16_t *y) if (i >= WAYPOINTS_NBX && j >= WAYPOINTS_NBY) return -1; *x = (OFFSET_CORN_X + i*STEP_CORN_X); - *y = COLOR_Y(OFFSET_CORN_Y + j*STEP_CORN_Y); + if (i&1) + *y = COLOR_Y(OFFSET_CORN_Y + j*STEP_CORN_Y + STEP_CORN_Y/2); + else + *y = COLOR_Y(OFFSET_CORN_Y + j*STEP_CORN_Y); return 0; } @@ -173,10 +179,14 @@ int8_t xycoord_to_ijcoord(int16_t *xp, int16_t *yp, uint8_t *ip, uint8_t *jp) if ((i & 1) == 1) { j = y / STEP_CORN_Y; } + else if ((i & 3) == 0) { + j = y / (STEP_CORN_Y*2); + j = j*2 + 1; + } else { - y += (STEP_CORN_Y/2); - y /= (STEP_CORN_Y*2); - j = (y * 2) + 1; + y += (STEP_CORN_Y); + j = y / (STEP_CORN_Y*2); + j = j*2; } if (ijcoord_to_xycoord(i, j, &x, &y) < 0) @@ -194,7 +204,6 @@ int8_t xycoord_to_ijcoord(int16_t *xp, int16_t *yp, uint8_t *ip, uint8_t *jp) return 0; } - /******** CORN */ /* return the index of a corn given its i,j coords. */ @@ -461,6 +470,9 @@ void strat_db_init(void) /* default type */ wp->type = WP_TYPE_WAYPOINT; + /* */ + wp->time_removed = -1; + /* mark dangerous points */ if (i == 0 || i == (WAYPOINTS_NBX-1)) wp->dangerous = 1; @@ -485,14 +497,27 @@ void strat_db_init(void) wp->type = WP_TYPE_CORN; wp->present = 1; wp->corn.idx = idx; +#ifdef HOST_VERSION + if (idx == corn_side_confs[SIDE_CONF][0] || + idx == corn_side_confs[SIDE_CONF][1] || + corn_get_sym_idx(idx) == corn_side_confs[SIDE_CONF][0] || + corn_get_sym_idx(idx) == corn_side_confs[SIDE_CONF][1] || + idx == corn_center_confs[CENTER_CONF][0] || + idx == corn_center_confs[CENTER_CONF][1] || + corn_get_sym_idx(idx) == corn_center_confs[CENTER_CONF][0] || + corn_get_sym_idx(idx) == corn_center_confs[CENTER_CONF][1]) + wp->corn.color = I2C_COB_BLACK; + else + wp->corn.color = I2C_COB_WHITE; +#else wp->corn.color = I2C_COB_UNKNOWN; +#endif continue; } /* tomato */ idx = ijcoord_to_tomato_idx(i, j); if (idx >= 0) { - printf("%d %d\n", i, j); wp->type = WP_TYPE_TOMATO; wp->present = 1; wp->tomato.idx = idx; @@ -530,4 +555,7 @@ void strat_db_dump(const char *caller) printf_P(PSTR("tomato%d: present=%d opp=%d\r\n"), i, wp->present, wp->opp_visited); } + + /* fill circuit infos */ + strat_avoid_init(); }