*/
static volatile uint8_t ax12_state = AX12_STATE_READ;
-extern volatile struct cirbuf g_tx_fifo[]; /* uart fifo */
static volatile uint8_t ax12_nsent = 0;
/* Called by ax12 module to send a character on serial line. Count the
*/
static volatile uint8_t ax12_state = AX12_STATE_READ;
-extern volatile struct cirbuf g_tx_fifo[]; /* uart fifo */
static volatile uint8_t ax12_nsent = 0;
/* Called by ax12 module to send a character on serial line. Count the
state_init();
else if (!strcmp_P(res->arg1, PSTR("eject")))
state_set_mode(I2C_COBBOARD_MODE_EJECT);
+ else if (!strcmp_P(res->arg1, PSTR("kickstand")))
+ state_set_mode(I2C_COBBOARD_MODE_KICKSTAND);
else if (!strcmp_P(res->arg1, PSTR("ignore_i2c")))
state_set_i2c_ignore(1);
else if (!strcmp_P(res->arg1, PSTR("care_i2c")))
prog_char str_state1_arg0[] = "cobboard";
parse_pgm_token_string_t cmd_state1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg0, str_state1_arg0);
-prog_char str_state1_arg1[] = "init#eject#ignore_i2c#care_i2c";
+prog_char str_state1_arg1[] = "init#eject#ignore_i2c#care_i2c#kickstand";
parse_pgm_token_string_t cmd_state1_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg1, str_state1_arg1);
prog_char help_state1[] = "set cobboard mode";
cs_set_consign(&cobboard.shovel.cs, SHOVEL_UP);
}
+void shovel_kickstand(void)
+{
+ quadramp_set_1st_order_vars(&cobboard.shovel.qr, 200, 200);
+ quadramp_set_2nd_order_vars(&cobboard.shovel.qr, 10, 10);
+ cs_set_consign(&cobboard.shovel.cs, SHOVEL_UP);
+}
+
uint8_t shovel_is_up(void)
{
return shovel_is_at_pos(SHOVEL_UP);
void shovel_down(void);
void shovel_mid(void);
void shovel_up(void);
+void shovel_kickstand(void);
uint8_t shovel_is_up(void);
uint8_t shovel_is_down(void);
#define INIT(mode) ((mode) == I2C_COBBOARD_MODE_INIT)
#define HARVEST(mode) ((mode) == I2C_COBBOARD_MODE_HARVEST)
#define EJECT(mode) ((mode) == I2C_COBBOARD_MODE_EJECT)
+#define KICKSTAND(mode) ((mode) == I2C_COBBOARD_MODE_KICKSTAND)
uint8_t state_debug = 0;
/* pack/deploy spickles depending on mode */
static void spickle_prepare(uint8_t side)
{
+ /* pack spickle if we are not in harvest mode */
+ if (!HARVEST(state_mode))
+ spickle_pack(side);
+
/* we do nothing in mode no out */
if (state_spicklemode_nomove(side))
return;
state_mode = I2C_COBBOARD_MODE_HARVEST;
}
- /* pack/deply spickles, enable/disable roller */
- cobroller_off(I2C_LEFT_SIDE);
- cobroller_off(I2C_RIGHT_SIDE);
- spickle_prepare(I2C_LEFT_SIDE);
- spickle_prepare(I2C_RIGHT_SIDE);
-
- /* harvest */
- if (cob_count < 5) {
- if (state_spicklemode_deployed(I2C_LEFT_SIDE) &&
- state_spicklemode_autoharvest(I2C_LEFT_SIDE))
- state_do_harvest(I2C_LEFT_SIDE);
- if (state_spicklemode_deployed(I2C_RIGHT_SIDE) &&
- state_spicklemode_autoharvest(I2C_RIGHT_SIDE))
- state_do_harvest(I2C_RIGHT_SIDE);
+ if (HARVEST(state_mode)) {
+ /* init for each loop */
+ shovel_down();
+ servo_carry_close();
+ servo_door_close();
+ shovel_current_limit_enable(0);
+
+ /* pack/deply spickles, enable/disable roller */
+ cobroller_off(I2C_LEFT_SIDE);
+ cobroller_off(I2C_RIGHT_SIDE);
+ spickle_prepare(I2C_LEFT_SIDE);
+ spickle_prepare(I2C_RIGHT_SIDE);
+
+ /* harvest if not many cobs */
+ if (cob_count < 5) {
+ if (state_spicklemode_deployed(I2C_LEFT_SIDE) &&
+ state_spicklemode_autoharvest(I2C_LEFT_SIDE))
+ state_do_harvest(I2C_LEFT_SIDE);
+ if (state_spicklemode_deployed(I2C_RIGHT_SIDE) &&
+ state_spicklemode_autoharvest(I2C_RIGHT_SIDE))
+ state_do_harvest(I2C_RIGHT_SIDE);
+ }
+ }
+
+ /* help to climb the hill */
+ if (KICKSTAND(state_mode)) {
+ servo_carry_open();
+ servo_door_open();
+ shovel_current_limit_enable(1);
+ shovel_kickstand();
}
/* eject */
/*
- * Copyright Droids Corporation (2007)
- *
+ * Copyright Droids Corporation (2010)
+ *
* 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
#define I2C_COBBOARD_MODE_HARVEST 0x01 /* harvest mode */
#define I2C_COBBOARD_MODE_EJECT 0x02 /* eject cobs */
#define I2C_COBBOARD_MODE_INIT 0x03 /* init state machine */
+#define I2C_COBBOARD_MODE_KICKSTAND 0x04 /* help to climb the hill */
uint8_t mode;
};
#define I2C_COBBOARD_STATUS_LBUSY 0x02
#define I2C_COBBOARD_STATUS_RBUSY 0x03
#define I2C_COBBOARD_STATUS_EJECT 0x04
+#define I2C_COBBOARD_STATUS_KICKSTAND 0x05
uint8_t status;
uint8_t cob_count;
i2c_cobboard_set_mode(I2C_COBBOARD_MODE_INIT);
else if (!strcmp_P(res->arg1, PSTR("eject")))
i2c_cobboard_set_mode(I2C_COBBOARD_MODE_EJECT);
+ else if (!strcmp_P(res->arg1, PSTR("kickstand")))
+ i2c_cobboard_set_mode(I2C_COBBOARD_MODE_KICKSTAND);
}
prog_char str_cobboard_setmode1_arg0[] = "cobboard";
parse_pgm_token_string_t cmd_cobboard_setmode1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_setmode1_result, arg0, str_cobboard_setmode1_arg0);
-prog_char str_cobboard_setmode1_arg1[] = "init#eject";
+prog_char str_cobboard_setmode1_arg1[] = "init#eject#kickstand";
parse_pgm_token_string_t cmd_cobboard_setmode1_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_setmode1_result, arg1, str_cobboard_setmode1_arg1);
prog_char help_cobboard_setmode1[] = "set cobboard mode (mode)";