]> git.droids-corp.org - fpv.git/commitdiff
imuboard: add commands to dump gps or imu
authorOlivier Matz <zer0@droids-corp.org>
Thu, 18 Sep 2014 17:47:48 +0000 (19:47 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Thu, 18 Sep 2014 17:47:48 +0000 (19:47 +0200)
imuboard/commands.c

index 42d243f0a17690f76f49b76f815fa6a6b3904c3a..ab4132e67e9b8acd20f4475cd0fa980e39ca9771 100644 (file)
@@ -41,6 +41,8 @@
 #include "main.h"
 #include "cmdline.h"
 #include "eeprom_config.h"
+#include "gps_venus.h"
+#include "imu.h"
 
 /* commands_gen.c */
 extern const parse_inst_t PROGMEM cmd_reset;
@@ -253,6 +255,84 @@ const parse_inst_t PROGMEM cmd_eeprom_list = {
        },
 };
 
+/* ************* */
+
+struct cmd_gps_show_result {
+       fixed_string_t cmd;
+       fixed_string_t action;
+};
+
+static void cmd_gps_show_parsed(void *parsed_result,
+                               void *data)
+{
+       (void)parsed_result;
+       (void)data;
+
+       while (!cmdline_keypressed()) {
+               gps_log(1);
+       }
+}
+
+const char PROGMEM str_gps_show_gps[] = "gps";
+const parse_token_string_t PROGMEM cmd_gps_show_cmd =
+       TOKEN_STRING_INITIALIZER(struct cmd_gps_show_result, cmd,
+                                str_gps_show_gps);
+const char PROGMEM str_gps_show_show[] = "show";
+const parse_token_string_t PROGMEM cmd_gps_show_action =
+       TOKEN_STRING_INITIALIZER(struct cmd_gps_show_result, action,
+                                str_gps_show_show);
+
+const char PROGMEM help_gps_show[] = "show gps position";
+const parse_inst_t PROGMEM cmd_gps_show = {
+       .f = cmd_gps_show_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_gps_show,
+       .tokens = {        /* token show, NULL terminated */
+               (PGM_P)&cmd_gps_show_cmd,
+               (PGM_P)&cmd_gps_show_action,
+               NULL,
+       },
+};
+
+/* ************* */
+
+struct cmd_imu_show_result {
+       fixed_string_t cmd;
+       fixed_string_t action;
+};
+
+static void cmd_imu_show_parsed(void *parsed_result,
+                               void *data)
+{
+       (void)parsed_result;
+       (void)data;
+
+       while (!cmdline_keypressed()) {
+               imu_log(1);
+       }
+}
+
+const char PROGMEM str_imu_show_imu[] = "imu";
+const parse_token_string_t PROGMEM cmd_imu_show_cmd =
+       TOKEN_STRING_INITIALIZER(struct cmd_imu_show_result, cmd,
+                                str_imu_show_imu);
+const char PROGMEM str_imu_show_show[] = "show";
+const parse_token_string_t PROGMEM cmd_imu_show_action =
+       TOKEN_STRING_INITIALIZER(struct cmd_imu_show_result, action,
+                                str_imu_show_show);
+
+const char PROGMEM help_imu_show[] = "show imu position";
+const parse_inst_t PROGMEM cmd_imu_show = {
+       .f = cmd_imu_show_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_imu_show,
+       .tokens = {        /* token show, NULL terminated */
+               (PGM_P)&cmd_imu_show_cmd,
+               (PGM_P)&cmd_imu_show_action,
+               NULL,
+       },
+};
+
 
 /* ************* */
 
@@ -272,5 +352,7 @@ const parse_ctx_t PROGMEM main_ctx[] = {
        &cmd_eeprom_add,
        &cmd_eeprom_add2,
        &cmd_eeprom_list,
+       &cmd_gps_show,
+       &cmd_imu_show,
        NULL,
 };