altos: ao_sample_preflight was exiting preflight mode immediately
authorKeith Packard <keithp@keithp.com>
Tue, 29 Mar 2011 17:08:46 +0000 (10:08 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 29 Mar 2011 17:08:46 +0000 (10:08 -0700)
Need to stay in pre-flight mode until we've gotten enough sensor data
to calibrate things appropriately. The conversion from a unified
ao_flight.c file was just broken here.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao_sample.c

index ef403393cb6c276fbd81c38c46cbe4f559d3dd1a..84cf1e00b8f70aba0ddf42427b7195b8a8297981 100644 (file)
@@ -68,16 +68,17 @@ ao_sample_preflight(void)
 #endif
                ao_sample_pres_sum += ao_sample_pres;
                ++nsamples;
-               ao_preflight = FALSE;
-       }
-       ao_config_get();
+       } else {
+               ao_config_get();
 #if HAS_ACCEL
-       ao_ground_accel = ao_sample_accel_sum >> 9;
-       ao_accel_2g = ao_config.accel_minus_g - ao_config.accel_plus_g;
-       ao_accel_scale = to_fix32(GRAVITY * 2 * 16) / ao_accel_2g;
+               ao_ground_accel = ao_sample_accel_sum >> 9;
+               ao_accel_2g = ao_config.accel_minus_g - ao_config.accel_plus_g;
+               ao_accel_scale = to_fix32(GRAVITY * 2 * 16) / ao_accel_2g;
 #endif
-       ao_ground_pres = ao_sample_pres_sum >> 9;
-       ao_ground_height = ao_pres_to_altitude(ao_ground_pres);
+               ao_ground_pres = ao_sample_pres_sum >> 9;
+               ao_ground_height = ao_pres_to_altitude(ao_ground_pres);
+               ao_preflight = FALSE;
+       }
 }
 
 uint8_t