X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fkernel%2Fao_tracker.c;h=1454c17c31815aadd08c9d060f10a81cacf78711;hb=HEAD;hp=f79bd18ae957d4e1d1516c6e1971a1a208e66be0;hpb=c417ab1de2a083b5fcff2e081e4feb2a65887903;p=fw%2Faltos diff --git a/src/kernel/ao_tracker.c b/src/kernel/ao_tracker.c index f79bd18a..e45653a6 100644 --- a/src/kernel/ao_tracker.c +++ b/src/kernel/ao_tracker.c @@ -30,7 +30,7 @@ static uint8_t ao_tracker_force_telem; static inline uint8_t ao_usb_connected(void) { - return ao_gpio_get(AO_USB_CONNECT_PORT, AO_USB_CONNECT_PIN, AO_USB_CONNECT) != 0; + return ao_gpio_get(AO_USB_CONNECT_PORT, AO_USB_CONNECT_PIN) != 0; } #else #define ao_usb_connected() 1 @@ -55,15 +55,15 @@ static uint8_t tracker_mutex; static uint8_t log_started; static struct ao_telemetry_location gps_data; static uint8_t tracker_running; -static uint16_t tracker_interval; +static uint8_t tracker_interval; static void ao_tracker(void) { uint8_t new; - int32_t ground_distance; - int16_t height; - uint16_t gps_tick; + uint32_t ground_distance; + gps_alt_t height; + AO_TICK_TYPE gps_tick; uint8_t new_tracker_running; #if HAS_ADC @@ -134,8 +134,8 @@ ao_tracker(void) height = -height; if (ao_tracker_force_telem > 1) - printf("head %d ring %d ground_distance %d height %d\n", gps_head, ring, ground_distance, height); - if (ground_distance > ao_config.tracker_motion || + printf("head %d ring %d ground_distance %lu height %ld\n", gps_head, ring, (long) ground_distance, height); + if (ground_distance > (uint32_t) ao_config.tracker_motion || height > (ao_config.tracker_motion << 1)) { moving = 1; @@ -186,9 +186,9 @@ ao_gps_lock(void) static uint8_t erasing_current; void -ao_tracker_erase_start(uint16_t flight) +ao_tracker_erase_start(int32_t flight) { - erasing_current = flight == ao_flight_number; + erasing_current = flight == (int32_t) ao_flight_number; if (erasing_current) { ao_mutex_get(&tracker_mutex); ao_log_stop(); @@ -211,9 +211,9 @@ static struct ao_task ao_tracker_task; static void ao_tracker_set_telem(void) { - uint16_t r = ao_cmd_hex(); + uint32_t r = ao_cmd_hex(); if (ao_cmd_status == ao_cmd_success) - ao_tracker_force_telem = r; + ao_tracker_force_telem = r != 0; ao_cmd_status = ao_cmd_success; printf ("flight: %d\n", ao_flight_number); printf ("force_telem: %d\n", ao_tracker_force_telem);