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"))) {
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");
85 printf_P(PSTR("errblock is %s\r\n"),
86 (DO_ERRBLOCKING & 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")))
100 else if (!strcmp_P(res->arg1, PSTR("errblock")))
101 bit = DO_ERRBLOCKING;
104 if (!strcmp_P(res->arg2, PSTR("on")))
105 cobboard.flags |= bit;
106 else if (!strcmp_P(res->arg2, PSTR("off"))) {
107 if (!strcmp_P(res->arg1, PSTR("cs"))) {
108 pwm_ng_set(LEFT_SPICKLE_PWM, 0);
109 pwm_ng_set(RIGHT_SPICKLE_PWM, 0);
110 pwm_ng_set(SHOVEL_PWM, 0);
112 cobboard.flags &= (~bit);
114 printf_P(PSTR("%s is %s\r\n"), res->arg1,
115 (bit & cobboard.flags) ? "on":"off");
118 prog_char str_event_arg0[] = "event";
119 parse_pgm_token_string_t cmd_event_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg0, str_event_arg0);
120 prog_char str_event_arg1[] = "all#encoders#cs#bd#power#errblock";
121 parse_pgm_token_string_t cmd_event_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg1, str_event_arg1);
122 prog_char str_event_arg2[] = "on#off#show";
123 parse_pgm_token_string_t cmd_event_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg2, str_event_arg2);
125 prog_char help_event[] = "Enable/disable events";
126 parse_pgm_inst_t cmd_event = {
127 .f = cmd_event_parsed, /* function to call */
128 .data = NULL, /* 2nd arg of func */
129 .help_str = help_event,
130 .tokens = { /* token list, NULL terminated */
131 (prog_void *)&cmd_event_arg0,
132 (prog_void *)&cmd_event_arg1,
133 (prog_void *)&cmd_event_arg2,
138 /**********************************************************/
141 /* this structure is filled when cmd_color is parsed successfully */
142 struct cmd_color_result {
144 fixed_string_t color;
147 /* function called when cmd_color is parsed successfully */
148 static void cmd_color_parsed(void *parsed_result, __attribute__((unused)) void *data)
150 struct cmd_color_result *res = (struct cmd_color_result *) parsed_result;
151 if (!strcmp_P(res->color, PSTR("yellow"))) {
152 cobboard.our_color = I2C_COLOR_YELLOW;
154 else if (!strcmp_P(res->color, PSTR("blue"))) {
155 cobboard.our_color = I2C_COLOR_BLUE;
157 printf_P(PSTR("Done\r\n"));
160 prog_char str_color_arg0[] = "color";
161 parse_pgm_token_string_t cmd_color_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_color_result, arg0, str_color_arg0);
162 prog_char str_color_color[] = "blue#yellow";
163 parse_pgm_token_string_t cmd_color_color = TOKEN_STRING_INITIALIZER(struct cmd_color_result, color, str_color_color);
165 prog_char help_color[] = "Set our color";
166 parse_pgm_inst_t cmd_color = {
167 .f = cmd_color_parsed, /* function to call */
168 .data = NULL, /* 2nd arg of func */
169 .help_str = help_color,
170 .tokens = { /* token list, NULL terminated */
171 (prog_void *)&cmd_color_arg0,
172 (prog_void *)&cmd_color_color,
177 /**********************************************************/
180 /* this structure is filled when cmd_state1 is parsed successfully */
181 struct cmd_state1_result {
186 /* function called when cmd_state1 is parsed successfully */
187 static void cmd_state1_parsed(void *parsed_result,
188 __attribute__((unused)) void *data)
190 struct cmd_state1_result *res = parsed_result;
192 if (!strcmp_P(res->arg1, PSTR("init")))
194 else if (!strcmp_P(res->arg1, PSTR("eject")))
195 state_set_mode(I2C_COBBOARD_MODE_EJECT);
196 else if (!strcmp_P(res->arg1, PSTR("ignore_i2c")))
197 state_set_i2c_ignore(1);
198 else if (!strcmp_P(res->arg1, PSTR("care_i2c")))
199 state_set_i2c_ignore(0);
204 prog_char str_state1_arg0[] = "cobboard";
205 parse_pgm_token_string_t cmd_state1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg0, str_state1_arg0);
206 prog_char str_state1_arg1[] = "init#eject#ignore_i2c#care_i2c";
207 parse_pgm_token_string_t cmd_state1_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg1, str_state1_arg1);
209 prog_char help_state1[] = "set cobboard mode";
210 parse_pgm_inst_t cmd_state1 = {
211 .f = cmd_state1_parsed, /* function to call */
212 .data = NULL, /* 2nd arg of func */
213 .help_str = help_state1,
214 .tokens = { /* token list, NULL terminated */
215 (prog_void *)&cmd_state1_arg0,
216 (prog_void *)&cmd_state1_arg1,
221 /**********************************************************/
224 /* this structure is filled when cmd_state2 is parsed successfully */
225 struct cmd_state2_result {
231 /* function called when cmd_state2 is parsed successfully */
232 static void cmd_state2_parsed(void *parsed_result,
233 __attribute__((unused)) void *data)
235 struct cmd_state2_result *res = parsed_result;
238 if (!strcmp_P(res->arg2, PSTR("left")))
239 side = I2C_LEFT_SIDE;
241 side = I2C_RIGHT_SIDE;
243 if (!strcmp_P(res->arg1, PSTR("pack"))) {
244 state_set_mode(I2C_COBBOARD_MODE_HARVEST);
245 state_set_spickle(side, 0);
247 else if (!strcmp_P(res->arg1, PSTR("deploy"))) {
248 state_set_mode(I2C_COBBOARD_MODE_HARVEST);
249 state_set_spickle(side, I2C_COBBOARD_SPK_DEPLOY);
251 else if (!strcmp_P(res->arg1, PSTR("harvest"))) {
252 state_set_mode(I2C_COBBOARD_MODE_HARVEST);
253 state_set_spickle(side, I2C_COBBOARD_SPK_DEPLOY |
254 I2C_COBBOARD_SPK_AUTOHARVEST);
256 else if (!strcmp_P(res->arg1, PSTR("deploy_nomove"))) {
257 state_set_mode(I2C_COBBOARD_MODE_HARVEST);
258 state_set_spickle(side, I2C_COBBOARD_SPK_DEPLOY |
259 I2C_COBBOARD_SPK_NO_MOVE);
261 else if (!strcmp_P(res->arg1, PSTR("harvest_nomove"))) {
262 state_set_mode(I2C_COBBOARD_MODE_HARVEST);
263 state_set_spickle(side, I2C_COBBOARD_SPK_DEPLOY |
264 I2C_COBBOARD_SPK_AUTOHARVEST |
265 I2C_COBBOARD_SPK_NO_MOVE);
269 prog_char str_state2_arg0[] = "cobboard";
270 parse_pgm_token_string_t cmd_state2_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg0, str_state2_arg0);
271 prog_char str_state2_arg1[] = "harvest#deploy#pack#harvest_nomove#deploy_nomove";
272 parse_pgm_token_string_t cmd_state2_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg1, str_state2_arg1);
273 prog_char str_state2_arg2[] = "left#right";
274 parse_pgm_token_string_t cmd_state2_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg2, str_state2_arg2);
276 prog_char help_state2[] = "set cobboard mode";
277 parse_pgm_inst_t cmd_state2 = {
278 .f = cmd_state2_parsed, /* function to call */
279 .data = NULL, /* 2nd arg of func */
280 .help_str = help_state2,
281 .tokens = { /* token list, NULL terminated */
282 (prog_void *)&cmd_state2_arg0,
283 (prog_void *)&cmd_state2_arg1,
284 (prog_void *)&cmd_state2_arg2,
289 /**********************************************************/
292 /* this structure is filled when cmd_state3 is parsed successfully */
293 struct cmd_state3_result {
299 /* function called when cmd_state3 is parsed successfully */
300 static void cmd_state3_parsed(void *parsed_result,
301 __attribute__((unused)) void *data)
303 struct cmd_state3_result *res = parsed_result;
305 if (!strcmp_P(res->arg1, PSTR("xxx"))) {
306 /* xxx = res->arg2 */
308 else if (!strcmp_P(res->arg1, PSTR("yyy"))) {
313 prog_char str_state3_arg0[] = "cobboard";
314 parse_pgm_token_string_t cmd_state3_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state3_result, arg0, str_state3_arg0);
315 prog_char str_state3_arg1[] = "xxx";
316 parse_pgm_token_string_t cmd_state3_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state3_result, arg1, str_state3_arg1);
317 parse_pgm_token_num_t cmd_state3_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_state3_result, arg2, UINT8);
319 prog_char help_state3[] = "set cobboard mode";
320 parse_pgm_inst_t cmd_state3 = {
321 .f = cmd_state3_parsed, /* function to call */
322 .data = NULL, /* 2nd arg of func */
323 .help_str = help_state3,
324 .tokens = { /* token list, NULL terminated */
325 (prog_void *)&cmd_state3_arg0,
326 (prog_void *)&cmd_state3_arg1,
327 (prog_void *)&cmd_state3_arg2,
332 /**********************************************************/
335 /* this structure is filled when cmd_state_machine is parsed successfully */
336 struct cmd_state_machine_result {
340 /* function called when cmd_state_machine is parsed successfully */
341 static void cmd_state_machine_parsed(__attribute__((unused)) void *parsed_result,
342 __attribute__((unused)) void *data)
347 prog_char str_state_machine_arg0[] = "state_machine";
348 parse_pgm_token_string_t cmd_state_machine_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state_machine_result, arg0, str_state_machine_arg0);
350 prog_char help_state_machine[] = "launch state machine";
351 parse_pgm_inst_t cmd_state_machine = {
352 .f = cmd_state_machine_parsed, /* function to call */
353 .data = NULL, /* 2nd arg of func */
354 .help_str = help_state_machine,
355 .tokens = { /* token list, NULL terminated */
356 (prog_void *)&cmd_state_machine_arg0,
361 /**********************************************************/
364 /* this structure is filled when cmd_state_debug is parsed successfully */
365 struct cmd_state_debug_result {
370 /* function called when cmd_state_debug is parsed successfully */
371 static void cmd_state_debug_parsed(void *parsed_result,
372 __attribute__((unused)) void *data)
374 struct cmd_state_debug_result *res = parsed_result;
375 state_debug = res->on;
378 prog_char str_state_debug_arg0[] = "state_debug";
379 parse_pgm_token_string_t cmd_state_debug_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state_debug_result, arg0, str_state_debug_arg0);
380 parse_pgm_token_num_t cmd_state_debug_on = TOKEN_NUM_INITIALIZER(struct cmd_state_debug_result, on, UINT8);
382 prog_char help_state_debug[] = "Set debug for state machine";
383 parse_pgm_inst_t cmd_state_debug = {
384 .f = cmd_state_debug_parsed, /* function to call */
385 .data = NULL, /* 2nd arg of func */
386 .help_str = help_state_debug,
387 .tokens = { /* token list, NULL terminated */
388 (prog_void *)&cmd_state_debug_arg0,
389 (prog_void *)&cmd_state_debug_on,
394 /**********************************************************/
397 /* this structure is filled when cmd_servo_door is parsed successfully */
398 struct cmd_servo_door_result {
403 /* function called when cmd_servo_door is parsed successfully */
404 static void cmd_servo_door_parsed(void *parsed_result,
405 __attribute__((unused)) void *data)
407 struct cmd_servo_door_result *res = parsed_result;
408 if (!strcmp_P(res->arg1, PSTR("open")))
410 else if (!strcmp_P(res->arg1, PSTR("closed")))
412 else if (!strcmp_P(res->arg1, PSTR("block")))
416 prog_char str_servo_door_arg0[] = "door";
417 parse_pgm_token_string_t cmd_servo_door_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_servo_door_result, arg0, str_servo_door_arg0);
418 prog_char str_servo_door_arg1[] = "open#closed#block";
419 parse_pgm_token_string_t cmd_servo_door_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_servo_door_result, arg1, str_servo_door_arg1);
421 prog_char help_servo_door[] = "Servo door function";
422 parse_pgm_inst_t cmd_servo_door = {
423 .f = cmd_servo_door_parsed, /* function to call */
424 .data = NULL, /* 2nd arg of func */
425 .help_str = help_servo_door,
426 .tokens = { /* token list, NULL terminated */
427 (prog_void *)&cmd_servo_door_arg0,
428 (prog_void *)&cmd_servo_door_arg1,
433 /**********************************************************/
436 /* this structure is filled when cmd_cobroller is parsed successfully */
437 struct cmd_cobroller_result {
443 /* function called when cmd_cobroller is parsed successfully */
444 static void cmd_cobroller_parsed(void *parsed_result,
445 __attribute__((unused)) void *data)
447 struct cmd_cobroller_result *res = parsed_result;
450 if (!strcmp_P(res->arg1, PSTR("left")))
451 side = I2C_LEFT_SIDE;
453 side = I2C_RIGHT_SIDE;
455 if (!strcmp_P(res->arg2, PSTR("on")))
457 else if (!strcmp_P(res->arg2, PSTR("off")))
461 prog_char str_cobroller_arg0[] = "cobroller";
462 parse_pgm_token_string_t cmd_cobroller_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_cobroller_result, arg0, str_cobroller_arg0);
463 prog_char str_cobroller_arg1[] = "left#right";
464 parse_pgm_token_string_t cmd_cobroller_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_cobroller_result, arg1, str_cobroller_arg1);
465 prog_char str_cobroller_arg2[] = "on#off";
466 parse_pgm_token_string_t cmd_cobroller_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_cobroller_result, arg2, str_cobroller_arg2);
468 prog_char help_cobroller[] = "Servo door function";
469 parse_pgm_inst_t cmd_cobroller = {
470 .f = cmd_cobroller_parsed, /* function to call */
471 .data = NULL, /* 2nd arg of func */
472 .help_str = help_cobroller,
473 .tokens = { /* token list, NULL terminated */
474 (prog_void *)&cmd_cobroller_arg0,
475 (prog_void *)&cmd_cobroller_arg1,
476 (prog_void *)&cmd_cobroller_arg2,
481 /**********************************************************/
484 /* this structure is filled when cmd_shovel is parsed successfully */
485 struct cmd_shovel_result {
490 /* function called when cmd_shovel is parsed successfully */
491 static void cmd_shovel_parsed(void *parsed_result,
492 __attribute__((unused)) void *data)
494 struct cmd_shovel_result *res = parsed_result;
495 if (!strcmp_P(res->arg1, PSTR("down")))
497 else if (!strcmp_P(res->arg1, PSTR("up")))
499 else if (!strcmp_P(res->arg1, PSTR("mid")))
503 prog_char str_shovel_arg0[] = "shovel";
504 parse_pgm_token_string_t cmd_shovel_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_shovel_result, arg0, str_shovel_arg0);
505 prog_char str_shovel_arg1[] = "down#up#mid";
506 parse_pgm_token_string_t cmd_shovel_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_shovel_result, arg1, str_shovel_arg1);
508 prog_char help_shovel[] = "Servo shovel function";
509 parse_pgm_inst_t cmd_shovel = {
510 .f = cmd_shovel_parsed, /* function to call */
511 .data = NULL, /* 2nd arg of func */
512 .help_str = help_shovel,
513 .tokens = { /* token list, NULL terminated */
514 (prog_void *)&cmd_shovel_arg0,
515 (prog_void *)&cmd_shovel_arg1,
520 /**********************************************************/
523 /* this structure is filled when cmd_servo_carry is parsed successfully */
524 struct cmd_servo_carry_result {
529 /* function called when cmd_servo_carry is parsed successfully */
530 static void cmd_servo_carry_parsed(void *parsed_result,
531 __attribute__((unused)) void *data)
533 struct cmd_servo_carry_result *res = parsed_result;
534 if (!strcmp_P(res->arg1, PSTR("open")))
536 else if (!strcmp_P(res->arg1, PSTR("closed")))
540 prog_char str_servo_carry_arg0[] = "carry";
541 parse_pgm_token_string_t cmd_servo_carry_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_servo_carry_result, arg0, str_servo_carry_arg0);
542 prog_char str_servo_carry_arg1[] = "open#closed";
543 parse_pgm_token_string_t cmd_servo_carry_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_servo_carry_result, arg1, str_servo_carry_arg1);
545 prog_char help_servo_carry[] = "Servo carry function";
546 parse_pgm_inst_t cmd_servo_carry = {
547 .f = cmd_servo_carry_parsed, /* function to call */
548 .data = NULL, /* 2nd arg of func */
549 .help_str = help_servo_carry,
550 .tokens = { /* token list, NULL terminated */
551 (prog_void *)&cmd_servo_carry_arg0,
552 (prog_void *)&cmd_servo_carry_arg1,
557 /**********************************************************/
560 /* this structure is filled when cmd_spickle is parsed successfully */
561 struct cmd_spickle_result {
567 /* function called when cmd_spickle is parsed successfully */
568 static void cmd_spickle_parsed(void * parsed_result,
569 __attribute__((unused)) void *data)
571 struct cmd_spickle_result * res = parsed_result;
574 if (!strcmp_P(res->arg1, PSTR("left")))
575 side = I2C_LEFT_SIDE;
577 side = I2C_RIGHT_SIDE;
579 if (!strcmp_P(res->arg2, PSTR("deploy"))) {
580 spickle_deploy(side);
582 else if (!strcmp_P(res->arg2, PSTR("pack"))) {
585 else if (!strcmp_P(res->arg2, PSTR("mid"))) {
588 printf_P(PSTR("done\r\n"));
591 prog_char str_spickle_arg0[] = "spickle";
592 parse_pgm_token_string_t cmd_spickle_arg0 =
593 TOKEN_STRING_INITIALIZER(struct cmd_spickle_result, arg0, str_spickle_arg0);
594 prog_char str_spickle_arg1[] = "left#right";
595 parse_pgm_token_string_t cmd_spickle_arg1 =
596 TOKEN_STRING_INITIALIZER(struct cmd_spickle_result, arg1, str_spickle_arg1);
597 prog_char str_spickle_arg2[] = "deploy#pack#mid";
598 parse_pgm_token_string_t cmd_spickle_arg2 =
599 TOKEN_STRING_INITIALIZER(struct cmd_spickle_result, arg2, str_spickle_arg2);
601 prog_char help_spickle[] = "move spickle";
602 parse_pgm_inst_t cmd_spickle = {
603 .f = cmd_spickle_parsed, /* function to call */
604 .data = NULL, /* 2nd arg of func */
605 .help_str = help_spickle,
606 .tokens = { /* token list, NULL terminated */
607 (prog_void *)&cmd_spickle_arg0,
608 (prog_void *)&cmd_spickle_arg1,
609 (prog_void *)&cmd_spickle_arg2,
614 /**********************************************************/
615 /* Set Spickle Params */
617 /* this structure is filled when cmd_spickle_params is parsed successfully */
618 struct cmd_spickle_params_result {
627 /* function called when cmd_spickle_params is parsed successfully */
628 static void cmd_spickle_params_parsed(void *parsed_result,
629 __attribute__((unused)) void *data)
631 struct cmd_spickle_params_result * res = parsed_result;
634 if (!strcmp_P(res->arg1, PSTR("show"))) {
635 spickle_dump_params();
639 if (!strcmp_P(res->arg1, PSTR("left")))
640 side = I2C_LEFT_SIDE;
642 side = I2C_RIGHT_SIDE;
644 if (!strcmp_P(res->arg2, PSTR("pos")))
645 spickle_set_pos(side, res->arg3, res->arg4, res->arg5);
648 prog_char str_spickle_params_arg0[] = "spickle_params";
649 parse_pgm_token_string_t cmd_spickle_params_arg0 =
650 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg0, str_spickle_params_arg0);
651 prog_char str_spickle_params_arg1[] = "left#right";
652 parse_pgm_token_string_t cmd_spickle_params_arg1 =
653 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg1, str_spickle_params_arg1);
654 prog_char str_spickle_params_arg2[] = "pos";
655 parse_pgm_token_string_t cmd_spickle_params_arg2 =
656 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg2, str_spickle_params_arg2);
657 parse_pgm_token_num_t cmd_spickle_params_arg3 =
658 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params_result, arg3, INT32);
659 parse_pgm_token_num_t cmd_spickle_params_arg4 =
660 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params_result, arg4, INT32);
661 parse_pgm_token_num_t cmd_spickle_params_arg5 =
662 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params_result, arg5, INT32);
664 prog_char help_spickle_params[] = "Set spickle pos values: left|right pos INTPACK INTMID INTDEPL";
665 parse_pgm_inst_t cmd_spickle_params = {
666 .f = cmd_spickle_params_parsed, /* function to call */
667 .data = NULL, /* 2nd arg of func */
668 .help_str = help_spickle_params,
669 .tokens = { /* token list, NULL terminated */
670 (prog_void *)&cmd_spickle_params_arg0,
671 (prog_void *)&cmd_spickle_params_arg1,
672 (prog_void *)&cmd_spickle_params_arg2,
673 (prog_void *)&cmd_spickle_params_arg3,
674 (prog_void *)&cmd_spickle_params_arg4,
675 (prog_void *)&cmd_spickle_params_arg5,
680 prog_char str_spickle_params_arg1_show[] = "show";
681 parse_pgm_token_string_t cmd_spickle_params_arg1_show =
682 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg1, str_spickle_params_arg1_show);
684 prog_char help_spickle_params_show[] = "show spickle params";
685 parse_pgm_inst_t cmd_spickle_params_show = {
686 .f = cmd_spickle_params_parsed, /* function to call */
687 .data = NULL, /* 2nd arg of func */
688 .help_str = help_spickle_params_show,
689 .tokens = { /* token list, NULL terminated */
690 (prog_void *)&cmd_spickle_params_arg0,
691 (prog_void *)&cmd_spickle_params_arg1_show,
696 /**********************************************************/
697 /* Set Spickle Params */
699 /* this structure is filled when cmd_spickle_params2 is parsed successfully */
700 struct cmd_spickle_params2_result {
707 /* function called when cmd_spickle_params2 is parsed successfully */
708 static void cmd_spickle_params2_parsed(void *parsed_result,
709 __attribute__((unused)) void *data)
711 struct cmd_spickle_params2_result * res = parsed_result;
713 if (!strcmp_P(res->arg1, PSTR("coef"))) {
714 spickle_set_coefs(res->arg2, res->arg3);
718 spickle_dump_params();
721 prog_char str_spickle_params2_arg0[] = "spickle_params2";
722 parse_pgm_token_string_t cmd_spickle_params2_arg0 =
723 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params2_result, arg0, str_spickle_params2_arg0);
724 prog_char str_spickle_params2_arg1[] = "coef";
725 parse_pgm_token_string_t cmd_spickle_params2_arg1 =
726 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params2_result, arg1, str_spickle_params2_arg1);
727 parse_pgm_token_num_t cmd_spickle_params2_arg2 =
728 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params2_result, arg2, INT32);
729 parse_pgm_token_num_t cmd_spickle_params2_arg3 =
730 TOKEN_NUM_INITIALIZER(struct cmd_spickle_params2_result, arg3, INT32);
732 prog_char help_spickle_params2[] = "Set spickle_params2 values";
733 parse_pgm_inst_t cmd_spickle_params2 = {
734 .f = cmd_spickle_params2_parsed, /* function to call */
735 .data = NULL, /* 2nd arg of func */
736 .help_str = help_spickle_params2,
737 .tokens = { /* token list, NULL terminated */
738 (prog_void *)&cmd_spickle_params2_arg0,
739 (prog_void *)&cmd_spickle_params2_arg1,
740 (prog_void *)&cmd_spickle_params2_arg2,
741 (prog_void *)&cmd_spickle_params2_arg3,
746 prog_char str_spickle_params2_arg1_show[] = "show";
747 parse_pgm_token_string_t cmd_spickle_params2_arg1_show =
748 TOKEN_STRING_INITIALIZER(struct cmd_spickle_params2_result, arg1, str_spickle_params2_arg1_show);
750 prog_char help_spickle_params2_show[] = "show spickle params";
751 parse_pgm_inst_t cmd_spickle_params2_show = {
752 .f = cmd_spickle_params2_parsed, /* function to call */
753 .data = NULL, /* 2nd arg of func */
754 .help_str = help_spickle_params2_show,
755 .tokens = { /* token list, NULL terminated */
756 (prog_void *)&cmd_spickle_params2_arg0,
757 (prog_void *)&cmd_spickle_params2_arg1_show,
762 /**********************************************************/
765 /* this structure is filled when cmd_test is parsed successfully */
766 struct cmd_test_result {
770 /* function called when cmd_test is parsed successfully */
771 static void cmd_test_parsed(__attribute__((unused)) void *parsed_result,
772 __attribute__((unused)) void *data)
776 prog_char str_test_arg0[] = "test";
777 parse_pgm_token_string_t cmd_test_arg0 =
778 TOKEN_STRING_INITIALIZER(struct cmd_test_result, arg0, str_test_arg0);
780 prog_char help_test[] = "Test function";
781 parse_pgm_inst_t cmd_test = {
782 .f = cmd_test_parsed, /* function to call */
783 .data = NULL, /* 2nd arg of func */
784 .help_str = help_test,
785 .tokens = { /* token list, NULL terminated */
786 (prog_void *)&cmd_test_arg0,