From: Keith Packard Date: Sat, 17 Oct 2020 03:48:55 +0000 (-0700) Subject: altos: Reset 3d-accel and motor pressure sums each ground interval X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=577918f429050f61e2e7d220d68a4a2bd52ad56e altos: Reset 3d-accel and motor pressure sums each ground interval We're repeatedly averaging 512 ground samples to get up-to-date values for all of the sensors, but we need to clear the sums after each sample interval. The 3d accel values were only cleared if there was a full IMU, not for devices with only an accelerometer like EasyMotor. The motor pressure sum was never cleared. Signed-off-by: Keith Packard --- diff --git a/src/kernel/ao_sample.c b/src/kernel/ao_sample.c index 874c9110..2c77c369 100644 --- a/src/kernel/ao_sample.c +++ b/src/kernel/ao_sample.c @@ -210,18 +210,18 @@ ao_sample_preflight_set(void) ao_ground_accel_along = ao_sample_accel_along_sum >> 9; ao_ground_accel_across = ao_sample_accel_across_sum >> 9; ao_ground_accel_through = ao_sample_accel_through_sum >> 9; - + ao_sample_accel_along_sum = 0; + ao_sample_accel_across_sum = 0; + ao_sample_accel_through_sum = 0; #endif #if HAS_MOTOR_PRESSURE ao_ground_motor_pressure = ao_sample_motor_pressure_sum >> 9; + ao_sample_motor_pressure_sum = 0; #endif #if HAS_GYRO ao_ground_pitch = ao_sample_pitch_sum; ao_ground_yaw = ao_sample_yaw_sum; ao_ground_roll = ao_sample_roll_sum; - ao_sample_accel_along_sum = 0; - ao_sample_accel_across_sum = 0; - ao_sample_accel_through_sum = 0; ao_sample_pitch_sum = 0; ao_sample_yaw_sum = 0; ao_sample_roll_sum = 0; @@ -257,7 +257,7 @@ ao_sample_preflight_set(void) (ao_ground_accel_across - ao_config.accel_zero_across), (ao_ground_accel_through - ao_config.accel_zero_through), (ao_ground_accel_along - ao_config.accel_zero_along)); -#endif +#endif ao_sample_compute_orient(); ao_sample_set_all_orients();