X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Fmainboard%2Fstrat.c;h=94b9b6f7c0416890e1ef18150379ef2d87c5f415;hp=423b0f7839dab668170ecac697357342ed876a13;hb=38196781643cba8e1d681aafb28cdadc51fe20ec;hpb=814b38b326d0b5bf54a26c5eaaa3d94e5c4a9753 diff --git a/projects/microb2010/mainboard/strat.c b/projects/microb2010/mainboard/strat.c index 423b0f7..94b9b6f 100644 --- a/projects/microb2010/mainboard/strat.c +++ b/projects/microb2010/mainboard/strat.c @@ -67,7 +67,7 @@ #define COL_DISP_MARGIN 400 /* stop 40 cm in front of dispenser */ #define COL_SCAN_PRE_MARGIN 250 -static uint8_t strat_running = 0; +static volatile uint8_t strat_running = 0; struct strat_conf strat_conf; /*************************************************************/ @@ -98,6 +98,16 @@ void strat_conf_dump(const char *caller) } +void strat_event_enable(void) +{ + strat_running = 1; +} + +void strat_event_disable(void) +{ + strat_running = 0; +} + /* call it just before launching the strat */ void strat_init(void) { @@ -173,11 +183,9 @@ void strat_event(void *dummy) /* detect cob on left side */ if (corn_is_near(&lidx, I2C_LEFT_SIDE)) { - if (lcob != I2C_COB_NONE) { + if (lcob != I2C_COB_NONE) corn_set_color(strat_db.corn_table[lidx], lcob); - DEBUG(E_USER_STRAT, "lcob %s %d", - lcob == I2C_COB_WHITE ? "white" : "black", lidx); - } + if (strat_db.corn_table[lidx]->corn.color == I2C_COB_WHITE) i2c_cobboard_autoharvest(I2C_LEFT_SIDE); else @@ -189,11 +197,9 @@ void strat_event(void *dummy) /* detect cob on right side */ if (corn_is_near(&ridx, I2C_RIGHT_SIDE)) { - if (rcob != I2C_COB_NONE) { + if (rcob != I2C_COB_NONE) corn_set_color(strat_db.corn_table[ridx], rcob); - DEBUG(E_USER_STRAT, "rcob %s %d", - rcob == I2C_COB_WHITE ? "white" : "black", ridx); - } + if (strat_db.corn_table[ridx]->corn.color == I2C_COB_WHITE) i2c_cobboard_autoharvest(I2C_RIGHT_SIDE); else @@ -216,12 +222,18 @@ static uint8_t strat_harvest(void) static uint8_t strat_eject(void) { + uint8_t err; + + //XXX return vals + strat_set_speed(600, SPEED_ANGLE_SLOW); + trajectory_goto_xy_abs(&mainboard.traj, 2625, COLOR_Y(1847)); - err = wait_traj_end(END_INTR|END_TRAJ); + err = wait_traj_end(TRAJ_FLAGS_NO_NEAR); + trajectory_a_abs(&mainboard.traj, COLOR_A(70)); + err = wait_traj_end(TRAJ_FLAGS_NO_NEAR); DEBUG(E_USER_STRAT, "%s():%d", __FUNCTION__, __LINE__); strat_hardstop(); - strat_set_speed(600, SPEED_ANGLE_FAST); /* ball ejection */ trajectory_a_abs(&mainboard.traj, COLOR_A(90)); @@ -263,6 +275,7 @@ static uint8_t strat_beginning(void) TRAJ_FLAGS_STD); strat_set_acc(ACC_DIST, ACC_ANGLE); + strat_set_speed(250, SPEED_ANGLE_SLOW); #if 1 l1: