__xdata ao_v_t ao_avg_height;
__pdata ao_v_t ao_error_h;
+#if !HAS_ACCEL || AO_FLIGHT_TEST
+#define AO_ERROR_H_SQ_AVG 1
+#endif
+
+#if AO_ERROR_H_SQ_AVG
__pdata ao_v_t ao_error_h_sq_avg;
+#endif
#if HAS_ACCEL
__pdata ao_v_t ao_error_a;
static void
ao_kalman_err_height(void)
{
+#if AO_ERROR_H_SQ_AVG
ao_v_t e;
+#endif
ao_v_t height_distrust;
#if HAS_ACCEL
ao_v_t speed_distrust;
ao_error_h = ao_sample_height - (ao_v_t) (ao_k_height >> 16);
+#if AO_ERROR_H_SQ_AVG
e = ao_error_h;
if (e < 0)
e = -e;
e = 127;
ao_error_h_sq_avg -= ao_error_h_sq_avg >> 4;
ao_error_h_sq_avg += (e * e) >> 4;
+#endif
if (ao_flight_state >= ao_flight_drogue)
return;