X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Fcobboard%2Fcommands_cobboard.c;h=9cfda19daf050f92f3fe3d2138203a313081104c;hp=669c4c8bc8589ac9753377c0ae9ebc6520e02dc2;hb=d23a4fdeed4e90d004d407942b230c188d012465;hpb=38196781643cba8e1d681aafb28cdadc51fe20ec diff --git a/projects/microb2010/cobboard/commands_cobboard.c b/projects/microb2010/cobboard/commands_cobboard.c index 669c4c8..9cfda19 100644 --- a/projects/microb2010/cobboard/commands_cobboard.c +++ b/projects/microb2010/cobboard/commands_cobboard.c @@ -244,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); @@ -268,7 +272,7 @@ static void cmd_state2_parsed(void *parsed_result, 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#harvest_nomove#deploy_nomove"; +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); @@ -710,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 */ @@ -721,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 = @@ -759,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 */