2 * Copyright Droids Corporation (2009)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: commands_cobboard.c,v 1.6 2009-11-08 17:25:00 zer0 Exp $
20 * Olivier MATZ <zer0@droids-corp.org>
26 #include <aversive/pgmspace.h>
27 #include <aversive/wait.h>
28 #include <aversive/error.h>
33 #include <clock_time.h>
38 #include <control_system_manager.h>
39 #include <blocking_detection_manager.h>
43 #include <parse_string.h>
44 #include <parse_num.h>
46 #include "../common/i2c_commands.h"
51 #include "i2c_protocol.h"
56 struct cmd_event_result {
63 /* function called when cmd_event is parsed successfully */
64 static void cmd_event_parsed(void *parsed_result, __attribute__((unused)) void *data)
68 struct cmd_event_result * res = parsed_result;
70 if (!strcmp_P(res->arg1, PSTR("all"))) {
71 bit = DO_ENCODERS | DO_CS | DO_BD | DO_POWER;
72 if (!strcmp_P(res->arg2, PSTR("on")))
73 cobboard.flags |= bit;
74 else if (!strcmp_P(res->arg2, PSTR("off")))
75 cobboard.flags &= bit;
77 printf_P(PSTR("encoders is %s\r\n"),
78 (DO_ENCODERS & cobboard.flags) ? "on":"off");
79 printf_P(PSTR("cs is %s\r\n"),
80 (DO_CS & cobboard.flags) ? "on":"off");
81 printf_P(PSTR("bd is %s\r\n"),
82 (DO_BD & cobboard.flags) ? "on":"off");
83 printf_P(PSTR("power is %s\r\n"),
84 (DO_POWER & cobboard.flags) ? "on":"off");
89 if (!strcmp_P(res->arg1, PSTR("encoders")))
91 else if (!strcmp_P(res->arg1, PSTR("cs"))) {
94 else if (!strcmp_P(res->arg1, PSTR("bd")))
96 else if (!strcmp_P(res->arg1, PSTR("power")))
100 if (!strcmp_P(res->arg2, PSTR("on")))
101 cobboard.flags |= bit;
102 else if (!strcmp_P(res->arg2, PSTR("off"))) {
103 if (!strcmp_P(res->arg1, PSTR("cs"))) {
104 pwm_ng_set(LEFT_SPICKLE_PWM, 0);
105 pwm_ng_set(RIGHT_SPICKLE_PWM, 0);
106 pwm_ng_set(SHOVEL_PWM, 0);
108 cobboard.flags &= (~bit);
110 printf_P(PSTR("%s is %s\r\n"), res->arg1,
111 (bit & cobboard.flags) ? "on":"off");
114 prog_char str_event_arg0[] = "event";
115 parse_pgm_token_string_t cmd_event_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg0, str_event_arg0);
116 prog_char str_event_arg1[] = "all#encoders#cs#bd#power";
117 parse_pgm_token_string_t cmd_event_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg1, str_event_arg1);
118 prog_char str_event_arg2[] = "on#off#show";
119 parse_pgm_token_string_t cmd_event_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg2, str_event_arg2);
121 prog_char help_event[] = "Enable/disable events";
122 parse_pgm_inst_t cmd_event = {
123 .f = cmd_event_parsed, /* function to call */
124 .data = NULL, /* 2nd arg of func */
125 .help_str = help_event,
126 .tokens = { /* token list, NULL terminated */
127 (prog_void *)&cmd_event_arg0,
128 (prog_void *)&cmd_event_arg1,
129 (prog_void *)&cmd_event_arg2,
134 /**********************************************************/
137 /* this structure is filled when cmd_color is parsed successfully */
138 struct cmd_color_result {
140 fixed_string_t color;
143 /* function called when cmd_color is parsed successfully */
144 static void cmd_color_parsed(void *parsed_result, __attribute__((unused)) void *data)
146 struct cmd_color_result *res = (struct cmd_color_result *) parsed_result;
147 if (!strcmp_P(res->color, PSTR("yellow"))) {
148 cobboard.our_color = I2C_COLOR_YELLOW;
150 else if (!strcmp_P(res->color, PSTR("blue"))) {
151 cobboard.our_color = I2C_COLOR_BLUE;
153 printf_P(PSTR("Done\r\n"));
156 prog_char str_color_arg0[] = "color";
157 parse_pgm_token_string_t cmd_color_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_color_result, arg0, str_color_arg0);
158 prog_char str_color_color[] = "blue#yellow";
159 parse_pgm_token_string_t cmd_color_color = TOKEN_STRING_INITIALIZER(struct cmd_color_result, color, str_color_color);
161 prog_char help_color[] = "Set our color";
162 parse_pgm_inst_t cmd_color = {
163 .f = cmd_color_parsed, /* function to call */
164 .data = NULL, /* 2nd arg of func */
165 .help_str = help_color,
166 .tokens = { /* token list, NULL terminated */
167 (prog_void *)&cmd_color_arg0,
168 (prog_void *)&cmd_color_color,
173 /**********************************************************/
176 /* this structure is filled when cmd_state1 is parsed successfully */
177 struct cmd_state1_result {
182 /* function called when cmd_state1 is parsed successfully */
183 static void cmd_state1_parsed(void *parsed_result,
184 __attribute__((unused)) void *data)
186 struct cmd_state1_result *res = parsed_result;
188 if (!strcmp_P(res->arg1, PSTR("init")))
190 else if (!strcmp_P(res->arg1, PSTR("eject")))
191 state_set_mode(I2C_COBBOARD_MODE_EJECT);
196 prog_char str_state1_arg0[] = "cobboard";
197 parse_pgm_token_string_t cmd_state1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg0, str_state1_arg0);
198 prog_char str_state1_arg1[] = "init#eject";
199 parse_pgm_token_string_t cmd_state1_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg1, str_state1_arg1);
201 prog_char help_state1[] = "set cobboard mode";
202 parse_pgm_inst_t cmd_state1 = {
203 .f = cmd_state1_parsed, /* function to call */
204 .data = NULL, /* 2nd arg of func */
205 .help_str = help_state1,
206 .tokens = { /* token list, NULL terminated */
207 (prog_void *)&cmd_state1_arg0,
208 (prog_void *)&cmd_state1_arg1,
213 /**********************************************************/
216 /* this structure is filled when cmd_state2 is parsed successfully */
217 struct cmd_state2_result {
223 /* function called when cmd_state2 is parsed successfully */
224 static void cmd_state2_parsed(void *parsed_result,
225 __attribute__((unused)) void *data)
227 struct cmd_state2_result *res = parsed_result;
228 uint8_t side, mode = state_get_mode();
230 if (!strcmp_P(res->arg2, PSTR("left"))) {
231 side = I2C_LEFT_SIDE;
232 mode &= ~(I2C_COBBOARD_MODE_L_DEPLOY | I2C_COBBOARD_MODE_L_HARVEST);
235 side = I2C_RIGHT_SIDE;
236 mode &= ~(I2C_COBBOARD_MODE_R_DEPLOY | I2C_COBBOARD_MODE_R_HARVEST);
239 if (!strcmp_P(res->arg1, PSTR("pack"))) {
242 else if (!strcmp_P(res->arg1, PSTR("deploy"))) {
243 if (side == I2C_LEFT_SIDE)
244 mode |= I2C_COBBOARD_MODE_L_DEPLOY;
246 mode |= I2C_COBBOARD_MODE_R_DEPLOY;
248 else if (!strcmp_P(res->arg1, PSTR("harvest"))) {
249 if (side == I2C_LEFT_SIDE) {
250 mode |= I2C_COBBOARD_MODE_L_DEPLOY;
251 mode |= I2C_COBBOARD_MODE_L_HARVEST;
254 mode |= I2C_COBBOARD_MODE_R_DEPLOY;
255 mode |= I2C_COBBOARD_MODE_R_HARVEST;
259 state_set_mode(mode);
262 prog_char str_state2_arg0[] = "cobboard";
263 parse_pgm_token_string_t cmd_state2_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg0, str_state2_arg0);
264 prog_char str_state2_arg1[] = "harvest#deploy#pack";
265 parse_pgm_token_string_t cmd_state2_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg1, str_state2_arg1);
266 prog_char str_state2_arg2[] = "left#right";
267 parse_pgm_token_string_t cmd_state2_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg2, str_state2_arg2);
269 prog_char help_state2[] = "set cobboard mode";
270 parse_pgm_inst_t cmd_state2 = {
271 .f = cmd_state2_parsed, /* function to call */
272 .data = NULL, /* 2nd arg of func */
273 .help_str = help_state2,
274 .tokens = { /* token list, NULL terminated */
275 (prog_void *)&cmd_state2_arg0,
276 (prog_void *)&cmd_state2_arg1,
277 (prog_void *)&cmd_state2_arg2,
282 /**********************************************************/
285 /* this structure is filled when cmd_state3 is parsed successfully */
286 struct cmd_state3_result {
292 /* function called when cmd_state3 is parsed successfully */
293 static void cmd_state3_parsed(void *parsed_result,
294 __attribute__((unused)) void *data)
296 struct cmd_state3_result *res = parsed_result;
298 if (!strcmp_P(res->arg1, PSTR("xxx"))) {
299 /* xxx = res->arg2 */
301 else if (!strcmp_P(res->arg1, PSTR("yyy"))) {
306 prog_char str_state3_arg0[] = "cobboard";
307 parse_pgm_token_string_t cmd_state3_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state3_result, arg0, str_state3_arg0);
308 prog_char str_state3_arg1[] = "xxx";
309 parse_pgm_token_string_t cmd_state3_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state3_result, arg1, str_state3_arg1);
310 parse_pgm_token_num_t cmd_state3_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_state3_result, arg2, UINT8);
312 prog_char help_state3[] = "set cobboard mode";
313 parse_pgm_inst_t cmd_state3 = {
314 .f = cmd_state3_parsed, /* function to call */
315 .data = NULL, /* 2nd arg of func */
316 .help_str = help_state3,
317 .tokens = { /* token list, NULL terminated */
318 (prog_void *)&cmd_state3_arg0,
319 (prog_void *)&cmd_state3_arg1,
320 (prog_void *)&cmd_state3_arg2,
325 /**********************************************************/
328 /* this structure is filled when cmd_state_machine is parsed successfully */
329 struct cmd_state_machine_result {
333 /* function called when cmd_state_machine is parsed successfully */
334 static void cmd_state_machine_parsed(__attribute__((unused)) void *parsed_result,
335 __attribute__((unused)) void *data)
340 prog_char str_state_machine_arg0[] = "state_machine";
341 parse_pgm_token_string_t cmd_state_machine_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state_machine_result, arg0, str_state_machine_arg0);
343 prog_char help_state_machine[] = "launch state machine";
344 parse_pgm_inst_t cmd_state_machine = {
345 .f = cmd_state_machine_parsed, /* function to call */
346 .data = NULL, /* 2nd arg of func */
347 .help_str = help_state_machine,
348 .tokens = { /* token list, NULL terminated */
349 (prog_void *)&cmd_state_machine_arg0,
354 /**********************************************************/
357 /* this structure is filled when cmd_state_debug is parsed successfully */
358 struct cmd_state_debug_result {
363 /* function called when cmd_state_debug is parsed successfully */
364 static void cmd_state_debug_parsed(void *parsed_result,
365 __attribute__((unused)) void *data)
367 struct cmd_state_debug_result *res = parsed_result;
368 state_debug = res->on;
371 prog_char str_state_debug_arg0[] = "state_debug";
372 parse_pgm_token_string_t cmd_state_debug_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state_debug_result, arg0, str_state_debug_arg0);
373 parse_pgm_token_num_t cmd_state_debug_on = TOKEN_NUM_INITIALIZER(struct cmd_state_debug_result, on, UINT8);
375 prog_char help_state_debug[] = "Set debug for state machine";
376 parse_pgm_inst_t cmd_state_debug = {
377 .f = cmd_state_debug_parsed, /* function to call */
378 .data = NULL, /* 2nd arg of func */
379 .help_str = help_state_debug,
380 .tokens = { /* token list, NULL terminated */
381 (prog_void *)&cmd_state_debug_arg0,
382 (prog_void *)&cmd_state_debug_on,
387 /**********************************************************/
390 /* this structure is filled when cmd_servo_door is parsed successfully */
391 struct cmd_servo_door_result {
396 /* function called when cmd_servo_door is parsed successfully */
397 static void cmd_servo_door_parsed(void *parsed_result,
398 __attribute__((unused)) void *data)
400 struct cmd_servo_door_result *res = parsed_result;
401 if (!strcmp_P(res->arg1, PSTR("open")))
403 else if (!strcmp_P(res->arg1, PSTR("closed")))
407 prog_char str_servo_door_arg0[] = "door";
408 parse_pgm_token_string_t cmd_servo_door_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_servo_door_result, arg0, str_servo_door_arg0);
409 prog_char str_servo_door_arg1[] = "open#closed";
410 parse_pgm_token_string_t cmd_servo_door_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_servo_door_result, arg1, str_servo_door_arg1);
412 prog_char help_servo_door[] = "Servo door function";
413 parse_pgm_inst_t cmd_servo_door = {
414 .f = cmd_servo_door_parsed, /* function to call */
415 .data = NULL, /* 2nd arg of func */
416 .help_str = help_servo_door,
417 .tokens = { /* token list, NULL terminated */
418 (prog_void *)&cmd_servo_door_arg0,
419 (prog_void *)&cmd_servo_door_arg1,
424 /**********************************************************/
427 /* this structure is filled when cmd_cobroller is parsed successfully */
428 struct cmd_cobroller_result {
434 /* function called when cmd_cobroller is parsed successfully */
435 static void cmd_cobroller_parsed(void *parsed_result,
436 __attribute__((unused)) void *data)
438 struct cmd_cobroller_result *res = parsed_result;
440 if (!strcmp_P(res->arg1, PSTR("left"))) {
441 if (!strcmp_P(res->arg2, PSTR("on")))
443 else if (!strcmp_P(res->arg2, PSTR("off")))
444 left_cobroller_off();
446 else if (!strcmp_P(res->arg1, PSTR("right"))) {
447 if (!strcmp_P(res->arg2, PSTR("on")))
448 right_cobroller_on();
449 else if (!strcmp_P(res->arg2, PSTR("off")))
450 right_cobroller_off();
454 prog_char str_cobroller_arg0[] = "cobroller";
455 parse_pgm_token_string_t cmd_cobroller_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_cobroller_result, arg0, str_cobroller_arg0);
456 prog_char str_cobroller_arg1[] = "left#right";
457 parse_pgm_token_string_t cmd_cobroller_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_cobroller_result, arg1, str_cobroller_arg1);
458 prog_char str_cobroller_arg2[] = "on#off";
459 parse_pgm_token_string_t cmd_cobroller_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_cobroller_result, arg2, str_cobroller_arg2);
461 prog_char help_cobroller[] = "Servo door function";
462 parse_pgm_inst_t cmd_cobroller = {
463 .f = cmd_cobroller_parsed, /* function to call */
464 .data = NULL, /* 2nd arg of func */
465 .help_str = help_cobroller,
466 .tokens = { /* token list, NULL terminated */
467 (prog_void *)&cmd_cobroller_arg0,
468 (prog_void *)&cmd_cobroller_arg1,
469 (prog_void *)&cmd_cobroller_arg2,
474 /**********************************************************/
477 /* this structure is filled when cmd_shovel is parsed successfully */
478 struct cmd_shovel_result {
483 /* function called when cmd_shovel is parsed successfully */
484 static void cmd_shovel_parsed(void *parsed_result,
485 __attribute__((unused)) void *data)
487 struct cmd_shovel_result *res = parsed_result;
488 if (!strcmp_P(res->arg1, PSTR("down")))
490 else if (!strcmp_P(res->arg1, PSTR("up")))
492 else if (!strcmp_P(res->arg1, PSTR("mid")))
496 prog_char str_shovel_arg0[] = "shovel";
497 parse_pgm_token_string_t cmd_shovel_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_shovel_result, arg0, str_shovel_arg0);
498 prog_char str_shovel_arg1[] = "down#up#mid";
499 parse_pgm_token_string_t cmd_shovel_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_shovel_result, arg1, str_shovel_arg1);
501 prog_char help_shovel[] = "Servo shovel function";
502 parse_pgm_inst_t cmd_shovel = {
503 .f = cmd_shovel_parsed, /* function to call */
504 .data = NULL, /* 2nd arg of func */
505 .help_str = help_shovel,
506 .tokens = { /* token list, NULL terminated */
507 (prog_void *)&cmd_shovel_arg0,
508 (prog_void *)&cmd_shovel_arg1,
513 /**********************************************************/
516 /* this structure is filled when cmd_servo_carry is parsed successfully */
517 struct cmd_servo_carry_result {
522 /* function called when cmd_servo_carry is parsed successfully */
523 static void cmd_servo_carry_parsed(void *parsed_result,
524 __attribute__((unused)) void *data)
526 struct cmd_servo_carry_result *res = parsed_result;
527 if (!strcmp_P(res->arg1, PSTR("open")))
529 else if (!strcmp_P(res->arg1, PSTR("closed")))
533 prog_char str_servo_carry_arg0[] = "carry";
534 parse_pgm_token_string_t cmd_servo_carry_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_servo_carry_result, arg0, str_servo_carry_arg0);
535 prog_char str_servo_carry_arg1[] = "open#closed";
536 parse_pgm_token_string_t cmd_servo_carry_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_servo_carry_result, arg1, str_servo_carry_arg1);
538 prog_char help_servo_carry[] = "Servo carry function";
539 parse_pgm_inst_t cmd_servo_carry = {
540 .f = cmd_servo_carry_parsed, /* function to call */
541 .data = NULL, /* 2nd arg of func */
542 .help_str = help_servo_carry,
543 .tokens = { /* token list, NULL terminated */
544 (prog_void *)&cmd_servo_carry_arg0,
545 (prog_void *)&cmd_servo_carry_arg1,
550 /**********************************************************/
553 /* this structure is filled when cmd_spickle is parsed successfully */
554 struct cmd_spickle_result {
560 /* function called when cmd_spickle is parsed successfully */
561 static void cmd_spickle_parsed(void * parsed_result,
562 __attribute__((unused)) void *data)
564 struct cmd_spickle_result * res = parsed_result;
567 if (!strcmp_P(res->arg1, PSTR("left")))
568 side = I2C_LEFT_SIDE;
570 side = I2C_RIGHT_SIDE;
572 if (!strcmp_P(res->arg2, PSTR("deploy"))) {
573 spickle_deploy(side);
575 else if (!strcmp_P(res->arg2, PSTR("pack"))) {
578 printf_P(PSTR("done\r\n"));
581 prog_char str_spickle_arg0[] = "spickle";
582 parse_pgm_token_string_t cmd_spickle_arg0 =
583 TOKEN_STRING_INITIALIZER(struct cmd_spickle_result, arg0, str_spickle_arg0);
584 prog_char str_spickle_arg1[] = "left#right";
585 parse_pgm_token_string_t cmd_spickle_arg1 =
586 TOKEN_STRING_INITIALIZER(struct cmd_spickle_result, arg1, str_spickle_arg1);
587 prog_char str_spickle_arg2[] = "deploy#pack";
588 parse_pgm_token_string_t cmd_spickle_arg2 =
589 TOKEN_STRING_INITIALIZER(struct cmd_spickle_result, arg2, str_spickle_arg2);
591 prog_char help_spickle[] = "move spickle";
592 parse_pgm_inst_t cmd_spickle = {
593 .f = cmd_spickle_parsed, /* function to call */
594 .data = NULL, /* 2nd arg of func */
595 .help_str = help_spickle,
596 .tokens = { /* token list, NULL terminated */
597 (prog_void *)&cmd_spickle_arg0,
598 (prog_void *)&cmd_spickle_arg1,
599 (prog_void *)&cmd_spickle_arg2,
604 /**********************************************************/
605 /* Set Spickle Params */
607 /* this structure is filled when cmd_spickle_params is parsed successfully */
608 struct cmd_spickle_params_result {
616 /* function called when cmd_spickle_params is parsed successfully */
617 static void cmd_spickle_params_parsed(void *parsed_result,
618 __attribute__((unused)) void *data)
620 struct cmd_spickle_params_result * res = parsed_result;
623 if (!strcmp_P(res->arg1, PSTR("show"))) {
624 spickle_dump_params();
628 if (!strcmp_P(res->arg1, PSTR("left")))
629 side = I2C_LEFT_SIDE;
631 side = I2C_RIGHT_SIDE;
633 if (!strcmp_P(res->arg2, PSTR("pos")))
634 spickle_set_pos(side, res->arg3, res->arg4);
635 else if (!strcmp_P(res->arg2, PSTR("delay")))
636 spickle_set_delay(side, res->arg3, res->arg4);
639 prog_char str_spickle_params_arg0[] = "spickle_params";
640 parse_pgm_token_string_t cmd_spickle_params_arg0 =
641 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg0, str_spickle_params_arg0);
642 prog_char str_spickle_params_arg1[] = "left#right";
643 parse_pgm_token_string_t cmd_spickle_params_arg1 =
644 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg1, str_spickle_params_arg1);
645 prog_char str_spickle_params_arg2[] = "pos#delay";
646 parse_pgm_token_string_t cmd_spickle_params_arg2 =
647 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg2, str_spickle_params_arg2);
648 parse_pgm_token_num_t cmd_spickle_params_arg3 =
649 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params_result, arg3, INT32);
650 parse_pgm_token_num_t cmd_spickle_params_arg4 =
651 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params_result, arg4, INT32);
653 prog_char help_spickle_params[] = "Set spickle pos values";
654 parse_pgm_inst_t cmd_spickle_params = {
655 .f = cmd_spickle_params_parsed, /* function to call */
656 .data = NULL, /* 2nd arg of func */
657 .help_str = help_spickle_params,
658 .tokens = { /* token list, NULL terminated */
659 (prog_void *)&cmd_spickle_params_arg0,
660 (prog_void *)&cmd_spickle_params_arg1,
661 (prog_void *)&cmd_spickle_params_arg2,
662 (prog_void *)&cmd_spickle_params_arg3,
663 (prog_void *)&cmd_spickle_params_arg4,
668 prog_char str_spickle_params_arg1_show[] = "show";
669 parse_pgm_token_string_t cmd_spickle_params_arg1_show =
670 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg1, str_spickle_params_arg1_show);
672 prog_char help_spickle_params_show[] = "show spickle params";
673 parse_pgm_inst_t cmd_spickle_params_show = {
674 .f = cmd_spickle_params_parsed, /* function to call */
675 .data = NULL, /* 2nd arg of func */
676 .help_str = help_spickle_params_show,
677 .tokens = { /* token list, NULL terminated */
678 (prog_void *)&cmd_spickle_params_arg0,
679 (prog_void *)&cmd_spickle_params_arg1_show,
684 /**********************************************************/
685 /* Set Spickle Params */
687 /* this structure is filled when cmd_spickle_params2 is parsed successfully */
688 struct cmd_spickle_params2_result {
695 /* function called when cmd_spickle_params2 is parsed successfully */
696 static void cmd_spickle_params2_parsed(void *parsed_result,
697 __attribute__((unused)) void *data)
699 struct cmd_spickle_params2_result * res = parsed_result;
701 if (!strcmp_P(res->arg1, PSTR("coef"))) {
702 spickle_set_coefs(res->arg2, res->arg3);
706 spickle_dump_params();
709 prog_char str_spickle_params2_arg0[] = "spickle_params2";
710 parse_pgm_token_string_t cmd_spickle_params2_arg0 =
711 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params2_result, arg0, str_spickle_params2_arg0);
712 prog_char str_spickle_params2_arg1[] = "coef";
713 parse_pgm_token_string_t cmd_spickle_params2_arg1 =
714 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params2_result, arg1, str_spickle_params2_arg1);
715 parse_pgm_token_num_t cmd_spickle_params2_arg2 =
716 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params2_result, arg2, INT32);
717 parse_pgm_token_num_t cmd_spickle_params2_arg3 =
718 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params2_result, arg3, INT32);
720 prog_char help_spickle_params2[] = "Set spickle_params2 values";
721 parse_pgm_inst_t cmd_spickle_params2 = {
722 .f = cmd_spickle_params2_parsed, /* function to call */
723 .data = NULL, /* 2nd arg of func */
724 .help_str = help_spickle_params2,
725 .tokens = { /* token list, NULL terminated */
726 (prog_void *)&cmd_spickle_params2_arg0,
727 (prog_void *)&cmd_spickle_params2_arg1,
728 (prog_void *)&cmd_spickle_params2_arg2,
729 (prog_void *)&cmd_spickle_params2_arg3,
734 prog_char str_spickle_params2_arg1_show[] = "show";
735 parse_pgm_token_string_t cmd_spickle_params2_arg1_show =
736 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params2_result, arg1, str_spickle_params2_arg1_show);
738 prog_char help_spickle_params2_show[] = "show spickle params";
739 parse_pgm_inst_t cmd_spickle_params2_show = {
740 .f = cmd_spickle_params2_parsed, /* function to call */
741 .data = NULL, /* 2nd arg of func */
742 .help_str = help_spickle_params2_show,
743 .tokens = { /* token list, NULL terminated */
744 (prog_void *)&cmd_spickle_params2_arg0,
745 (prog_void *)&cmd_spickle_params2_arg1_show,
750 /**********************************************************/
753 /* this structure is filled when cmd_test is parsed successfully */
754 struct cmd_test_result {
758 /* function called when cmd_test is parsed successfully */
759 static void cmd_test_parsed(__attribute__((unused)) void *parsed_result,
760 __attribute__((unused)) void *data)
764 prog_char str_test_arg0[] = "test";
765 parse_pgm_token_string_t cmd_test_arg0 =
766 TOKEN_STRING_INITIALIZER(struct cmd_test_result, arg0, str_test_arg0);
768 prog_char help_test[] = "Test function";
769 parse_pgm_inst_t cmd_test = {
770 .f = cmd_test_parsed, /* function to call */
771 .data = NULL, /* 2nd arg of func */
772 .help_str = help_test,
773 .tokens = { /* token list, NULL terminated */
774 (prog_void *)&cmd_test_arg0,