]> git.droids-corp.org - aversive.git/commitdiff
state machine
authorOlivier Matz <zer0@droids-corp.org>
Tue, 30 Mar 2010 20:02:37 +0000 (22:02 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Tue, 30 Mar 2010 20:02:37 +0000 (22:02 +0200)
projects/microb2010/cobboard/actuator.c
projects/microb2010/cobboard/state.c
projects/microb2010/common/i2c_commands.h

index 321727067a05465a5ace2168ab27a3095fd7fed1..46065409ea58f6bac22aa0e0b354e3425cd70b8b 100644 (file)
@@ -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
 
index 4c9651edc5230bf606ced0f01c4952dd71edf985..8e8affc60c131f03469b39e386744e73b2f307c0 100644 (file)
@@ -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;
index fb4829f929dbc07c641bd571871f9ec114cc45ac..d08e58023a7940fdf62fca7d1caf4cf05f888718 100644 (file)
@@ -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 */
 /****/