command circle set coef
[aversive.git] / projects / microb2009 / mainboard / commands_traj.c
index 82477a3..170dce8 100644 (file)
@@ -126,6 +126,65 @@ parse_pgm_inst_t cmd_traj_speed_show = {
 };
 
 /**********************************************************/
+/* circle coef configuration */
+
+/* this structure is filled when cmd_circle_coef is parsed successfully */
+struct cmd_circle_coef_result {
+       fixed_string_t arg0;
+       fixed_string_t arg1;
+       float circle_coef;
+};
+
+
+/* function called when cmd_circle_coef is parsed successfully */
+static void cmd_circle_coef_parsed(void *parsed_result, void *data)
+{
+       struct cmd_circle_coef_result *res = parsed_result;
+
+       if (!strcmp_P(res->arg1, PSTR("set"))) {
+               trajectory_set_circle_coef(&mainboard.traj, res->circle_coef);
+       }
+
+       printf_P(PSTR("circle_coef set %2.2f\r\n"), mainboard.traj.circle_coef);
+}
+
+prog_char str_circle_coef_arg0[] = "circle_coef";
+parse_pgm_token_string_t cmd_circle_coef_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_circle_coef_result, arg0, str_circle_coef_arg0);
+prog_char str_circle_coef_arg1[] = "set";
+parse_pgm_token_string_t cmd_circle_coef_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_circle_coef_result, arg1, str_circle_coef_arg1);
+parse_pgm_token_num_t cmd_circle_coef_val = TOKEN_NUM_INITIALIZER(struct cmd_circle_coef_result, circle_coef, FLOAT);
+
+prog_char help_circle_coef[] = "Set circle coef";
+parse_pgm_inst_t cmd_circle_coef = {
+       .f = cmd_circle_coef_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_circle_coef,
+       .tokens = {        /* token list, NULL terminated */
+               (prog_void *)&cmd_circle_coef_arg0,
+               (prog_void *)&cmd_circle_coef_arg1,
+               (prog_void *)&cmd_circle_coef_val,
+               NULL,
+       },
+};
+
+/* show */
+
+prog_char str_circle_coef_show_arg[] = "show";
+parse_pgm_token_string_t cmd_circle_coef_show_arg = TOKEN_STRING_INITIALIZER(struct cmd_circle_coef_result, arg1, str_circle_coef_show_arg);
+
+prog_char help_circle_coef_show[] = "Show circle coef";
+parse_pgm_inst_t cmd_circle_coef_show = {
+       .f = cmd_circle_coef_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_circle_coef_show,
+       .tokens = {        /* token list, NULL terminated */
+               (prog_void *)&cmd_circle_coef_arg0, 
+               (prog_void *)&cmd_circle_coef_show_arg,
+               NULL,
+       },
+};
+
+/**********************************************************/
 /* trajectory window configuration */
 
 /* this structure is filled when cmd_trajectory is parsed successfully */