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 extern uint16_t state_debug;
58 struct cmd_event_result {
65 /* function called when cmd_event is parsed successfully */
66 static void cmd_event_parsed(void *parsed_result, __attribute__((unused)) void *data)
70 struct cmd_event_result * res = parsed_result;
72 if (!strcmp_P(res->arg1, PSTR("all"))) {
73 bit = DO_ENCODERS | DO_CS | DO_BD | DO_POWER;
74 if (!strcmp_P(res->arg2, PSTR("on")))
75 cobboard.flags |= bit;
76 else if (!strcmp_P(res->arg2, PSTR("off")))
77 cobboard.flags &= bit;
79 printf_P(PSTR("encoders is %s\r\n"),
80 (DO_ENCODERS & cobboard.flags) ? "on":"off");
81 printf_P(PSTR("cs is %s\r\n"),
82 (DO_CS & cobboard.flags) ? "on":"off");
83 printf_P(PSTR("bd is %s\r\n"),
84 (DO_BD & cobboard.flags) ? "on":"off");
85 printf_P(PSTR("power is %s\r\n"),
86 (DO_POWER & cobboard.flags) ? "on":"off");
91 if (!strcmp_P(res->arg1, PSTR("encoders")))
93 else if (!strcmp_P(res->arg1, PSTR("cs"))) {
96 else if (!strcmp_P(res->arg1, PSTR("bd")))
98 else if (!strcmp_P(res->arg1, PSTR("power")))
102 if (!strcmp_P(res->arg2, PSTR("on")))
103 cobboard.flags |= bit;
104 else if (!strcmp_P(res->arg2, PSTR("off"))) {
105 if (!strcmp_P(res->arg1, PSTR("cs"))) {
106 pwm_ng_set(LEFT_SPICKLE_PWM, 0);
107 pwm_ng_set(RIGHT_SPICKLE_PWM, 0);
108 pwm_ng_set(SHOVEL_PWM, 0);
110 cobboard.flags &= (~bit);
112 printf_P(PSTR("%s is %s\r\n"), res->arg1,
113 (bit & cobboard.flags) ? "on":"off");
116 prog_char str_event_arg0[] = "event";
117 parse_pgm_token_string_t cmd_event_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg0, str_event_arg0);
118 prog_char str_event_arg1[] = "all#encoders#cs#bd#power";
119 parse_pgm_token_string_t cmd_event_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg1, str_event_arg1);
120 prog_char str_event_arg2[] = "on#off#show";
121 parse_pgm_token_string_t cmd_event_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg2, str_event_arg2);
123 prog_char help_event[] = "Enable/disable events";
124 parse_pgm_inst_t cmd_event = {
125 .f = cmd_event_parsed, /* function to call */
126 .data = NULL, /* 2nd arg of func */
127 .help_str = help_event,
128 .tokens = { /* token list, NULL terminated */
129 (prog_void *)&cmd_event_arg0,
130 (prog_void *)&cmd_event_arg1,
131 (prog_void *)&cmd_event_arg2,
136 /**********************************************************/
139 /* this structure is filled when cmd_color is parsed successfully */
140 struct cmd_color_result {
142 fixed_string_t color;
145 /* function called when cmd_color is parsed successfully */
146 static void cmd_color_parsed(void *parsed_result, __attribute__((unused)) void *data)
148 struct cmd_color_result *res = (struct cmd_color_result *) parsed_result;
149 if (!strcmp_P(res->color, PSTR("red"))) {
150 cobboard.our_color = I2C_COLOR_RED;
152 else if (!strcmp_P(res->color, PSTR("green"))) {
153 cobboard.our_color = I2C_COLOR_GREEN;
155 printf_P(PSTR("Done\r\n"));
158 prog_char str_color_arg0[] = "color";
159 parse_pgm_token_string_t cmd_color_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_color_result, arg0, str_color_arg0);
160 prog_char str_color_color[] = "green#red";
161 parse_pgm_token_string_t cmd_color_color = TOKEN_STRING_INITIALIZER(struct cmd_color_result, color, str_color_color);
163 prog_char help_color[] = "Set our color";
164 parse_pgm_inst_t cmd_color = {
165 .f = cmd_color_parsed, /* function to call */
166 .data = NULL, /* 2nd arg of func */
167 .help_str = help_color,
168 .tokens = { /* token list, NULL terminated */
169 (prog_void *)&cmd_color_arg0,
170 (prog_void *)&cmd_color_color,
175 /**********************************************************/
178 /* this structure is filled when cmd_state1 is parsed successfully */
179 struct cmd_state1_result {
184 /* function called when cmd_state1 is parsed successfully */
185 static void cmd_state1_parsed(void *parsed_result,
186 __attribute__((unused)) void *data)
188 struct cmd_state1_result *res = parsed_result;
190 if (!strcmp_P(res->arg1, PSTR("init")))
192 else if (!strcmp_P(res->arg1, PSTR("eject")))
193 state_set_mode(I2C_COBBOARD_MODE_EJECT);
198 prog_char str_state1_arg0[] = "cobboard";
199 parse_pgm_token_string_t cmd_state1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg0, str_state1_arg0);
200 prog_char str_state1_arg1[] = "init#eject";
201 parse_pgm_token_string_t cmd_state1_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg1, str_state1_arg1);
203 prog_char help_state1[] = "set cobboard mode";
204 parse_pgm_inst_t cmd_state1 = {
205 .f = cmd_state1_parsed, /* function to call */
206 .data = NULL, /* 2nd arg of func */
207 .help_str = help_state1,
208 .tokens = { /* token list, NULL terminated */
209 (prog_void *)&cmd_state1_arg0,
210 (prog_void *)&cmd_state1_arg1,
215 /**********************************************************/
218 /* this structure is filled when cmd_state2 is parsed successfully */
219 struct cmd_state2_result {
225 /* function called when cmd_state2 is parsed successfully */
226 static void cmd_state2_parsed(void *parsed_result,
227 __attribute__((unused)) void *data)
229 struct cmd_state2_result *res = parsed_result;
230 uint8_t side, mode = state_get_mode();
232 if (!strcmp_P(res->arg2, PSTR("left"))) {
233 side = I2C_LEFT_SIDE;
234 mode &= ~(I2C_COBBOARD_MODE_L_DEPLOY | I2C_COBBOARD_MODE_L_HARVEST);
237 side = I2C_RIGHT_SIDE;
238 mode &= ~(I2C_COBBOARD_MODE_R_DEPLOY | I2C_COBBOARD_MODE_R_HARVEST);
241 if (!strcmp_P(res->arg1, PSTR("pack"))) {
244 else if (!strcmp_P(res->arg1, PSTR("deploy"))) {
245 if (side == I2C_LEFT_SIDE)
246 mode |= I2C_COBBOARD_MODE_L_DEPLOY;
248 mode |= I2C_COBBOARD_MODE_R_DEPLOY;
250 else if (!strcmp_P(res->arg1, PSTR("harvest"))) {
251 if (side == I2C_LEFT_SIDE) {
252 mode |= I2C_COBBOARD_MODE_L_DEPLOY;
253 mode |= I2C_COBBOARD_MODE_L_HARVEST;
256 mode |= I2C_COBBOARD_MODE_R_DEPLOY;
257 mode |= I2C_COBBOARD_MODE_R_HARVEST;
261 state_set_mode(mode);
264 prog_char str_state2_arg0[] = "cobboard";
265 parse_pgm_token_string_t cmd_state2_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg0, str_state2_arg0);
266 prog_char str_state2_arg1[] = "harvest#deploy#pack";
267 parse_pgm_token_string_t cmd_state2_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg1, str_state2_arg1);
268 prog_char str_state2_arg2[] = "left#right";
269 parse_pgm_token_string_t cmd_state2_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg2, str_state2_arg2);
271 prog_char help_state2[] = "set cobboard mode";
272 parse_pgm_inst_t cmd_state2 = {
273 .f = cmd_state2_parsed, /* function to call */
274 .data = NULL, /* 2nd arg of func */
275 .help_str = help_state2,
276 .tokens = { /* token list, NULL terminated */
277 (prog_void *)&cmd_state2_arg0,
278 (prog_void *)&cmd_state2_arg1,
279 (prog_void *)&cmd_state2_arg2,
284 /**********************************************************/
287 /* this structure is filled when cmd_state3 is parsed successfully */
288 struct cmd_state3_result {
294 /* function called when cmd_state3 is parsed successfully */
295 static void cmd_state3_parsed(void *parsed_result,
296 __attribute__((unused)) void *data)
298 struct cmd_state3_result *res = parsed_result;
300 if (!strcmp_P(res->arg1, PSTR("xxx"))) {
301 /* xxx = res->arg2 */
303 else if (!strcmp_P(res->arg1, PSTR("yyy"))) {
308 prog_char str_state3_arg0[] = "cobboard";
309 parse_pgm_token_string_t cmd_state3_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state3_result, arg0, str_state3_arg0);
310 prog_char str_state3_arg1[] = "xxx";
311 parse_pgm_token_string_t cmd_state3_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state3_result, arg1, str_state3_arg1);
312 parse_pgm_token_num_t cmd_state3_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_state3_result, arg2, UINT8);
314 prog_char help_state3[] = "set cobboard mode";
315 parse_pgm_inst_t cmd_state3 = {
316 .f = cmd_state3_parsed, /* function to call */
317 .data = NULL, /* 2nd arg of func */
318 .help_str = help_state3,
319 .tokens = { /* token list, NULL terminated */
320 (prog_void *)&cmd_state3_arg0,
321 (prog_void *)&cmd_state3_arg1,
322 (prog_void *)&cmd_state3_arg2,
327 /**********************************************************/
330 /* this structure is filled when cmd_state_machine is parsed successfully */
331 struct cmd_state_machine_result {
335 /* function called when cmd_state_machine is parsed successfully */
336 static void cmd_state_machine_parsed(__attribute__((unused)) void *parsed_result,
337 __attribute__((unused)) void *data)
342 prog_char str_state_machine_arg0[] = "state_machine";
343 parse_pgm_token_string_t cmd_state_machine_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state_machine_result, arg0, str_state_machine_arg0);
345 prog_char help_state_machine[] = "launch state machine";
346 parse_pgm_inst_t cmd_state_machine = {
347 .f = cmd_state_machine_parsed, /* function to call */
348 .data = NULL, /* 2nd arg of func */
349 .help_str = help_state_machine,
350 .tokens = { /* token list, NULL terminated */
351 (prog_void *)&cmd_state_machine_arg0,
356 /**********************************************************/
359 /* this structure is filled when cmd_state_debug is parsed successfully */
360 struct cmd_state_debug_result {
365 /* function called when cmd_state_debug is parsed successfully */
366 static void cmd_state_debug_parsed(void *parsed_result,
367 __attribute__((unused)) void *data)
369 struct cmd_state_debug_result *res = parsed_result;
370 state_debug = res->on;
373 prog_char str_state_debug_arg0[] = "state_debug";
374 parse_pgm_token_string_t cmd_state_debug_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state_debug_result, arg0, str_state_debug_arg0);
375 parse_pgm_token_num_t cmd_state_debug_on = TOKEN_NUM_INITIALIZER(struct cmd_state_debug_result, on, UINT8);
377 prog_char help_state_debug[] = "Set debug timer for state machine";
378 parse_pgm_inst_t cmd_state_debug = {
379 .f = cmd_state_debug_parsed, /* function to call */
380 .data = NULL, /* 2nd arg of func */
381 .help_str = help_state_debug,
382 .tokens = { /* token list, NULL terminated */
383 (prog_void *)&cmd_state_debug_arg0,
384 (prog_void *)&cmd_state_debug_on,
389 /**********************************************************/
392 /* this structure is filled when cmd_servo_door is parsed successfully */
393 struct cmd_servo_door_result {
398 /* function called when cmd_servo_door is parsed successfully */
399 static void cmd_servo_door_parsed(void *parsed_result,
400 __attribute__((unused)) void *data)
402 struct cmd_servo_door_result *res = parsed_result;
403 if (!strcmp_P(res->arg1, PSTR("open")))
405 else if (!strcmp_P(res->arg1, PSTR("closed")))
409 prog_char str_servo_door_arg0[] = "door";
410 parse_pgm_token_string_t cmd_servo_door_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_servo_door_result, arg0, str_servo_door_arg0);
411 prog_char str_servo_door_arg1[] = "open#closed";
412 parse_pgm_token_string_t cmd_servo_door_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_servo_door_result, arg1, str_servo_door_arg1);
414 prog_char help_servo_door[] = "Servo door function";
415 parse_pgm_inst_t cmd_servo_door = {
416 .f = cmd_servo_door_parsed, /* function to call */
417 .data = NULL, /* 2nd arg of func */
418 .help_str = help_servo_door,
419 .tokens = { /* token list, NULL terminated */
420 (prog_void *)&cmd_servo_door_arg0,
421 (prog_void *)&cmd_servo_door_arg1,
426 /**********************************************************/
429 /* this structure is filled when cmd_cobroller is parsed successfully */
430 struct cmd_cobroller_result {
436 /* function called when cmd_cobroller is parsed successfully */
437 static void cmd_cobroller_parsed(void *parsed_result,
438 __attribute__((unused)) void *data)
440 struct cmd_cobroller_result *res = parsed_result;
442 if (!strcmp_P(res->arg1, PSTR("left"))) {
443 if (!strcmp_P(res->arg2, PSTR("on")))
445 else if (!strcmp_P(res->arg2, PSTR("off")))
446 left_cobroller_off();
448 else if (!strcmp_P(res->arg1, PSTR("right"))) {
449 if (!strcmp_P(res->arg2, PSTR("on")))
450 right_cobroller_on();
451 else if (!strcmp_P(res->arg2, PSTR("off")))
452 right_cobroller_off();
456 prog_char str_cobroller_arg0[] = "cobroller";
457 parse_pgm_token_string_t cmd_cobroller_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_cobroller_result, arg0, str_cobroller_arg0);
458 prog_char str_cobroller_arg1[] = "left#right";
459 parse_pgm_token_string_t cmd_cobroller_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_cobroller_result, arg1, str_cobroller_arg1);
460 prog_char str_cobroller_arg2[] = "on#off";
461 parse_pgm_token_string_t cmd_cobroller_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_cobroller_result, arg2, str_cobroller_arg2);
463 prog_char help_cobroller[] = "Servo door function";
464 parse_pgm_inst_t cmd_cobroller = {
465 .f = cmd_cobroller_parsed, /* function to call */
466 .data = NULL, /* 2nd arg of func */
467 .help_str = help_cobroller,
468 .tokens = { /* token list, NULL terminated */
469 (prog_void *)&cmd_cobroller_arg0,
470 (prog_void *)&cmd_cobroller_arg1,
471 (prog_void *)&cmd_cobroller_arg2,
476 /**********************************************************/
479 /* this structure is filled when cmd_shovel is parsed successfully */
480 struct cmd_shovel_result {
485 /* function called when cmd_shovel is parsed successfully */
486 static void cmd_shovel_parsed(void *parsed_result,
487 __attribute__((unused)) void *data)
489 struct cmd_shovel_result *res = parsed_result;
490 if (!strcmp_P(res->arg1, PSTR("down")))
492 else if (!strcmp_P(res->arg1, PSTR("up")))
494 else if (!strcmp_P(res->arg1, PSTR("mid")))
498 prog_char str_shovel_arg0[] = "shovel";
499 parse_pgm_token_string_t cmd_shovel_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_shovel_result, arg0, str_shovel_arg0);
500 prog_char str_shovel_arg1[] = "down#up#mid";
501 parse_pgm_token_string_t cmd_shovel_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_shovel_result, arg1, str_shovel_arg1);
503 prog_char help_shovel[] = "Servo shovel function";
504 parse_pgm_inst_t cmd_shovel = {
505 .f = cmd_shovel_parsed, /* function to call */
506 .data = NULL, /* 2nd arg of func */
507 .help_str = help_shovel,
508 .tokens = { /* token list, NULL terminated */
509 (prog_void *)&cmd_shovel_arg0,
510 (prog_void *)&cmd_shovel_arg1,
515 /**********************************************************/
518 /* this structure is filled when cmd_servo_carry is parsed successfully */
519 struct cmd_servo_carry_result {
524 /* function called when cmd_servo_carry is parsed successfully */
525 static void cmd_servo_carry_parsed(void *parsed_result,
526 __attribute__((unused)) void *data)
528 struct cmd_servo_carry_result *res = parsed_result;
529 if (!strcmp_P(res->arg1, PSTR("open")))
531 else if (!strcmp_P(res->arg1, PSTR("closed")))
535 prog_char str_servo_carry_arg0[] = "carry";
536 parse_pgm_token_string_t cmd_servo_carry_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_servo_carry_result, arg0, str_servo_carry_arg0);
537 prog_char str_servo_carry_arg1[] = "open#closed";
538 parse_pgm_token_string_t cmd_servo_carry_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_servo_carry_result, arg1, str_servo_carry_arg1);
540 prog_char help_servo_carry[] = "Servo carry function";
541 parse_pgm_inst_t cmd_servo_carry = {
542 .f = cmd_servo_carry_parsed, /* function to call */
543 .data = NULL, /* 2nd arg of func */
544 .help_str = help_servo_carry,
545 .tokens = { /* token list, NULL terminated */
546 (prog_void *)&cmd_servo_carry_arg0,
547 (prog_void *)&cmd_servo_carry_arg1,
552 /**********************************************************/
555 /* this structure is filled when cmd_spickle is parsed successfully */
556 struct cmd_spickle_result {
562 /* function called when cmd_spickle is parsed successfully */
563 static void cmd_spickle_parsed(void * parsed_result,
564 __attribute__((unused)) void *data)
566 struct cmd_spickle_result * res = parsed_result;
569 if (!strcmp_P(res->arg1, PSTR("left")))
570 side = I2C_LEFT_SIDE;
572 side = I2C_RIGHT_SIDE;
574 if (!strcmp_P(res->arg2, PSTR("deploy"))) {
575 spickle_deploy(side);
577 else if (!strcmp_P(res->arg2, PSTR("pack"))) {
580 printf_P(PSTR("done\r\n"));
583 prog_char str_spickle_arg0[] = "spickle";
584 parse_pgm_token_string_t cmd_spickle_arg0 =
585 TOKEN_STRING_INITIALIZER(struct cmd_spickle_result, arg0, str_spickle_arg0);
586 prog_char str_spickle_arg1[] = "left#right";
587 parse_pgm_token_string_t cmd_spickle_arg1 =
588 TOKEN_STRING_INITIALIZER(struct cmd_spickle_result, arg1, str_spickle_arg1);
589 prog_char str_spickle_arg2[] = "deploy#pack";
590 parse_pgm_token_string_t cmd_spickle_arg2 =
591 TOKEN_STRING_INITIALIZER(struct cmd_spickle_result, arg2, str_spickle_arg2);
593 prog_char help_spickle[] = "move spickle";
594 parse_pgm_inst_t cmd_spickle = {
595 .f = cmd_spickle_parsed, /* function to call */
596 .data = NULL, /* 2nd arg of func */
597 .help_str = help_spickle,
598 .tokens = { /* token list, NULL terminated */
599 (prog_void *)&cmd_spickle_arg0,
600 (prog_void *)&cmd_spickle_arg1,
601 (prog_void *)&cmd_spickle_arg2,
606 /**********************************************************/
607 /* Set Spickle Params */
609 /* this structure is filled when cmd_spickle_params is parsed successfully */
610 struct cmd_spickle_params_result {
618 /* function called when cmd_spickle_params is parsed successfully */
619 static void cmd_spickle_params_parsed(void *parsed_result,
620 __attribute__((unused)) void *data)
622 struct cmd_spickle_params_result * res = parsed_result;
625 if (!strcmp_P(res->arg1, PSTR("show"))) {
626 spickle_dump_params();
630 if (!strcmp_P(res->arg1, PSTR("left")))
631 side = I2C_LEFT_SIDE;
633 side = I2C_RIGHT_SIDE;
635 if (!strcmp_P(res->arg2, PSTR("pos")))
636 spickle_set_pos(side, res->arg3, res->arg4);
637 else if (!strcmp_P(res->arg2, PSTR("delay")))
638 spickle_set_delay(side, res->arg3, res->arg4);
641 prog_char str_spickle_params_arg0[] = "spickle_params";
642 parse_pgm_token_string_t cmd_spickle_params_arg0 =
643 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg0, str_spickle_params_arg0);
644 prog_char str_spickle_params_arg1[] = "left#right";
645 parse_pgm_token_string_t cmd_spickle_params_arg1 =
646 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg1, str_spickle_params_arg1);
647 prog_char str_spickle_params_arg2[] = "pos#delay";
648 parse_pgm_token_string_t cmd_spickle_params_arg2 =
649 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg2, str_spickle_params_arg2);
650 parse_pgm_token_num_t cmd_spickle_params_arg3 =
651 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params_result, arg3, INT32);
652 parse_pgm_token_num_t cmd_spickle_params_arg4 =
653 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params_result, arg4, INT32);
655 prog_char help_spickle_params[] = "Set spickle pos values";
656 parse_pgm_inst_t cmd_spickle_params = {
657 .f = cmd_spickle_params_parsed, /* function to call */
658 .data = NULL, /* 2nd arg of func */
659 .help_str = help_spickle_params,
660 .tokens = { /* token list, NULL terminated */
661 (prog_void *)&cmd_spickle_params_arg0,
662 (prog_void *)&cmd_spickle_params_arg1,
663 (prog_void *)&cmd_spickle_params_arg2,
664 (prog_void *)&cmd_spickle_params_arg3,
665 (prog_void *)&cmd_spickle_params_arg4,
670 prog_char str_spickle_params_arg1_show[] = "show";
671 parse_pgm_token_string_t cmd_spickle_params_arg1_show =
672 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg1, str_spickle_params_arg1_show);
674 prog_char help_spickle_params_show[] = "show spickle params";
675 parse_pgm_inst_t cmd_spickle_params_show = {
676 .f = cmd_spickle_params_parsed, /* function to call */
677 .data = NULL, /* 2nd arg of func */
678 .help_str = help_spickle_params_show,
679 .tokens = { /* token list, NULL terminated */
680 (prog_void *)&cmd_spickle_params_arg0,
681 (prog_void *)&cmd_spickle_params_arg1_show,
686 /**********************************************************/
687 /* Set Spickle Params */
689 /* this structure is filled when cmd_spickle_params2 is parsed successfully */
690 struct cmd_spickle_params2_result {
697 /* function called when cmd_spickle_params2 is parsed successfully */
698 static void cmd_spickle_params2_parsed(void *parsed_result,
699 __attribute__((unused)) void *data)
701 struct cmd_spickle_params2_result * res = parsed_result;
703 if (!strcmp_P(res->arg1, PSTR("coef"))) {
704 spickle_set_coefs(res->arg2, res->arg3);
708 spickle_dump_params();
711 prog_char str_spickle_params2_arg0[] = "spickle_params2";
712 parse_pgm_token_string_t cmd_spickle_params2_arg0 =
713 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params2_result, arg0, str_spickle_params2_arg0);
714 prog_char str_spickle_params2_arg1[] = "coef";
715 parse_pgm_token_string_t cmd_spickle_params2_arg1 =
716 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params2_result, arg1, str_spickle_params2_arg1);
717 parse_pgm_token_num_t cmd_spickle_params2_arg2 =
718 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params2_result, arg2, INT32);
719 parse_pgm_token_num_t cmd_spickle_params2_arg3 =
720 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params2_result, arg3, INT32);
722 prog_char help_spickle_params2[] = "Set spickle_params2 values";
723 parse_pgm_inst_t cmd_spickle_params2 = {
724 .f = cmd_spickle_params2_parsed, /* function to call */
725 .data = NULL, /* 2nd arg of func */
726 .help_str = help_spickle_params2,
727 .tokens = { /* token list, NULL terminated */
728 (prog_void *)&cmd_spickle_params2_arg0,
729 (prog_void *)&cmd_spickle_params2_arg1,
730 (prog_void *)&cmd_spickle_params2_arg2,
731 (prog_void *)&cmd_spickle_params2_arg3,
736 prog_char str_spickle_params2_arg1_show[] = "show";
737 parse_pgm_token_string_t cmd_spickle_params2_arg1_show =
738 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params2_result, arg1, str_spickle_params2_arg1_show);
740 prog_char help_spickle_params2_show[] = "show spickle params";
741 parse_pgm_inst_t cmd_spickle_params2_show = {
742 .f = cmd_spickle_params2_parsed, /* function to call */
743 .data = NULL, /* 2nd arg of func */
744 .help_str = help_spickle_params2_show,
745 .tokens = { /* token list, NULL terminated */
746 (prog_void *)&cmd_spickle_params2_arg0,
747 (prog_void *)&cmd_spickle_params2_arg1_show,
752 /**********************************************************/
755 /* this structure is filled when cmd_test is parsed successfully */
756 struct cmd_test_result {
760 /* function called when cmd_test is parsed successfully */
761 static void cmd_test_parsed(__attribute__((unused)) void *parsed_result,
762 __attribute__((unused)) void *data)
766 prog_char str_test_arg0[] = "test";
767 parse_pgm_token_string_t cmd_test_arg0 =
768 TOKEN_STRING_INITIALIZER(struct cmd_test_result, arg0, str_test_arg0);
770 prog_char help_test[] = "Test function";
771 parse_pgm_inst_t cmd_test = {
772 .f = cmd_test_parsed, /* function to call */
773 .data = NULL, /* 2nd arg of func */
774 .help_str = help_test,
775 .tokens = { /* token list, NULL terminated */
776 (prog_void *)&cmd_test_arg0,