altos: Remove unused accel_vel_mach and accel_vel_boost variables
[fw/altos] / src / ao_flight.c
index f57573d0547b15baf2e804441837dc122db03ab3..5567d87fdd4649eb041564ea18f30271339f2c63 100644 (file)
@@ -50,6 +50,8 @@ __data uint8_t ao_flight_adc;
 __pdata int16_t ao_raw_accel, ao_raw_accel_prev, ao_raw_pres;
 __pdata int16_t ao_accel_2g;
 
+__xdata uint8_t ao_flight_force_idle;
+
 /* Accelerometer calibration
  *
  * We're sampling the accelerometer through a resistor divider which
@@ -82,9 +84,6 @@ __pdata int16_t ao_accel_2g;
 #define ACCEL_VEL_MACH VEL_MPS_TO_COUNT(200)
 #define ACCEL_VEL_BOOST        VEL_MPS_TO_COUNT(5)
 
-int32_t accel_vel_mach;
-int32_t accel_vel_boost;
-
 /*
  * Barometer calibration
  *
@@ -212,8 +211,6 @@ ao_flight(void)
                        ao_config_get();
                        ao_main_pres = ao_altitude_to_pres(ao_pres_to_altitude(ao_ground_pres) + ao_config.main_deploy);
                        ao_accel_2g = ao_config.accel_minus_g - ao_config.accel_plus_g;
-                       accel_vel_mach = ACCEL_VEL_MACH;
-                       accel_vel_boost = ACCEL_VEL_BOOST;
                        ao_flight_vel = 0;
                        ao_min_vel = 0;
                        ao_old_vel = ao_flight_vel;
@@ -221,8 +218,10 @@ ao_flight(void)
 
                        /* Go to pad state if the nose is pointing up */
                        ao_config_get();
-                       if (ao_config.accel_plus_g != 0 && ao_config.accel_minus_g != 0 &&
-                           ao_flight_accel < ao_config.accel_plus_g + ACCEL_NOSE_UP)
+                       if (ao_config.accel_plus_g != 0 &&
+                           ao_config.accel_minus_g != 0 &&
+                           ao_flight_accel < ao_config.accel_plus_g + ACCEL_NOSE_UP &&
+                           !ao_flight_force_idle)
                        {
                                /* Disable the USB controller in flight mode
                                 * to save power
@@ -285,6 +284,10 @@ ao_flight(void)
                                /* disable RDF beacon */
                                ao_rdf_set(0);
 
+                               /* Record current GPS position by waking up GPS log tasks */
+                               ao_wakeup(&ao_gps_data);
+                               ao_wakeup(&ao_gps_tracking_data);
+
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
                                break;
                        }