add code to control the audio buzzer
[protos/xbee-avr.git] / commands.c
index c9d415f..b58594a 100644 (file)
@@ -51,6 +51,7 @@
 #include "rc_proto.h"
 #include "main.h"
 #include "cmdline.h"
+#include "beep.h"
 
 /* commands_gen.c */
 extern const parse_inst_t PROGMEM cmd_reset;
@@ -1299,6 +1300,45 @@ const parse_inst_t PROGMEM cmd_baudrate = {
        },
 };
 
+
+/**********************************************************/
+
+/* this structure is filled when cmd_beep is parsed successfully */
+struct cmd_beep_result {
+       fixed_string_t beep;
+};
+
+/* function called when cmd_beep is parsed successfully */
+static void cmd_beep_parsed(void *parsed_result, void *data)
+{
+       (void)parsed_result;
+       (void)data;
+
+       beep(0, 3, 3);
+       beep(1, 3, 3);
+       beep(2, 3, 3);
+       beep(0, 1, 1);
+       beep(1, 1, 1);
+       beep(2, 1, 1);
+}
+
+const char PROGMEM str_beep[] = "beep";
+const parse_token_string_t PROGMEM cmd_beep_beep =
+       TOKEN_STRING_INITIALIZER(struct cmd_beep_result, beep,
+                                str_beep);
+
+const char PROGMEM help_beep[] = "Send a beep";
+
+const parse_inst_t PROGMEM cmd_beep = {
+       .f = cmd_beep_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_beep,
+       .tokens = {        /* token list, NULL terminated */
+               (PGM_P)&cmd_beep_beep,
+               NULL,
+       },
+};
+
 /**********************************************************/
 
 /* this structure is filled when cmd_servo is parsed successfully */
@@ -1546,6 +1586,7 @@ const parse_ctx_t PROGMEM main_ctx[] = {
        &cmd_dump,
        &cmd_debug,
        &cmd_baudrate,
+       &cmd_beep,
        &cmd_servo_set,
        &cmd_servo_bypassppm,
        &cmd_servo_show,