diff options
author | Keith Packard <keithp@keithp.com> | 2011-08-01 22:44:13 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2011-08-27 12:12:41 -0700 |
commit | b10fbbf0830053a39e4640a53598b1c027615c63 (patch) | |
tree | 6e43d1b214a74f525ef8f4bd4ddfc484d8463614 /src/core/ao_telemetry.c | |
parent | 1c46c419704f661064d200432eb7efeeb11b3859 (diff) |
altos: Add 'send all baro' compile-time option
This option creates a new packet type that delivers full sensor-rate
barometer telemetry data to allow for off-line analysis of flight
algorithms using all of the data, rather than the slower rate provided
either over telemetry or stored in the eeprom file.
Define AO_SEND_ALL_BARO and this will get built in. Perhaps this could
be a run-time option...
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core/ao_telemetry.c')
-rw-r--r-- | src/core/ao_telemetry.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/core/ao_telemetry.c b/src/core/ao_telemetry.c index c7338a58..de669ce1 100644 --- a/src/core/ao_telemetry.c +++ b/src/core/ao_telemetry.c @@ -94,6 +94,30 @@ ao_send_sensor(void) ao_radio_send(&telemetry, sizeof (telemetry)); } +static uint8_t ao_baro_sample; + +#ifdef AO_SEND_ALL_BARO +static void +ao_send_baro(void) +{ + uint8_t sample = ao_sample_adc; + uint8_t samples = (sample - ao_baro_sample) & (AO_ADC_RING - 1); + + if (samples > 12) { + ao_baro_sample = (ao_baro_sample + (samples - 12)) & (AO_ADC_RING - 1); + samples = 12; + } + telemetry.generic.tick = ao_adc_ring[sample].tick; + telemetry.generic.type = AO_TELEMETRY_BARO; + telemetry.baro.samples = samples; + for (sample = 0; sample < samples; sample++) { + telemetry.baro.baro[sample] = ao_adc_ring[ao_baro_sample].pres; + ao_baro_sample = ao_adc_ring_next(ao_baro_sample); + } + ao_radio_send(&telemetry, sizeof (telemetry)); +} +#endif + static void ao_send_configuration(void) { @@ -193,6 +217,9 @@ ao_telemetry(void) while (ao_telemetry_interval) { +#ifdef AO_SEND_ALL_BARO + ao_send_baro(); +#endif ao_send_sensor(); #if HAS_COMPANION if (ao_companion_running) @@ -203,12 +230,14 @@ ao_telemetry(void) ao_send_location(); ao_send_satellite(); #endif +#ifndef AO_SEND_ALL_BARO if (ao_rdf && (int16_t) (ao_time() - ao_rdf_time) >= 0) { ao_rdf_time = ao_time() + AO_RDF_INTERVAL_TICKS; ao_radio_rdf(AO_RDF_LENGTH_MS); } +#endif time += ao_telemetry_interval; delay = time - ao_time(); if (delay > 0) |