From: Olivier Matz Date: Thu, 24 Jul 2014 16:16:43 +0000 (+0200) Subject: beep when GPS ready X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=HEAD;p=protos%2Fxbee-avr.git beep when GPS ready --- diff --git a/commands.c b/commands.c index 9f7eaf6..d67b651 100644 --- a/commands.c +++ b/commands.c @@ -2271,7 +2271,7 @@ static void cmd_dump_i2c_parsed(void *parsed_result, void *data) imu.latitude, imu.longitude, imu.altitude); } else - printf_P(PSTR("GPS unavailable")); + printf_P(PSTR("GPS unavailable\n")); i2c_protocol_debug(); wait_ms(100); } diff --git a/i2c_protocol.c b/i2c_protocol.c index 6b667b4..ca4c49c 100644 --- a/i2c_protocol.c +++ b/i2c_protocol.c @@ -30,8 +30,9 @@ #include #include "../fpv-common/i2c_commands.h" -#include "main.h" #include "i2c_protocol.h" +#include "beep.h" +#include "main.h" #define I2C_STATE_MAX 2 #define I2C_PERIOD_MS 50 @@ -41,8 +42,12 @@ static volatile uint8_t i2c_poll_num = 0; static volatile uint8_t i2c_state = 0; +static volatile uint8_t i2c_rx_count = 0; +static volatile uint8_t i2c_tx_count = 0; static volatile uint16_t i2c_errors = 0; +static uint8_t gps_ok = 0; + #define OP_READY 0 /* no i2c op running */ #define OP_POLL 1 /* a user command is running */ #define OP_CMD 2 /* a polling (req / ans) is running */ @@ -80,6 +85,8 @@ volatile uint8_t command_size=0; void i2c_protocol_debug(void) { printf_P(PSTR("I2C protocol debug infos:\r\n")); + printf_P(PSTR(" i2c_send=%d\r\n"), i2c_tx_count); + printf_P(PSTR(" i2c_recv=%d\r\n"), i2c_rx_count); printf_P(PSTR(" i2c_state=%d\r\n"), i2c_state); printf_P(PSTR(" i2c_errors=%d\r\n"), i2c_errors); printf_P(PSTR(" running_op=%d\r\n"), running_op); @@ -198,6 +205,7 @@ void i2c_sendevent(int8_t size) } else command_size = 0; + i2c_tx_count++; } else { i2c_errors++; @@ -230,6 +238,8 @@ void i2c_recvevent(uint8_t * buf, int8_t size) goto error; } + i2c_rx_count++; + switch (buf[0]) { case I2C_ANS_IMUBOARD_STATUS: { @@ -242,6 +252,13 @@ void i2c_recvevent(uint8_t * buf, int8_t size) /* copy status in a global struct */ memcpy(&imuboard_status, ans, sizeof(imuboard_status)); + if (gps_ok == 0 && + (imuboard_status.flags & IMUBOARD_STATUS_GPS_OK)) { + gps_ok = 1; + beep(0, 1, 1); + beep(0, 1, 1); + } + break; }