command circle set coef
[aversive.git] / projects / microb2009 / mainboard / commands_traj.c
index 715f167..170dce8 100644 (file)
@@ -125,6 +125,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 */
 
@@ -489,6 +548,7 @@ struct cmd_goto_result {
        int32_t arg2;
        int32_t arg3;
        int32_t arg4;
+       int32_t arg5;
 };
 
 /* function called when cmd_goto is parsed successfully */
@@ -539,6 +599,11 @@ static void cmd_goto_parsed(void * parsed_result, void * data)
        else if (!strcmp_P(res->arg1, PSTR("da_rel"))) {
                trajectory_d_a_rel(&mainboard.traj, res->arg2, res->arg3);
        }
+       else if (!strcmp_P(res->arg1, PSTR("circle_rel"))) {
+               trajectory_circle_rel(&mainboard.traj, res->arg2, res->arg3,
+                                     res->arg4, res->arg5, 0);
+               return; /* XXX */
+       }
        t1 = time_get_us2();
        while ((err = test_traj_end(0xFF)) == 0) {
                t2 = time_get_us2();
@@ -592,6 +657,28 @@ parse_pgm_inst_t cmd_goto2 = {
        },
 };
 
+prog_char str_goto_arg1_c[] = "circle_rel";
+parse_pgm_token_string_t cmd_goto_arg1_c = TOKEN_STRING_INITIALIZER(struct cmd_goto_result, arg1, str_goto_arg1_c);
+parse_pgm_token_num_t cmd_goto_arg4 = TOKEN_NUM_INITIALIZER(struct cmd_goto_result, arg4, INT32);
+parse_pgm_token_num_t cmd_goto_arg5 = TOKEN_NUM_INITIALIZER(struct cmd_goto_result, arg5, INT32);
+
+/* 4 params */
+prog_char help_goto4[] = "Do a circle: (x,y, radius, angle)";
+parse_pgm_inst_t cmd_goto4 = {
+       .f = cmd_goto_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_goto4,
+       .tokens = {        /* token list, NULL terminated */
+               (prog_void *)&cmd_goto_arg0,
+               (prog_void *)&cmd_goto_arg1_c,
+               (prog_void *)&cmd_goto_arg2,
+               (prog_void *)&cmd_goto_arg3,
+               (prog_void *)&cmd_goto_arg4,
+               (prog_void *)&cmd_goto_arg5,
+               NULL,
+       },
+};
+
 /**********************************************************/
 /* Position tests */