X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fkernel%2Fao_kalman.c;h=e4cc6d4b9f73676fbc93b750ececfad91b2ed332;hb=a3b4f0d33e9d13fb5294397304ec0eb44ecaf1fc;hp=82315c485de086b7f3b0cb64a462a878ac620119;hpb=ea6fe21d78744d7e6225a56c369d54f7cd956767;p=fw%2Faltos diff --git a/src/kernel/ao_kalman.c b/src/kernel/ao_kalman.c index 82315c48..e4cc6d4b 100644 --- a/src/kernel/ao_kalman.c +++ b/src/kernel/ao_kalman.c @@ -45,7 +45,13 @@ static __pdata ao_k_t ao_avg_height_scaled; __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; @@ -83,7 +89,9 @@ ao_kalman_predict(void) 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; @@ -91,6 +99,7 @@ ao_kalman_err_height(void) 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; @@ -98,6 +107,7 @@ ao_kalman_err_height(void) 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;