From: Olivier Matz Date: Tue, 30 Mar 2010 20:02:37 +0000 (+0200) Subject: state machine X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=c5092ef0e45256f7e5ff2ceea8e1aa1cb33027db;p=aversive.git state machine --- diff --git a/projects/microb2010/cobboard/actuator.c b/projects/microb2010/cobboard/actuator.c index 3217270..4606540 100644 --- a/projects/microb2010/cobboard/actuator.c +++ b/projects/microb2010/cobboard/actuator.c @@ -47,7 +47,6 @@ #define COBROLLER_SPEED 800 -#define SERVO_DOOR_PWM ((void *)&gen.servo2) #define SERVO_DOOR_OPEN 250 #define SERVO_DOOR_CLOSED 470 diff --git a/projects/microb2010/cobboard/state.c b/projects/microb2010/cobboard/state.c index 4c9651e..8e8affc 100644 --- a/projects/microb2010/cobboard/state.c +++ b/projects/microb2010/cobboard/state.c @@ -118,11 +118,12 @@ static uint8_t state_cob_color(uint8_t side) int8_t state_set_mode(uint8_t mode) { state_mode = mode; - /* XXX synchrounous pack here */ - STMCH_DEBUG("%s(): l_deploy=%d l_harvest=%d " - "r_deploy=%d r_harvest=%d eject=%d", - __FUNCTION__, L_DEPLOY(mode), L_HARVEST(mode), - R_DEPLOY(mode), R_HARVEST(mode), EJECT(mode)); + +/* STMCH_DEBUG("%s(): l_deploy=%d l_harvest=%d " */ +/* "r_deploy=%d r_harvest=%d eject=%d", */ +/* __FUNCTION__, L_DEPLOY(mode), L_HARVEST(mode), */ +/* R_DEPLOY(mode), R_HARVEST(mode), EJECT(mode)); */ + return 0; } @@ -184,8 +185,10 @@ static void state_do_eject(void) { cob_count = 0; shovel_mid(); + servo_door_open(); time_wait_ms(2000); shovel_down(); + servo_door_close(); } /* main state machine */ @@ -199,15 +202,23 @@ void state_machine(void) state_init(); } - /* pack spickles */ - if (L_DEPLOY(state_mode)) + /* pack/deply spickles, enable/disable roller */ + if (L_DEPLOY(state_mode)) { spickle_deploy(I2C_LEFT_SIDE); - else + left_cobroller_on(); + } + else { spickle_pack(I2C_LEFT_SIDE); - if (R_DEPLOY(state_mode)) + left_cobroller_off(); + } + if (R_DEPLOY(state_mode)) { spickle_deploy(I2C_RIGHT_SIDE); - else + right_cobroller_on(); + } + else { spickle_pack(I2C_RIGHT_SIDE); + right_cobroller_off(); + } /* harvest */ if (L_DEPLOY(state_mode) && L_HARVEST(state_mode)) @@ -227,6 +238,7 @@ void state_init(void) { vt100_init(&local_vt100); shovel_down(); + servo_door_close(); spickle_pack(I2C_LEFT_SIDE); spickle_pack(I2C_RIGHT_SIDE); state_mode = 0; diff --git a/projects/microb2010/common/i2c_commands.h b/projects/microb2010/common/i2c_commands.h index fb4829f..d08e580 100644 --- a/projects/microb2010/common/i2c_commands.h +++ b/projects/microb2010/common/i2c_commands.h @@ -80,6 +80,21 @@ struct i2c_cmd_cobboard_set_mode { uint8_t mode; }; +#define I2C_CMD_BALLBOARD_SET_MODE 0x10 + +struct i2c_cmd_ballboard_set_mode { + struct i2c_cmd_hdr hdr; + +#define I2C_BALLBOARD_MODE_OFF 0x00 +#define I2C_BALLBOARD_MODE_HARVEST 0x01 +#define I2C_BALLBOARD_MODE_EJECT 0x02 +#define I2C_BALLBOARD_MODE_PREP_L_FORK 0x03 +#define I2C_BALLBOARD_MODE_TAKE_L_FORK 0x04 +#define I2C_BALLBOARD_MODE_PREP_R_FORK 0x05 +#define I2C_BALLBOARD_MODE_TAKE_R_FORK 0x06 + uint8_t mode; +}; + /****/ /* requests and their answers */ /****/