X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Fcobboard%2Fcommands_cobboard.c;h=9cfda19daf050f92f3fe3d2138203a313081104c;hp=dbbdd791a85d624c56dcf8b8990e75e7eeca9a12;hb=d23a4fdeed4e90d004d407942b230c188d012465;hpb=19cd41f7920628a962928580cd1618a1ee5750aa diff --git a/projects/microb2010/cobboard/commands_cobboard.c b/projects/microb2010/cobboard/commands_cobboard.c index dbbdd79..9cfda19 100644 --- a/projects/microb2010/cobboard/commands_cobboard.c +++ b/projects/microb2010/cobboard/commands_cobboard.c @@ -193,13 +193,17 @@ static void cmd_state1_parsed(void *parsed_result, state_init(); else if (!strcmp_P(res->arg1, PSTR("eject"))) state_set_mode(I2C_COBBOARD_MODE_EJECT); + else if (!strcmp_P(res->arg1, PSTR("ignore_i2c"))) + state_set_i2c_ignore(1); + else if (!strcmp_P(res->arg1, PSTR("care_i2c"))) + state_set_i2c_ignore(0); /* other commands */ } 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"; +prog_char str_state1_arg1[] = "init#eject#ignore_i2c#care_i2c"; 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"; @@ -240,6 +244,10 @@ static void cmd_state2_parsed(void *parsed_result, state_set_mode(I2C_COBBOARD_MODE_HARVEST); state_set_spickle(side, 0); } + else if (!strcmp_P(res->arg1, PSTR("weak_pack"))) { + state_set_mode(I2C_COBBOARD_MODE_HARVEST); + state_set_spickle(side, I2C_COBBOARD_SPK_WEAK); + } else if (!strcmp_P(res->arg1, PSTR("deploy"))) { state_set_mode(I2C_COBBOARD_MODE_HARVEST); state_set_spickle(side, I2C_COBBOARD_SPK_DEPLOY); @@ -249,11 +257,22 @@ static void cmd_state2_parsed(void *parsed_result, state_set_spickle(side, I2C_COBBOARD_SPK_DEPLOY | I2C_COBBOARD_SPK_AUTOHARVEST); } + else if (!strcmp_P(res->arg1, PSTR("deploy_nomove"))) { + state_set_mode(I2C_COBBOARD_MODE_HARVEST); + state_set_spickle(side, I2C_COBBOARD_SPK_DEPLOY | + I2C_COBBOARD_SPK_NO_MOVE); + } + else if (!strcmp_P(res->arg1, PSTR("harvest_nomove"))) { + state_set_mode(I2C_COBBOARD_MODE_HARVEST); + state_set_spickle(side, I2C_COBBOARD_SPK_DEPLOY | + I2C_COBBOARD_SPK_AUTOHARVEST | + I2C_COBBOARD_SPK_NO_MOVE); + } } prog_char str_state2_arg0[] = "cobboard"; parse_pgm_token_string_t cmd_state2_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg0, str_state2_arg0); -prog_char str_state2_arg1[] = "harvest#deploy#pack"; +prog_char str_state2_arg1[] = "harvest#deploy#pack#weak_pack#harvest_nomove#deploy_nomove"; parse_pgm_token_string_t cmd_state2_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg1, str_state2_arg1); prog_char str_state2_arg2[] = "left#right"; parse_pgm_token_string_t cmd_state2_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg2, str_state2_arg2); @@ -695,8 +714,11 @@ static void cmd_spickle_params2_parsed(void *parsed_result, { struct cmd_spickle_params2_result * res = parsed_result; - if (!strcmp_P(res->arg1, PSTR("coef"))) { - spickle_set_coefs(res->arg2, res->arg3); + if (!strcmp_P(res->arg1, PSTR("wcoef"))) { + spickle_set_wcoefs(res->arg2, res->arg3); + } + else if (!strcmp_P(res->arg1, PSTR("scoef"))) { + spickle_set_scoefs(res->arg2, res->arg3); } /* else show */ @@ -706,7 +728,7 @@ static void cmd_spickle_params2_parsed(void *parsed_result, prog_char str_spickle_params2_arg0[] = "spickle_params2"; parse_pgm_token_string_t cmd_spickle_params2_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_spickle_params2_result, arg0, str_spickle_params2_arg0); -prog_char str_spickle_params2_arg1[] = "coef"; +prog_char str_spickle_params2_arg1[] = "wcoef#scoef"; parse_pgm_token_string_t cmd_spickle_params2_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_spickle_params2_result, arg1, str_spickle_params2_arg1); parse_pgm_token_num_t cmd_spickle_params2_arg2 = @@ -744,6 +766,79 @@ parse_pgm_inst_t cmd_spickle_params2_show = { }, }; +/**********************************************************/ +/* Set Shovel Params */ + +/* this structure is filled when cmd_shovel_current is parsed successfully */ +struct cmd_shovel_current_result { + fixed_string_t arg0; + fixed_string_t arg1; + int32_t arg2; + int32_t arg3; +}; + +/* function called when cmd_shovel_current is parsed successfully */ +static void cmd_shovel_current_parsed(void *parsed_result, + __attribute__((unused)) void *data) +{ + struct cmd_shovel_current_result * res = parsed_result; + uint8_t enable; + int32_t k1, k2; + + if (!strcmp_P(res->arg1, PSTR("set"))) + shovel_set_current_limit_coefs(res->arg2, res->arg3); + else if (!strcmp_P(res->arg1, PSTR("on"))) + shovel_current_limit_enable(1); + else if (!strcmp_P(res->arg1, PSTR("off"))) + shovel_current_limit_enable(0); + + /* else show */ + enable = shovel_get_current_limit_coefs(&k1, &k2); + printf_P(PSTR("enabled=%d k1=%"PRIi32" k2=%"PRIi32"\r\n"), + enable, k1, k2); +} + +prog_char str_shovel_current_arg0[] = "shovel_current"; +parse_pgm_token_string_t cmd_shovel_current_arg0 = + TOKEN_STRING_INITIALIZER(struct cmd_shovel_current_result, arg0, str_shovel_current_arg0); +prog_char str_shovel_current_arg1[] = "set"; +parse_pgm_token_string_t cmd_shovel_current_arg1 = + TOKEN_STRING_INITIALIZER(struct cmd_shovel_current_result, arg1, str_shovel_current_arg1); +parse_pgm_token_num_t cmd_shovel_current_arg2 = + TOKEN_NUM_INITIALIZER(struct cmd_shovel_current_result, arg2, INT32); +parse_pgm_token_num_t cmd_shovel_current_arg3 = + TOKEN_NUM_INITIALIZER(struct cmd_shovel_current_result, arg3, INT32); + +prog_char help_shovel_current[] = "Set shovel_current values"; +parse_pgm_inst_t cmd_shovel_current = { + .f = cmd_shovel_current_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = help_shovel_current, + .tokens = { /* token list, NULL terminated */ + (prog_void *)&cmd_shovel_current_arg0, + (prog_void *)&cmd_shovel_current_arg1, + (prog_void *)&cmd_shovel_current_arg2, + (prog_void *)&cmd_shovel_current_arg3, + NULL, + }, +}; + +prog_char str_shovel_current_arg1_show[] = "show#on#off"; +parse_pgm_token_string_t cmd_shovel_current_arg1_show = + TOKEN_STRING_INITIALIZER(struct cmd_shovel_current_result, arg1, str_shovel_current_arg1_show); + +prog_char help_shovel_current_show[] = "show shovel params"; +parse_pgm_inst_t cmd_shovel_current_show = { + .f = cmd_shovel_current_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = help_shovel_current_show, + .tokens = { /* token list, NULL terminated */ + (prog_void *)&cmd_shovel_current_arg0, + (prog_void *)&cmd_shovel_current_arg1_show, + NULL, + }, +}; + /**********************************************************/ /* Test */