diff options
author | Keith Packard <keithp@keithp.com> | 2012-06-17 19:04:22 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-06-17 19:04:22 -0700 |
commit | 629f43e7c7abbff33e14b168a08a4b6a9c88b937 (patch) | |
tree | 0a0e22f2efe7568aad64b4f854baad173403c67d /src/core | |
parent | 9b24f413da0b6d989b32e8654a91c8deee4c81dd (diff) |
altos: Add telemetry to megametrum
Now that the radio works
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ao.h | 1 | ||||
-rw-r--r-- | src/core/ao_flight_mm.c | 16 | ||||
-rw-r--r-- | src/core/ao_telemetry.c | 8 |
3 files changed, 17 insertions, 8 deletions
diff --git a/src/core/ao.h b/src/core/ao.h index a4136a9b..3dae8b40 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -347,6 +347,7 @@ struct ao_telemetry_generic { #define AO_TELEMETRY_SENSOR_TELEMETRUM 0x01 #define AO_TELEMETRY_SENSOR_TELEMINI 0x02 #define AO_TELEMETRY_SENSOR_TELENANO 0x03 +#define AO_TELEMETRY_SENSOR_MEGAMETRUM 0x08 struct ao_telemetry_sensor { uint16_t serial; /* 0 */ diff --git a/src/core/ao_flight_mm.c b/src/core/ao_flight_mm.c index c2a7cd64..28b9869f 100644 --- a/src/core/ao_flight_mm.c +++ b/src/core/ao_flight_mm.c @@ -32,6 +32,10 @@ #error Please define HAS_USB #endif +#ifndef HAS_TELEMETRY +#define HAS_TELEMETRY HAS_RADIO +#endif + /* Main flight thread. */ __pdata enum ao_flight_state ao_flight_state; /* current flight state */ @@ -83,7 +87,7 @@ ao_flight(void) * - pad mode if we're upright, * - idle mode otherwise */ -#if HAS_ACCEL +#if HAS_ACCEL && 0 if (ao_config.accel_plus_g == 0 || ao_config.accel_minus_g == 0 || ao_ground_accel < ao_config.accel_plus_g - ACCEL_NOSE_UP || @@ -101,14 +105,14 @@ ao_flight(void) } else #endif if (!ao_flight_force_idle -#if HAS_ACCEL +#if HAS_ACCEL && 0 && ao_ground_accel < ao_config.accel_plus_g + ACCEL_NOSE_UP #endif ) { /* Set pad mode - we can fly! */ ao_flight_state = ao_flight_pad; -#if HAS_USB && HAS_RADIO +#if HAS_USB && HAS_RADIO && 0 /* Disable the USB controller in flight mode * to save power */ @@ -120,7 +124,7 @@ ao_flight(void) ao_packet_slave_stop(); #endif -#if HAS_RADIO && !defined (MEGAMETRUM) +#if HAS_TELEMETRY /* Turn on telemetry system */ ao_rdf_set(1); ao_telemetry_set_interval(AO_TELEMETRY_INTERVAL_PAD); @@ -171,7 +175,7 @@ ao_flight(void) /* start logging data */ ao_log_start(); -#if HAS_RADIO && !defined(MEGAMETRUM) +#if HAS_TELEMETRY /* Increase telemetry rate */ ao_telemetry_set_interval(AO_TELEMETRY_INTERVAL_FLIGHT); @@ -259,7 +263,7 @@ ao_flight(void) ao_ignite(ao_igniter_drogue); #endif -#if HAS_RADIO && !defined(MEGAMETRUM) +#if HAS_TELEMETRY /* slow down the telemetry system */ ao_telemetry_set_interval(AO_TELEMETRY_INTERVAL_RECOVER); diff --git a/src/core/ao_telemetry.c b/src/core/ao_telemetry.c index 6e8fc02f..5857c44d 100644 --- a/src/core/ao_telemetry.c +++ b/src/core/ao_telemetry.c @@ -35,6 +35,10 @@ static __pdata uint16_t ao_rdf_time; #define AO_RDF_INTERVAL_TICKS AO_SEC_TO_TICKS(5) #define AO_RDF_LENGTH_MS 500 +#if defined(MEGAMETRUM) +#define AO_TELEMETRY_SENSOR AO_TELEMETRY_SENSOR_MEGAMETRUM +#endif + #if defined(TELEMETRUM_V_0_1) || defined(TELEMETRUM_V_0_2) || defined(TELEMETRUM_V_1_0) || defined(TELEMETRUM_V_1_1) || defined(TELEBALLOON_V_1_1) || defined(TELEMETRUM_V_1_2) #define AO_TELEMETRY_SENSOR AO_TELEMETRY_SENSOR_TELEMETRUM #endif @@ -53,7 +57,7 @@ static __xdata union ao_telemetry_all telemetry; static void ao_send_sensor(void) { - __xdata struct ao_data *packet = &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; + __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; telemetry.generic.tick = packet->tick; telemetry.generic.type = AO_TELEMETRY_SENSOR; @@ -64,7 +68,7 @@ ao_send_sensor(void) #else telemetry.sensor.accel = 0; #endif - telemetry.sensor.pres = packet->adc.pres; + telemetry.sensor.pres = ao_data_pres(packet); telemetry.sensor.temp = packet->adc.temp; telemetry.sensor.v_batt = packet->adc.v_batt; #if HAS_IGNITE |