*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
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
uint8_t new;
int32_t ground_distance;
int16_t height;
- uint16_t gps_tick;
+ AO_TICK_TYPE gps_tick;
uint8_t new_tracker_running;
#if HAS_ADC
#if !HAS_USB_CONNECT
ao_tracker_force_telem = 1;
#endif
- ao_log_scan();
+ log_started = ao_log_scan();
ao_rdf_set(1);
if (height < 0)
height = -height;
- if (ao_tracker_force_telem)
- printf("head %d ring %d ground_distance %d height %d\n", gps_head, ring, ground_distance, height);
+ if (ao_tracker_force_telem > 1)
+ printf("head %d ring %d ground_distance %ld height %d\n", gps_head, ring, (long) ground_distance, height);
if (ground_distance > ao_config.tracker_motion ||
height > (ao_config.tracker_motion << 1))
{
break;
}
}
- if (ao_tracker_force_telem) {
+ if (ao_tracker_force_telem > 1) {
printf ("moving %d started %d\n", moving, log_started);
flush();
}
}
}
+#ifdef AO_LED_GPS_LOCK
+
+static struct ao_task ao_gps_lock_task;
+
+static void
+ao_gps_lock(void)
+{
+ for (;;) {
+ if ((gps_data.flags & (AO_GPS_VALID|AO_GPS_COURSE_VALID)) ==
+ (AO_GPS_VALID|AO_GPS_COURSE_VALID))
+ {
+ ao_led_for(AO_LED_GPS_LOCK, AO_MS_TO_TICKS(20));
+ }
+ ao_delay(AO_SEC_TO_TICKS(3));
+ }
+}
+#endif
+
+
static uint8_t erasing_current;
void
ao_tracker_erase_end(void)
{
if (erasing_current) {
- ao_log_scan();
- log_started = 0;
+ log_started = ao_log_scan();
ao_mutex_put(&tracker_mutex);
}
}
static void
ao_tracker_set_telem(void)
{
- uint8_t telem;
- ao_cmd_hex();
- telem = ao_cmd_lex_i;
+ uint16_t r = ao_cmd_hex();
if (ao_cmd_status == ao_cmd_success)
- ao_tracker_force_telem = telem;
+ ao_tracker_force_telem = r;
ao_cmd_status = ao_cmd_success;
printf ("flight: %d\n", ao_flight_number);
printf ("force_telem: %d\n", ao_tracker_force_telem);
}
static const struct ao_cmds ao_tracker_cmds[] = {
- { ao_tracker_set_telem, "t <d>\0Set telem on USB" },
+ { ao_tracker_set_telem, "t <d>\0Set telem on USB (0 off, 1 on, 2 dbg)" },
{ 0, NULL },
};
#endif
ao_cmd_register(&ao_tracker_cmds[0]);
ao_add_task(&ao_tracker_task, ao_tracker, "tracker");
+#ifdef AO_LED_GPS_LOCK
+ ao_add_task(&ao_gps_lock_task, ao_gps_lock, "gps lock");
+#endif
}