altos: Use computed height for avg_height when baro is missing
authorKeith Packard <keithp@keithp.com>
Thu, 9 Apr 2020 00:23:48 +0000 (17:23 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 9 Apr 2020 00:25:33 +0000 (17:25 -0700)
EasyTimer doesn't have a barometer.

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

index 8cb6ff61fd403c305ca7a6c2dc0f513f07a0c162..aaf0595f01ab7d5e345ab5997983386f78bd4c1e 100644 (file)
@@ -41,10 +41,8 @@ ao_v_t                       ao_height;
 ao_v_t                 ao_speed;
 ao_v_t                 ao_accel;
 ao_v_t                 ao_max_height;
-#if HAS_BARO
 static ao_k_t          ao_avg_height_scaled;
 ao_v_t                 ao_avg_height;
-#endif
 
 ao_v_t                 ao_error_h;
 #if !HAS_ACCEL || AO_FLIGHT_TEST
@@ -304,6 +302,9 @@ ao_kalman(void)
                ao_max_height = ao_height;
 #if HAS_BARO
        ao_avg_height_scaled = ao_avg_height_scaled - ao_avg_height + ao_sample_height;
+#else
+       ao_avg_height_scaled = ao_avg_height_scaled - ao_avg_height + ao_height;
+#endif
 #ifdef AO_FLIGHT_TEST
        if ((int16_t) (ao_sample_tick - ao_sample_prev_tick) > 50)
                ao_avg_height = (ao_avg_height_scaled + 1) >> 1;
@@ -312,5 +313,4 @@ ao_kalman(void)
        else 
 #endif
                ao_avg_height = (ao_avg_height_scaled + 63) >> 7;
-#endif
 }