X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=projects%2Fmicrob2010%2Ftests%2Fbeacon_tsop%2Fcommands.c;h=7b489fd31159289ad4311bdc961357d68344972b;hb=4872fe91ffcc459a56e45cb213eec2a8660075e1;hp=e938a73f1e41370272e4bd312e4db5107f80a3e6;hpb=dccae820e0f5c68a3a9c496b63eb8d02102d6ebc;p=aversive.git diff --git a/projects/microb2010/tests/beacon_tsop/commands.c b/projects/microb2010/tests/beacon_tsop/commands.c index e938a73..7b489fd 100644 --- a/projects/microb2010/tests/beacon_tsop/commands.c +++ b/projects/microb2010/tests/beacon_tsop/commands.c @@ -32,7 +32,11 @@ #include #include #include +#include +#include +#include +#include "trigo.h" #include "main.h" /**********************************************************/ @@ -147,6 +151,61 @@ parse_pgm_inst_t cmd_debug_speed = { }; /**********************************************************/ +/* Test */ + +/* this structure is filled when cmd_test is parsed successfully */ +struct cmd_test_result { + fixed_string_t arg0; +}; + +/* function called when cmd_test is parsed successfully */ +static void cmd_test_parsed(__attribute__((unused)) void *parsed_result, + __attribute__((unused)) void *data) +{ + point_t pos; + double a01 = 1.65; + double a12 = 2.12; + double a20 = 2.53; + uint16_t time1, time2; + + cli(); + time1 = TCNT3; + sei(); + + if (angles_to_posxy(&pos, a01, a12, a20) < 0) + printf_P(PSTR("error\n")); + + cli(); + time2 = TCNT3; + sei(); + + printf_P(PSTR("%2.2f %2.2f (t=%d)\n"), pos.x, pos.y, time2-time1); +} + +prog_char str_test_arg0[] = "test"; +parse_pgm_token_string_t cmd_test_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_test_result, arg0, str_test_arg0); + +prog_char help_test[] = "Test the board"; +parse_pgm_inst_t cmd_test = { + .f = cmd_test_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = help_test, + .tokens = { /* token list, NULL terminated */ + (prog_void *)&cmd_test_arg0, + NULL, + }, +}; + +/**********************************************************/ + +extern parse_pgm_inst_t cmd_gain; +extern parse_pgm_inst_t cmd_gain_show; +extern parse_pgm_inst_t cmd_derivate_filter; +extern parse_pgm_inst_t cmd_derivate_filter_show; +extern parse_pgm_inst_t cmd_maximum; +extern parse_pgm_inst_t cmd_maximum_show; +extern parse_pgm_inst_t cmd_consign; +extern parse_pgm_inst_t cmd_consign_show; /* in progmem */ parse_pgm_ctx_t main_ctx[] = { @@ -155,5 +214,16 @@ parse_pgm_ctx_t main_ctx[] = { (parse_pgm_inst_t *)&cmd_reset, (parse_pgm_inst_t *)&cmd_debug_frame, (parse_pgm_inst_t *)&cmd_debug_speed, + (parse_pgm_inst_t *)&cmd_test, + + (parse_pgm_inst_t *)&cmd_gain, + (parse_pgm_inst_t *)&cmd_gain_show, + (parse_pgm_inst_t *)&cmd_derivate_filter, + (parse_pgm_inst_t *)&cmd_derivate_filter_show, + (parse_pgm_inst_t *)&cmd_maximum, + (parse_pgm_inst_t *)&cmd_maximum_show, + (parse_pgm_inst_t *)&cmd_consign, + (parse_pgm_inst_t *)&cmd_consign_show, + NULL, };