imuboard: remove references to xbee
[fpv.git] / imuboard / commands.c
index 42d243f..2d7b700 100644 (file)
 #include <parse_string.h>
 #include <parse_num.h>
 #include <uart.h>
-#include <xbee.h>
 #include <callout.h>
 
 #include "main.h"
 #include "cmdline.h"
 #include "eeprom_config.h"
+#include "gps.h"
+#include "imu.h"
 
 /* commands_gen.c */
 extern const parse_inst_t PROGMEM cmd_reset;
@@ -227,16 +228,20 @@ struct cmd_eeprom_list_result {
 static void cmd_eeprom_list_parsed(void *parsed_result,
                                void *data)
 {
-       (void)parsed_result;
+       struct cmd_eeprom_list_result *res = parsed_result;
+
        (void)data;
-       eeprom_dump_cmds();
+       if (!strcmp_P(PSTR("list"), res->cmd))
+               eeprom_dump_cmds();
+       else
+               eeprom_reset();
 }
 
 const char PROGMEM str_eeprom_list_eeprom[] = "eeprom";
 const parse_token_string_t PROGMEM cmd_eeprom_list_cmd =
        TOKEN_STRING_INITIALIZER(struct cmd_eeprom_list_result, cmd,
                                 str_eeprom_list_eeprom);
-const char PROGMEM str_eeprom_list_list[] = "list";
+const char PROGMEM str_eeprom_list_list[] = "list#reset";
 const parse_token_string_t PROGMEM cmd_eeprom_list_action =
        TOKEN_STRING_INITIALIZER(struct cmd_eeprom_list_result, action,
                                 str_eeprom_list_list);
@@ -253,6 +258,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 +355,7 @@ const parse_ctx_t PROGMEM main_ctx[] = {
        &cmd_eeprom_add,
        &cmd_eeprom_add2,
        &cmd_eeprom_list,
+       &cmd_gps_show,
+       &cmd_imu_show,
        NULL,
 };