Compute an average of ground motor pressure values and store those in
the log data in the AO_FLIGHT record.
Signed-off-by: Keith Packard <keithp@keithp.com>
#define AO_DATA_RING 64
struct ao_adc {
#define AO_DATA_RING 64
struct ao_adc {
+ int16_t motor_pressure;
int16_t v_batt;
};
#define AO_ADC_DUMP(p) \
int16_t v_batt;
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u pressure: %5d batt: %5d\n", \
+ printf("tick: %5u motor_pressure: %5d batt: %5d\n", \
+ (p)->adc.motor_pressure, \
#define HAS_IMU 1
#define USE_ADXL375_IMU 1
#define HAS_IMU 1
#define USE_ADXL375_IMU 1
+/* Motor pressure */
+#define HAS_MOTOR_PRESSURE 1
+#define ao_data_motor_pressure(packet) ((packet)->adc.motor_pressure)
+
+typedef int16_t motor_pressure_t;
+
int16_t ground_accel_along; /* 8 */
int16_t ground_accel_across; /* 10 */
int16_t ground_accel_through; /* 12 */
int16_t ground_accel_along; /* 8 */
int16_t ground_accel_across; /* 10 */
int16_t ground_accel_through; /* 12 */
+ int16_t ground_motor_pressure; /* 14 */
+ } flight; /* 16 */
/* AO_LOG_STATE */
struct {
uint16_t state; /* 4 */
/* AO_LOG_STATE */
struct {
uint16_t state; /* 4 */
ao_log_data.type = AO_LOG_FLIGHT;
ao_log_data.tick = ao_sample_tick;
ao_log_data.u.flight.ground_accel = ao_ground_accel;
ao_log_data.type = AO_LOG_FLIGHT;
ao_log_data.tick = ao_sample_tick;
ao_log_data.u.flight.ground_accel = ao_ground_accel;
+ ao_log_data.u.flight.ground_accel_along = ao_ground_accel_along;
+ ao_log_data.u.flight.ground_accel_through = ao_ground_accel_through;
+ ao_log_data.u.flight.ground_motor_pressure = ao_ground_motor_pressure;
ao_log_data.u.flight.flight = ao_flight_number;
ao_log_write(&ao_log_data);
ao_log_data.u.flight.flight = ao_flight_number;
ao_log_write(&ao_log_data);
ao_log_data.tick = ao_data_ring[ao_log_data_pos].tick;
if ((int16_t) (ao_log_data.tick - next_sensor) >= 0) {
ao_log_data.type = AO_LOG_SENSOR;
ao_log_data.tick = ao_data_ring[ao_log_data_pos].tick;
if ((int16_t) (ao_log_data.tick - next_sensor) >= 0) {
ao_log_data.type = AO_LOG_SENSOR;
- ao_log_data.u.sensor.pressure = ao_data_ring[ao_log_data_pos].adc.pressure;
+ ao_log_data.u.sensor.pressure = ao_data_motor_pressure(&ao_data_ring[ao_log_data_pos]);
ao_log_data.u.sensor.v_batt = ao_data_ring[ao_log_data_pos].adc.v_batt;
ao_log_data.u.sensor.accel = ao_data_accel(&ao_data_ring[ao_log_data_pos]);
ao_log_data.u.sensor.accel_across = ao_data_across(&ao_data_ring[ao_log_data_pos]);
ao_log_data.u.sensor.v_batt = ao_data_ring[ao_log_data_pos].adc.v_batt;
ao_log_data.u.sensor.accel = ao_data_accel(&ao_data_ring[ao_log_data_pos]);
ao_log_data.u.sensor.accel_across = ao_data_across(&ao_data_ring[ao_log_data_pos]);
angle_t ao_sample_orients[AO_NUM_ORIENT];
uint8_t ao_sample_orient_pos;
#endif
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
int32_t ao_ground_roll;
#endif
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;
static uint8_t ao_preflight; /* in preflight mode */
static uint16_t nsamples;
int32_t ao_sample_roll_sum;
static struct ao_quaternion ao_rotation;
#endif
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;
#if HAS_FLIGHT_DEBUG
extern uint8_t ao_orient_test;
ao_sample_pitch_sum += ao_sample_pitch;
ao_sample_yaw_sum += ao_sample_yaw;
ao_sample_roll_sum += ao_sample_roll;
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;
ao_ground_accel_through = ao_sample_accel_through_sum >> 9;
#endif
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;
#if HAS_GYRO
ao_ground_pitch = ao_sample_pitch_sum;
ao_ground_yaw = ao_sample_yaw_sum;
ao_sample_yaw = ao_data_yaw(ao_data);
ao_sample_roll = ao_data_roll(ao_data);
#endif
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();
if (ao_preflight)
ao_sample_preflight();
extern angle_t ao_sample_orients[AO_NUM_ORIENT];
extern uint8_t ao_sample_orient_pos;
#endif
extern angle_t ao_sample_orients[AO_NUM_ORIENT];
extern uint8_t ao_sample_orient_pos;
#endif
+#if HAS_MOTOR_PRESSURE
+extern motor_pressure_t ao_ground_motor_pressure;
+extern motor_pressure_t ao_sample_motor_pressure;
+#endif
void ao_sample_init(void);
void ao_sample_init(void);