Don't re-initialize the landing range data at each apogee detect sample
authorKeith Packard <keithp@keithp.com>
Mon, 11 May 2009 06:01:16 +0000 (23:01 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 11 May 2009 06:01:16 +0000 (23:01 -0700)
The landing range values are used only after apogee detect, so we need only
initialize them on the transition from apogee to drogue.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao_flight.c

index 91953975203c830fa76814e1cd02fb35fc33a68b..3bc6b974008e625812214112838b8a5eb0669fe5 100644 (file)
@@ -347,26 +347,28 @@ ao_flight(void)
                                /* Enable RDF beacon */
                                ao_rdf_set(1);
 
                                /* Enable RDF beacon */
                                ao_rdf_set(1);
 
+                               /*
+                                * Start recording min/max accel and pres for a while
+                                * to figure out when the rocket has landed
+                                */
+                               /* Set the 'last' limits to max range to prevent
+                                * early resting detection
+                                */
+                               ao_interval_min_accel = 0;
+                               ao_interval_max_accel = 0x7fff;
+                               ao_interval_min_pres = 0;
+                               ao_interval_max_pres = 0x7fff;
+
+                               /* initialize interval values */
+                               ao_interval_end = ao_flight_tick + AO_INTERVAL_TICKS;
+
+                               ao_interval_cur_min_pres = ao_interval_cur_max_pres = ao_flight_pres;
+                               ao_interval_cur_min_accel = ao_interval_cur_max_accel = ao_flight_accel;
+
+                               /* and enter drogue state */
                                ao_flight_state = ao_flight_drogue;
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
                        }
                                ao_flight_state = ao_flight_drogue;
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
                        }
-                       /*
-                        * Start recording min/max accel and pres for a while
-                        * to figure out when the rocket has landed
-                        */
-                       /* Set the 'last' limits to max range to prevent
-                        * early resting detection
-                        */
-                       ao_interval_min_accel = 0;
-                       ao_interval_max_accel = 0x7fff;
-                       ao_interval_min_pres = 0;
-                       ao_interval_max_pres = 0x7fff;
-
-                       /* initialize interval values */
-                       ao_interval_end = ao_flight_tick + AO_INTERVAL_TICKS;
-
-                       ao_interval_cur_min_pres = ao_interval_cur_max_pres = ao_flight_pres;
-                       ao_interval_cur_min_accel = ao_interval_cur_max_accel = ao_flight_accel;
 
                        break;
                case ao_flight_drogue:
 
                        break;
                case ao_flight_drogue: