X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fkernel%2Fao_sample.c;h=874c91100a665ca1f0ec3680e4392ede174e9acc;hb=db449c108431cb45bcc572b3a9f6c8b945695e16;hp=a7f5006590264a0a6d1e6dd348c87fb18e2136d7;hpb=d55d7c56b81dba7043857a763d0749e93cf7823a;p=fw%2Faltos diff --git a/src/kernel/ao_sample.c b/src/kernel/ao_sample.c index a7f50065..874c9110 100644 --- a/src/kernel/ao_sample.c +++ b/src/kernel/ao_sample.c @@ -57,6 +57,9 @@ angle_t ao_sample_orient; angle_t ao_sample_orients[AO_NUM_ORIENT]; uint8_t ao_sample_orient_pos; #endif +#ifdef HAS_MOTOR_PRESSURE +motor_pressure_t ao_sample_motor_pressure; +#endif uint8_t ao_sample_data; @@ -87,6 +90,10 @@ int32_t ao_ground_yaw; int32_t ao_ground_roll; #endif +#if HAS_MOTOR_PRESSURE +motor_pressure_t ao_ground_motor_pressure; +#endif + static uint8_t ao_preflight; /* in preflight mode */ static uint16_t nsamples; @@ -107,6 +114,9 @@ int32_t ao_sample_yaw_sum; int32_t ao_sample_roll_sum; static struct ao_quaternion ao_rotation; #endif +#if HAS_MOTOR_PRESSURE +int32_t ao_sample_motor_pressure_sum; +#endif #if HAS_FLIGHT_DEBUG extern uint8_t ao_orient_test; @@ -130,6 +140,9 @@ ao_sample_preflight_add(void) ao_sample_pitch_sum += ao_sample_pitch; ao_sample_yaw_sum += ao_sample_yaw; ao_sample_roll_sum += ao_sample_roll; +#endif +#if HAS_MOTOR_PRESSURE + ao_sample_motor_pressure_sum += ao_sample_motor_pressure; #endif ++nsamples; } @@ -199,6 +212,9 @@ ao_sample_preflight_set(void) ao_ground_accel_through = ao_sample_accel_through_sum >> 9; #endif +#if HAS_MOTOR_PRESSURE + ao_ground_motor_pressure = ao_sample_motor_pressure_sum >> 9; +#endif #if HAS_GYRO ao_ground_pitch = ao_sample_pitch_sum; ao_ground_yaw = ao_sample_yaw_sum; @@ -323,7 +339,7 @@ ao_sample_preflight_update(void) else ao_sample_preflight_set(); #if !HAS_BARO - if ((nsamples & 0x7f) == 0) + if ((nsamples & 0x3f) == 0) ao_kalman_reset_accumulate(); #endif } @@ -379,6 +395,9 @@ ao_sample(void) ao_sample_yaw = ao_data_yaw(ao_data); ao_sample_roll = ao_data_roll(ao_data); #endif +#if HAS_MOTOR_PRESSURE + ao_sample_motor_pressure = ao_data_motor_pressure(ao_data); +#endif if (ao_preflight) ao_sample_preflight();