#include "strat_corn.h"
#include "i2c_protocol.h"
#include "actuator.h"
-#include "beacon.h"
struct cmd_event_result {
fixed_string_t arg0;
};
/**********************************************************/
-/* Beacon tests */
+/* Beacon_Start */
-/* this structure is filled when cmd_beacon is parsed successfully */
-struct cmd_beacon_result {
+/* this structure is filled when cmd_beacon_start is parsed successfully */
+struct cmd_beacon_start_result {
fixed_string_t arg0;
fixed_string_t arg1;
};
-/* function called when cmd_beacon is parsed successfully */
-static void cmd_beacon_parsed(void *parsed_result, void *data)
+/* function called when cmd_beacon_start is parsed successfully */
+static void cmd_beacon_start_parsed(void *parsed_result, void *data)
{
- int16_t x, y;
- double a;
+ struct cmd_beacon_start_result *res = parsed_result;
- if (beacon_get_pos(&x, &y, &a) < 0)
- printf_P(PSTR("No position from beacon\r\n"));
+ if (!strcmp_P(res->arg1, PSTR("start")))
+ i2c_ballboard_set_beacon(1);
else
- printf_P(PSTR("x=%d y=%d a=%2.2f\r\n"), x, y, a);
+ i2c_ballboard_set_beacon(0);
}
-prog_char str_beacon_arg0[] = "beacon";
-parse_pgm_token_string_t cmd_beacon_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_beacon_result, arg0, str_beacon_arg0);
-prog_char str_beacon_arg1[] = "show";
-parse_pgm_token_string_t cmd_beacon_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_beacon_result, arg1, str_beacon_arg1);
+prog_char str_beacon_start_arg0[] = "beacon";
+parse_pgm_token_string_t cmd_beacon_start_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_beacon_start_result, arg0, str_beacon_start_arg0);
+prog_char str_beacon_start_arg1[] = "start#stop";
+parse_pgm_token_string_t cmd_beacon_start_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_beacon_start_result, arg1, str_beacon_start_arg1);
-prog_char help_beacon[] = "Show (x,y) beacon";
-parse_pgm_inst_t cmd_beacon = {
- .f = cmd_beacon_parsed, /* function to call */
+prog_char help_beacon_start[] = "Beacon enabled/disable";
+parse_pgm_inst_t cmd_beacon_start = {
+ .f = cmd_beacon_start_parsed, /* function to call */
.data = NULL, /* 2nd arg of func */
- .help_str = help_beacon,
+ .help_str = help_beacon_start,
.tokens = { /* token list, NULL terminated */
- (prog_void *)&cmd_beacon_arg0,
- (prog_void *)&cmd_beacon_arg1,
+ (prog_void *)&cmd_beacon_start_arg0,
+ (prog_void *)&cmd_beacon_start_arg1,
NULL,
},
};
mainboard.our_color = I2C_COLOR_YELLOW;
i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_YELLOW);
i2c_set_color(I2C_BALLBOARD_ADDR, I2C_COLOR_YELLOW);
- beacon_set_color(I2C_COLOR_YELLOW);
}
else if (!strcmp_P(res->color, PSTR("blue"))) {
mainboard.our_color = I2C_COLOR_BLUE;
i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_BLUE);
i2c_set_color(I2C_BALLBOARD_ADDR, I2C_COLOR_BLUE);
- beacon_set_color(I2C_COLOR_BLUE);
}
+ printf_P(PSTR("Press a key when beacon ready\r\n"));
+ i2c_ballboard_set_beacon(0);
+ while(!cmdline_keypressed());
+ i2c_ballboard_set_beacon(1);
+
strat_start();
gen.logs[NB_LOGS] = 0;
mainboard.our_color = I2C_COLOR_YELLOW;
i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_YELLOW);
i2c_set_color(I2C_BALLBOARD_ADDR, I2C_COLOR_YELLOW);
- beacon_set_color(I2C_COLOR_YELLOW);
}
else if (!strcmp_P(res->color, PSTR("blue"))) {
mainboard.our_color = I2C_COLOR_BLUE;
i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_BLUE);
i2c_set_color(I2C_BALLBOARD_ADDR, I2C_COLOR_BLUE);
- beacon_set_color(I2C_COLOR_BLUE);
}
printf_P(PSTR("Done\r\n"));
#endif