altos: Use 32-bits for flight state data (alt/speed/accel)
[fw/altos] / src / test / ao_flight_test.c
index 1ee3ad2756fd9d79cf0d8ea28c656be5f3f2ba15..bb5c3a7d86d7618938e05d8795b5f7ef684eca79 100644 (file)
 #define ao_data_ring_next(n)   (((n) + 1) & (AO_DATA_RING - 1))
 #define ao_data_ring_prev(n)   (((n) - 1) & (AO_DATA_RING - 1))
 
+#if 0
 #define AO_M_TO_HEIGHT(m)      ((int16_t) (m))
 #define AO_MS_TO_SPEED(ms)     ((int16_t) ((ms) * 16))
 #define AO_MSS_TO_ACCEL(mss)   ((int16_t) ((mss) * 16))
+#endif
 
 #define AO_GPS_NEW_DATA                1
 #define AO_GPS_NEW_TRACKING    2
@@ -49,13 +51,13 @@ int ao_gps_new;
 #define HAS_MPU6000            1
 #define HAS_MMA655X            1
 #define HAS_HMC5883            1
+#define HAS_BEEP               1
+#define AO_CONFIG_MAX_SIZE     1024
 
 struct ao_adc {
        int16_t                 sense[AO_ADC_NUM_SENSE];
        int16_t                 v_batt;
        int16_t                 v_pbatt;
-       int16_t                 accel_ref;
-       int16_t                 accel;
        int16_t                 temp;
 };
 #else
@@ -93,6 +95,7 @@ struct ao_adc {
 #include <ao_data.h>
 #include <ao_log.h>
 #include <ao_telemetry.h>
+#include <ao_sample.h>
 
 #if TELEMEGA
 int ao_gps_count;
@@ -175,7 +178,7 @@ ao_gps_angle(void)
                        ao_gps_static.latitude / 1e7,
                        ao_gps_static.longitude / 1e7,
                        &dist, &bearing);
-       height = ao_gps_static.altitude - ao_gps_prev.altitude;
+       height = AO_TELEMETRY_LOCATION_ALTITUDE(&ao_gps_static) - AO_TELEMETRY_LOCATION_ALTITUDE(&ao_gps_prev);
 
        angle = atan2(dist, height);
        return angle * 180/M_PI;
@@ -234,7 +237,7 @@ double      main_time;
 
 int    tick_offset;
 
-static int32_t ao_k_height;
+static ao_k_t  ao_k_height;
 
 int16_t
 ao_time(void)
@@ -317,22 +320,8 @@ struct ao_ms5607_prom      ao_ms5607_prom;
 #include "ao_convert.c"
 #endif
 
-struct ao_config {
-       uint16_t        main_deploy;
-       int16_t         accel_plus_g;
-       int16_t         accel_minus_g;
-       uint8_t         pad_orientation;
-       uint16_t        apogee_lockout;
-#if TELEMEGA
-       struct ao_pyro  pyro[AO_PYRO_NUM];      /* minor version 12 */
-       int16_t         accel_zero_along;
-       int16_t         accel_zero_across;
-       int16_t         accel_zero_through;
-#endif
-};
-
-#define AO_PAD_ORIENTATION_ANTENNA_UP  0
-#define AO_PAD_ORIENTATION_ANTENNA_DOWN        1
+#include <ao_config.h>
+#include <ao_fake_flight.h>
 
 #define ao_config_get()
 
@@ -770,7 +759,10 @@ ao_sleep(void *wchan)
                                        ao_gps_static.tick = tick;
                                        ao_gps_static.latitude = int32(bytes, 0);
                                        ao_gps_static.longitude = int32(bytes, 4);
-                                       ao_gps_static.altitude = int32(bytes, 8);
+                                       {
+                                               int32_t altitude = int32(bytes, 8);
+                                               AO_TELEMETRY_LOCATION_SET_ALTITUDE(&ao_gps_static, altitude);
+                                       }
                                        ao_gps_static.flags = bytes[13];
                                        if (!ao_gps_count)
                                                ao_gps_first = ao_gps_static;
@@ -810,6 +802,7 @@ ao_sleep(void *wchan)
                                        pyro->flags |= ao_pyro_values[j].flag;
                                        if (ao_pyro_values[j].offset != NO_VALUE && i + 1 < nword) {
                                                int16_t val = strtoul(words[++i], NULL, 10);
+                                               printf("pyro %d condition %s value %d\n", p, words[i-1], val);
                                                *((int16_t *) ((char *) pyro + ao_pyro_values[j].offset)) = val;
                                        }
                                }
@@ -1003,6 +996,7 @@ void run_flight_fixed(char *name, FILE *f, int summary, char *info)
        emulator_in = f;
        emulator_info = info;
        ao_summary = summary;
+
        ao_flight_init();
        ao_flight();
 }