first cut at turnon scripts for EasyTimer v2
[fw/altos] / ao-tools / lib / cc-process.c
index 5c1acc6bd203384028b737596a4545d4860a72c7..f2307a8207818436391dd6560f18699424d4aba5 100644 (file)
@@ -3,7 +3,8 @@
  *
  * 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
@@ -45,8 +46,8 @@ struct cc_flightcooked *
 cc_flight_cook(struct cc_flightraw *raw)
 {
        struct cc_flightcooked *cooked;
-       double                  flight_start;
-       double                  flight_stop;
+       double                  flight_start = 0;
+       double                  flight_stop = 0;
        int                     start_set = 0;
        int                     stop_set = 0;
        int                     i;
@@ -70,7 +71,7 @@ cc_flight_cook(struct cc_flightraw *raw)
         */
        for (i = 0; i < raw->state.num; i++) {
                if (!start_set && raw->state.data[i].value > ao_flight_pad) {
-                       flight_start = raw->state.data[i].time;
+                       flight_start = raw->state.data[i].time - 10;
                        start_set = 1;
                }
                if (!stop_set && raw->state.data[i].value > ao_flight_main) {
@@ -79,7 +80,7 @@ cc_flight_cook(struct cc_flightraw *raw)
                }
        }
 
-       if (!start_set)
+       if (!start_set || flight_start < raw->accel.data[0].time)
                flight_start = raw->accel.data[0].time;
        if (stop_set) {
                for (i = 0; i < raw->accel.num - 1; i++) {
@@ -101,8 +102,8 @@ cc_flight_cook(struct cc_flightraw *raw)
        accel_speed = cc_timedata_integrate(&cooked->accel, flight_start - 10, flight_stop);
        accel_pos = cc_timedata_integrate(accel_speed, flight_start - 10, flight_stop);
 
-#define ACCEL_OMEGA_PASS       (2 * M_PI * 5 / 100)
-#define ACCEL_OMEGA_STOP       (2 * M_PI * 8 / 100)
+#define ACCEL_OMEGA_PASS       (2 * M_PI * 20 / 100)
+#define ACCEL_OMEGA_STOP       (2 * M_PI * 30 / 100)
 #define BARO_OMEGA_PASS                (2 * M_PI * .5 / 100)
 #define BARO_OMEGA_STOP                (2 * M_PI * 1 / 100)
 #define FILTER_ERROR           (1e-8)