summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/ao.h1
-rw-r--r--src/core/ao_flight_mm.c16
-rw-r--r--src/core/ao_telemetry.c8
-rw-r--r--src/megametrum-v0.1/Makefile5
-rw-r--r--src/megametrum-v0.1/ao_megametrum.c1
-rw-r--r--src/megametrum-v0.1/ao_pins.h1
6 files changed, 22 insertions, 10 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
diff --git a/src/megametrum-v0.1/Makefile b/src/megametrum-v0.1/Makefile
index 054855ba..5c641e9a 100644
--- a/src/megametrum-v0.1/Makefile
+++ b/src/megametrum-v0.1/Makefile
@@ -64,12 +64,13 @@ ALTOS_SRC = \
ao_log_mega.c \
ao_sample_mm.c \
ao_kalman.c \
- ao_flight_mm.c
+ ao_flight_mm.c \
+ ao_telemetry.c
PRODUCT=MegaMetrum-v0.1
PRODUCT_DEF=-DMEGAMETRUM
-IDPRODUCT=0x000a
+IDPRODUCT=0x0023
CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) -Os -g
diff --git a/src/megametrum-v0.1/ao_megametrum.c b/src/megametrum-v0.1/ao_megametrum.c
index 628c5538..dc9c0d19 100644
--- a/src/megametrum-v0.1/ao_megametrum.c
+++ b/src/megametrum-v0.1/ao_megametrum.c
@@ -47,6 +47,7 @@ main(void)
ao_flight_init();
ao_log_init();
ao_report_init();
+ ao_telemetry_init();
ao_config_init();
ao_start_scheduler();
diff --git a/src/megametrum-v0.1/ao_pins.h b/src/megametrum-v0.1/ao_pins.h
index 5121ad58..5c5c5972 100644
--- a/src/megametrum-v0.1/ao_pins.h
+++ b/src/megametrum-v0.1/ao_pins.h
@@ -66,6 +66,7 @@
#define HAS_USB 1
#define HAS_BEEP 1
#define HAS_RADIO 1
+#define HAS_TELEMETRY 1
#define HAS_SPI_1 1
#define SPI_1_PA5_PA6_PA7 1