Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / src / kernel / ao_tracker.c
index 4abd309a99b1fa931c0f083f1e2e45606a0067c5..1454c17c31815aadd08c9d060f10a81cacf78711 100644 (file)
@@ -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
@@ -164,6 +164,25 @@ ao_tracker(void)
        }
 }
 
+#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
@@ -192,9 +211,9 @@ static struct ao_task ao_tracker_task;
 static void
 ao_tracker_set_telem(void)
 {
-       ao_cmd_hex();
+       uint16_t r = ao_cmd_hex();
        if (ao_cmd_status == ao_cmd_success)
-               ao_tracker_force_telem = ao_cmd_lex_i;
+               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);
@@ -222,4 +241,7 @@ ao_tracker_init(void)
 #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
 }