altos: Make serial, usb, beeper and accelerometer optional components
authorKeith Packard <keithp@keithp.com>
Mon, 7 Mar 2011 04:56:25 +0000 (20:56 -0800)
committerKeith Packard <keithp@keithp.com>
Wed, 16 Mar 2011 22:57:37 +0000 (15:57 -0700)
Not all boards will have these, so fix places that use them to deal
with that.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/Makefile.proto
src/ao.h
src/ao_flight.c
src/ao_flight_test.c
src/ao_log.c
src/ao_panic.c
src/ao_pins.h
src/ao_product.c
src/ao_report.c
src/ao_telemetry.c

index 709cbca73f059fdd0bb766b7b80bf02f39387789..30cd57981ae7a79504d26698f903c30d2c27605c 100644 (file)
@@ -42,11 +42,15 @@ ALTOS_SRC = \
 # Shared AltOS drivers
 #
 ALTOS_DRIVER_SRC = \
-       ao_beep.c \
        ao_config.c \
        ao_led.c \
        ao_radio.c \
-       ao_stdio.c \
+       ao_stdio.c
+
+BEEP_DRIVER_SRC = \
+       ao_beep.c
+
+USB_DRIVER_SRC = \
        ao_usb.c
 
 TELE_COMMON_SRC = \
@@ -68,7 +72,12 @@ TELE_RECEIVER_SRC =\
 #
 
 TELE_DRIVER_SRC = \
-       ao_convert.c \
+       ao_convert.c
+
+#
+# Serial port driver
+#
+SERIAL_DRIVER_SRC = \
        ao_serial.c
 
 #
@@ -89,7 +98,9 @@ DBG_SRC = \
 TM_DRIVER_SRC = \
        ao_adc.c \
        ao_gps_report.c \
-       ao_ignite.c
+       ao_ignite.c \
+       $(BEEP_DRIVER_SRC) \
+       $(USB_DRIVER_SRC)
 
 #
 # 25LC1024 driver source
@@ -142,6 +153,7 @@ TM_BASE_SRC = \
        $(ALTOS_SRC) \
        $(ALTOS_DRIVER_SRC) \
        $(TELE_DRIVER_SRC) \
+       $(SERIAL_DRIVER_SRC) \
        $(TELE_COMMON_SRC) \
        $(TM_DRIVER_SRC) \
        $(TM_TASK_SRC) \
@@ -158,6 +170,7 @@ TI_SRC = \
        $(ALTOS_DRIVER_SRC) \
        $(TELE_RECEIVER_SRC) \
        $(TELE_COMMON_SRC) \
+       $(USB_DRIVER_SRC) \
        $(TI_MAIN_SRC) \
        $(DBG_SRC)
 
@@ -172,6 +185,7 @@ TT_SRC = \
        $(TELE_RECEIVER_SRC) \
        $(TELE_DRIVER_SRC) \
        $(TELE_COMMON_SRC) \
+       $(USB_DRIVER_SRC) \
        $(TT_MAIN_SRC)
 
 
@@ -187,6 +201,7 @@ TD_SRC = \
        $(ALTOS_DRIVER_SRC) \
        $(TELE_RECEIVER_SRC) \
        $(TELE_COMMON_SRC) \
+       $(USB_DRIVER_SRC) \
        $(TD_MAIN_SRC)
 
 include Makefile.defs
index 791064e8d25c7b6c3e5e52c2e3d0c7beaf56cdb4..5bbe5158e8452707518f88cccf477cc83e960a48 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -164,9 +164,13 @@ struct ao_adc {
 
 #if HAS_ADC
 
+#if HAS_ACCEL
 #ifndef HAS_ACCEL_REF
 #error Please define HAS_ACCEL_REF
 #endif
+#else
+#define HAS_ACCEL_REF 0
+#endif
 
 /*
  * ao_adc.c
@@ -303,7 +307,14 @@ extern __code __at (0x00a0) uint16_t ao_romconfig_version;
 extern __code __at (0x00a2) uint16_t ao_romconfig_check;
 extern __code __at (0x00a4) uint16_t ao_serial_number;
 extern __code __at (0x00a6) uint32_t ao_radio_cal;
+
+#ifndef HAS_USB
+#error Please define HAS_USB
+#endif
+
+#if HAS_USB
 extern __code __at (0x00aa) uint8_t ao_usb_descriptors [];
+#endif
 
 /*
  * ao_usb.c
@@ -327,9 +338,11 @@ ao_usb_pollchar(void);
 void
 ao_usb_flush(void);
 
+#if HAS_USB
 /* USB interrupt handler */
 void
 ao_usb_isr(void) __interrupt 6;
+#endif
 
 /* Enable the USB controller */
 void
@@ -1062,7 +1075,6 @@ ao_rssi_init(uint8_t rssi_led);
  * each instance of a product
  */
 
-extern __code __at(0x00aa) uint8_t ao_usb_descriptors [];
 extern const char ao_version[];
 extern const char ao_manufacturer[];
 extern const char ao_product[];
index 81aecad3e26e0053059b65a90b7273a9504d627a..843865e8f83d82188f2c3bdf63cb9254c87a494b 100644 (file)
 #include "ao.h"
 #endif
 
+#ifndef HAS_ACCEL
+#error Please define HAS_ACCEL
+#endif
+
+#ifndef HAS_GPS
+#error Please define HAS_GPS
+#endif
+
+#ifndef HAS_USB
+#error Please define HAS_USB
+#endif
+
 /* Main flight thread. */
 
 __pdata enum ao_flight_state   ao_flight_state;        /* current flight state */
 __pdata uint16_t               ao_flight_tick;         /* time of last data */
 __pdata uint16_t               ao_flight_prev_tick;    /* time of previous data */
-__pdata int16_t                        ao_flight_accel;        /* filtered acceleration */
 __pdata int16_t                        ao_flight_pres;         /* filtered pressure */
 __pdata int16_t                        ao_ground_pres;         /* startup pressure */
-__pdata int16_t                        ao_ground_accel;        /* startup acceleration */
 __pdata int16_t                        ao_min_pres;            /* minimum recorded pressure */
 __pdata uint16_t               ao_launch_tick;         /* time of launch detect */
 __pdata int16_t                        ao_main_pres;           /* pressure to eject main */
+#if HAS_ACCEL
+__pdata int16_t                        ao_flight_accel;        /* filtered acceleration */
+__pdata int16_t                        ao_ground_accel;        /* startup acceleration */
+#endif
 
 /*
  * track min/max data over a long interval to detect
  * resting
  */
 __pdata uint16_t               ao_interval_end;
-__pdata int16_t                        ao_interval_cur_min_accel;
-__pdata int16_t                        ao_interval_cur_max_accel;
 __pdata int16_t                        ao_interval_cur_min_pres;
 __pdata int16_t                        ao_interval_cur_max_pres;
-__pdata int16_t                        ao_interval_min_accel;
-__pdata int16_t                        ao_interval_max_accel;
 __pdata int16_t                        ao_interval_min_pres;
 __pdata int16_t                        ao_interval_max_pres;
+#if HAS_ACCEL
+__pdata int16_t                        ao_interval_cur_min_accel;
+__pdata int16_t                        ao_interval_cur_max_accel;
+__pdata int16_t                        ao_interval_min_accel;
+__pdata int16_t                        ao_interval_max_accel;
+#endif
 
 __data uint8_t ao_flight_adc;
-__pdata int16_t ao_raw_accel, ao_raw_accel_prev, ao_raw_pres;
-__pdata int16_t ao_accel_2g;
-
+__pdata int16_t ao_raw_pres;
 __xdata uint8_t ao_flight_force_idle;
 
+#if HAS_ACCEL
+__pdata int16_t ao_raw_accel, ao_raw_accel_prev;
+__pdata int16_t ao_accel_2g;
+
 /* Accelerometer calibration
  *
  * We're sampling the accelerometer through a resistor divider which
@@ -84,6 +102,8 @@ __xdata uint8_t ao_flight_force_idle;
 #define ACCEL_VEL_MACH VEL_MPS_TO_COUNT(200)
 #define ACCEL_VEL_BOOST        VEL_MPS_TO_COUNT(5)
 
+#endif
+
 /*
  * Barometer calibration
  *
@@ -117,6 +137,7 @@ __xdata uint8_t ao_flight_force_idle;
 
 #define BOOST_TICKS_MAX        AO_SEC_TO_TICKS(15)
 
+#if HAS_ACCEL
 /* This value is scaled in a weird way. It's a running total of accelerometer
  * readings minus the ground accelerometer reading. That means it measures
  * velocity, and quite accurately too. As it gets updated 100 times a second,
@@ -126,7 +147,10 @@ __pdata int32_t    ao_flight_vel;
 __pdata int32_t ao_min_vel;
 __pdata int32_t        ao_old_vel;
 __pdata int16_t ao_old_vel_tick;
-__xdata int32_t ao_raw_accel_sum, ao_raw_pres_sum;
+__xdata int32_t ao_raw_accel_sum;
+#endif
+
+__xdata int32_t ao_raw_pres_sum;
 
 /* Landing is detected by getting constant readings from both pressure and accelerometer
  * for a fairly long time (AO_INTERVAL_TICKS)
@@ -141,22 +165,31 @@ ao_flight(void)
        __pdata static uint16_t nsamples = 0;
 
        ao_flight_adc = ao_adc_head;
+       ao_raw_pres = 0;
+#if HAS_ACCEL
        ao_raw_accel_prev = 0;
        ao_raw_accel = 0;
-       ao_raw_pres = 0;
+#endif
        ao_flight_tick = 0;
        for (;;) {
                ao_wakeup(DATA_TO_XDATA(&ao_flight_adc));
                ao_sleep(DATA_TO_XDATA(&ao_adc_head));
                while (ao_flight_adc != ao_adc_head) {
+#if HAS_ACCEL
                        __pdata uint8_t ticks;
                        __pdata int16_t ao_vel_change;
+#endif
                        __xdata struct ao_adc *ao_adc;
                        ao_flight_prev_tick = ao_flight_tick;
 
                        /* Capture a sample */
                        ao_adc = &ao_adc_ring[ao_flight_adc];
                        ao_flight_tick = ao_adc->tick;
+                       ao_raw_pres = ao_adc->pres;
+                       ao_flight_pres -= ao_flight_pres >> 4;
+                       ao_flight_pres += ao_raw_pres >> 4;
+
+#if HAS_ACCEL
                        ao_raw_accel = ao_adc->accel;
 #if HAS_ACCEL_REF
                        /*
@@ -242,12 +275,9 @@ ao_flight(void)
                        ao_raw_accel = (uint16_t) ((((uint32_t) ao_raw_accel << 16) / (ao_accel_ref[ao_flight_adc] << 1))) >> 1;
                        ao_adc->accel = ao_raw_accel;
 #endif
-                       ao_raw_pres = ao_adc->pres;
 
                        ao_flight_accel -= ao_flight_accel >> 4;
                        ao_flight_accel += ao_raw_accel >> 4;
-                       ao_flight_pres -= ao_flight_pres >> 4;
-                       ao_flight_pres += ao_raw_pres >> 4;
                        /* Update velocity
                         *
                         * The accelerometer is mounted so that
@@ -264,12 +294,14 @@ ao_flight(void)
                                ao_flight_vel += (int32_t) ao_vel_change;
                        else
                                ao_flight_vel += (int32_t) ao_vel_change * (int32_t) ticks;
+#endif
 
                        ao_flight_adc = ao_adc_ring_next(ao_flight_adc);
                }
 
                if (ao_flight_pres < ao_min_pres)
                        ao_min_pres = ao_flight_pres;
+#if HAS_ACCEL
                if (ao_flight_vel >= 0) {
                        if (ao_flight_vel < ao_min_vel)
                            ao_min_vel = ao_flight_vel;
@@ -277,6 +309,7 @@ ao_flight(void)
                        if (-ao_flight_vel < ao_min_vel)
                            ao_min_vel = -ao_flight_vel;
                }
+#endif
 
                switch (ao_flight_state) {
                case ao_flight_startup:
@@ -287,21 +320,27 @@ ao_flight(void)
                         * data and average them to find the resting values
                         */
                        if (nsamples < 512) {
+#if HAS_ACCEL
                                ao_raw_accel_sum += ao_raw_accel;
+#endif
                                ao_raw_pres_sum += ao_raw_pres;
                                ++nsamples;
                                continue;
                        }
+#if HAS_ACCEL
                        ao_ground_accel = ao_raw_accel_sum >> 9;
+#endif
                        ao_ground_pres = ao_raw_pres_sum >> 9;
                        ao_min_pres = ao_ground_pres;
                        ao_config_get();
                        ao_main_pres = ao_altitude_to_pres(ao_pres_to_altitude(ao_ground_pres) + ao_config.main_deploy);
+#if HAS_ACCEL
                        ao_accel_2g = ao_config.accel_minus_g - ao_config.accel_plus_g;
                        ao_flight_vel = 0;
                        ao_min_vel = 0;
                        ao_old_vel = ao_flight_vel;
                        ao_old_vel_tick = ao_flight_tick;
+#endif
 
                        /* Check to see what mode we should go to.
                         *  - Invalid mode if accel cal appears to be out
@@ -309,6 +348,7 @@ ao_flight(void)
                         *  - idle mode otherwise
                         */
                        ao_config_get();
+#if HAS_ACCEL
                        if (ao_config.accel_plus_g == 0 ||
                            ao_config.accel_minus_g == 0 ||
                            ao_flight_accel < ao_config.accel_plus_g - ACCEL_NOSE_UP ||
@@ -323,17 +363,23 @@ ao_flight(void)
                                 */
                                ao_packet_slave_start();
 
-                       } else if (ao_flight_accel < ao_config.accel_plus_g + ACCEL_NOSE_UP &&
-                                  !ao_flight_force_idle)
+                       } else
+#endif
+                               if (!ao_flight_force_idle
+#if HAS_ACCEL
+                                   && ao_flight_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
                                /* Disable the USB controller in flight mode
                                 * to save power
                                 */
                                ao_usb_disable();
-
+#endif
                                /* Turn on telemetry system */
                                ao_rdf_set(1);
                                ao_telemetry_set_interval(AO_TELEMETRY_INTERVAL_PAD);
@@ -356,6 +402,7 @@ ao_flight(void)
                        break;
                case ao_flight_pad:
 
+#if HAS_ACCEL
                        /* Trim velocity
                         *
                         * Once a second, remove any velocity from
@@ -366,6 +413,7 @@ ao_flight(void)
                                ao_flight_vel -= ao_old_vel;
                                ao_old_vel = ao_flight_vel;
                        }
+#endif
                        /* pad to boost:
                         *
                         * accelerometer: > 2g AND velocity > 5m/s
@@ -376,11 +424,18 @@ ao_flight(void)
                         * the barometer, but we use both to make sure this
                         * transition is detected
                         */
-                       if ((ao_flight_accel < ao_ground_accel - ACCEL_BOOST &&
-                            ao_flight_vel > ACCEL_VEL_BOOST) ||
+                       if (
+#if HAS_ACCEL
+                               (ao_flight_accel < ao_ground_accel - ACCEL_BOOST &&
+                                ao_flight_vel > ACCEL_VEL_BOOST) ||
+#endif
                            ao_flight_pres < ao_ground_pres - BARO_LAUNCH)
                        {
+#if HAS_ACCEL
                                ao_flight_state = ao_flight_boost;
+#else
+                               ao_flight_state = ao_flight_coast;
+#endif
                                ao_launch_tick = ao_flight_tick;
 
                                /* start logging data */
@@ -392,14 +447,17 @@ ao_flight(void)
                                /* disable RDF beacon */
                                ao_rdf_set(0);
 
+#if HAS_GPS
                                /* Record current GPS position by waking up GPS log tasks */
                                ao_wakeup(&ao_gps_data);
                                ao_wakeup(&ao_gps_tracking_data);
+#endif
 
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
                                break;
                        }
                        break;
+#if HAS_ACCEL
                case ao_flight_boost:
 
                        /* boost to fast:
@@ -448,6 +506,7 @@ ao_flight(void)
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
                        }
                        break;
+#endif
                case ao_flight_coast:
 
                        /* apogee detect: coast to drogue deploy:
@@ -478,8 +537,10 @@ ao_flight(void)
                                /* Set the 'last' limits to max range to prevent
                                 * early resting detection
                                 */
+#if HAS_ACCEL
                                ao_interval_min_accel = 0;
                                ao_interval_max_accel = 0x7fff;
+#endif
                                ao_interval_min_pres = 0;
                                ao_interval_max_pres = 0x7fff;
 
@@ -487,7 +548,9 @@ ao_flight(void)
                                ao_interval_end = ao_flight_tick + AO_INTERVAL_TICKS;
 
                                ao_interval_cur_min_pres = ao_interval_cur_max_pres = ao_flight_pres;
+#if HAS_ACCEL
                                ao_interval_cur_min_accel = ao_interval_cur_max_accel = ao_flight_accel;
+#endif
 
                                /* and enter drogue state */
                                ao_flight_state = ao_flight_drogue;
@@ -530,21 +593,28 @@ ao_flight(void)
                                ao_interval_cur_min_pres = ao_flight_pres;
                        if (ao_flight_pres > ao_interval_cur_max_pres)
                                ao_interval_cur_max_pres = ao_flight_pres;
+#if HAS_ACCEL
                        if (ao_flight_accel < ao_interval_cur_min_accel)
                                ao_interval_cur_min_accel = ao_flight_accel;
                        if (ao_flight_accel > ao_interval_cur_max_accel)
                                ao_interval_cur_max_accel = ao_flight_accel;
+#endif
 
                        if ((int16_t) (ao_flight_tick - ao_interval_end) >= 0) {
                                ao_interval_max_pres = ao_interval_cur_max_pres;
                                ao_interval_min_pres = ao_interval_cur_min_pres;
+                               ao_interval_cur_min_pres = ao_interval_cur_max_pres = ao_flight_pres;
+#if HAS_ACCEL
                                ao_interval_max_accel = ao_interval_cur_max_accel;
                                ao_interval_min_accel = ao_interval_cur_min_accel;
-                               ao_interval_end = ao_flight_tick + AO_INTERVAL_TICKS;
-                               ao_interval_cur_min_pres = ao_interval_cur_max_pres = ao_flight_pres;
                                ao_interval_cur_min_accel = ao_interval_cur_max_accel = ao_flight_accel;
+#endif
+                               ao_interval_end = ao_flight_tick + AO_INTERVAL_TICKS;
 
-                               if ((uint16_t) (ao_interval_max_accel - ao_interval_min_accel) < (uint16_t) ACCEL_INT_LAND &&
+                               if (
+#if HAS_ACCEL
+                                       (uint16_t) (ao_interval_max_accel - ao_interval_min_accel) < (uint16_t) ACCEL_INT_LAND &&
+#endif
                                    ao_flight_pres > ao_ground_pres - BARO_LAND &&
                                    (uint16_t) (ao_interval_max_pres - ao_interval_min_pres) < (uint16_t) BARO_INT_LAND)
                                {
index 0c2006d54907c6ac90f8c997a194ea4c1759cff4..e75bc8df348f5ca8dc240aaaaed6a8900f880d73 100644 (file)
@@ -155,6 +155,15 @@ struct ao_config ao_config;
 
 #define DATA_TO_XDATA(x) (x)
 
+#define HAS_FLIGHT 1
+#define HAS_ADC 1
+#define HAS_USB 1
+#define HAS_GPS 1
+#ifndef HAS_ACCEL
+#define HAS_ACCEL 1
+#endif
+#define HAS_ACCEL_REF 0
+
 #include "ao_flight.c"
 
 void
index 1b10961d1d45a151657d29d317b142fc19880f47..817d3e6fc6ca0615d05e648267d96753a1ec6f55 100644 (file)
@@ -92,7 +92,9 @@ ao_log(void)
 
        log.type = AO_LOG_FLIGHT;
        log.tick = ao_flight_tick;
+#if HAS_ACCEL
        log.u.flight.ground_accel = ao_ground_accel;
+#endif
        log.u.flight.flight = ao_flight_number;
        ao_log_data(&log);
 
index e996371e3536463f1a62adb46d98bf0626e17b0c..fdada201572c38e19e8adac2b6d9c7ad23414109 100644 (file)
 
 #include "ao.h"
 
+#ifndef HAS_BEEP
+#error Please define HAS_BEEP
+#endif
+
+#if !HAS_BEEP
+#define ao_beep(x)
+#endif
+
 static void
 ao_panic_delay(uint8_t n)
 {
index 2c5b9db5ca749a34f7f7d9f3884c53b848906dae..596045887690396c302d05f6132b67302bb9d4e0 100644 (file)
@@ -19,6 +19,9 @@
 #define _AO_PINS_H_
 
 #if defined(TELEMETRUM_V_1_0)
+       #define HAS_USB                 1
+       #define HAS_BEEP                1
+       #define HAS_GPS                 1
        #define HAS_SERIAL_1            1
        #define HAS_ADC                 1
        #define HAS_EEPROM              1
        #define LEDS_AVAILABLE          (AO_LED_RED)
        #define HAS_EXTERNAL_TEMP       0
        #define HAS_ACCEL_REF           0
+       #define HAS_ACCEL               1
 #endif
 
 #if defined(TELEMETRUM_V_1_1)
+       #define HAS_USB                 1
+       #define HAS_BEEP                1
+       #define HAS_GPS                 1
        #define HAS_SERIAL_1            1
        #define HAS_ADC                 1
        #define HAS_EEPROM              1
        #define SPI_CS_ON_P0            0
        #define M25_CS_MASK             0x02    /* CS0 is P1_1 */
        #define M25_MAX_CHIPS           1
+       #define HAS_ACCEL               1
 #endif
 
 #if defined(TELEDONGLE_V_0_2)
+       #define HAS_USB                 1
+       #define HAS_BEEP                0
        #define HAS_SERIAL_1            0
        #define HAS_ADC                 0
        #define HAS_DBG                 1
@@ -71,6 +81,9 @@
 #endif
 
 #if defined(TELEMETRUM_V_0_1)
+       #define HAS_USB                 1
+       #define HAS_BEEP                1
+       #define HAS_GPS                 1
        #define HAS_SERIAL_1            1
        #define HAS_ADC                 1
        #define HAS_DBG                 0
        #define HAS_ACCEL_REF           0
        #define SPI_CS_ON_P1            1
        #define SPI_CS_ON_P0            0
+       #define HAS_ACCEL               1
 #endif
 
 #if defined(TELEDONGLE_V_0_1)
+       #define HAS_USB                 1
+       #define HAS_BEEP                0
        #define HAS_SERIAL_1            0
        #define HAS_ADC                 0
        #define HAS_DBG                 0
 #endif
 
 #if defined(TIDONGLE)
+       #define HAS_USB                 1
+       #define HAS_BEEP                0
        #define HAS_SERIAL_1            0
        #define HAS_ADC                 0
        #define HAS_DBG                 1
index 82d6298f2dbe4751b6de6bd496ea6412f1c9a2d8..54ba2a14e993b85017c0f203e22191e2f82e9bca 100644 (file)
@@ -16,7 +16,6 @@
  */
 
 #include "ao.h"
-#include "ao_usb.h"
 #include PRODUCT_DEFS
 
 /* Defines which mark this particular AltOS product */
@@ -27,6 +26,8 @@ const char ao_product[] = AO_iProduct_STRING;
 
 #define LE_WORD(x)    ((x)&0xFF),((uint8_t) (((uint16_t) (x))>>8))
 
+#if HAS_USB
+#include "ao_usb.h"
 /* USB descriptors in one giant block of bytes */
 __code __at(0x00aa) uint8_t ao_usb_descriptors [] =
 {
@@ -151,3 +152,4 @@ __code __at(0x00aa) uint8_t ao_usb_descriptors [] =
        /* Terminating zero */
        0
 };
+#endif
index cc8b512b095ca0af903620e9d7802fd32e3905ca..c9ee7cae05724a1e234cd04fac7f26d5dd0344f5 100644 (file)
@@ -37,10 +37,14 @@ static const uint8_t flight_reports[] = {
        MORSE4(1,0,0,1),        /* invalid 'X' */
 };
 
-#if 1
-#define signal(time)   ao_beep_for(AO_BEEP_MID, time)
+#if HAS_BEEP
+#define low(time)      ao_beep_for(AO_BEEP_LOW, time)
+#define mid(time)      ao_beep_for(AO_BEEP_MID, time)
+#define high(time)     ao_beep_for(AO_BEEP_HIGH, time)
 #else
-#define signal(time)   ao_led_for(AO_LED_RED, time)
+#define low(time)      ao_led_for(AO_LED_RED, time)
+#define mid(time)      ao_led_for(AO_LED_RED|AO_LED_GREEN, time)
+#define high(time)     ao_led_for(AO_LED_GREEN, time)
 #endif
 #define pause(time)    ao_delay(time)
 
@@ -56,9 +60,9 @@ ao_report_beep(void) __reentrant
                return;
        while (l--) {
                if (r & 8)
-                       signal(AO_MS_TO_TICKS(600));
+                       mid(AO_MS_TO_TICKS(600));
                else
-                       signal(AO_MS_TO_TICKS(200));
+                       mid(AO_MS_TO_TICKS(200));
                pause(AO_MS_TO_TICKS(200));
                r >>= 1;
        }
@@ -69,12 +73,12 @@ static void
 ao_report_digit(uint8_t digit) __reentrant
 {
        if (!digit) {
-               signal(AO_MS_TO_TICKS(500));
+               mid(AO_MS_TO_TICKS(500));
                pause(AO_MS_TO_TICKS(200));
        } else {
                while (digit--) {
-                       signal(AO_MS_TO_TICKS(200));
-                       pause(AO_MS_TO_TICKS(200));
+                       mid(AO_MS_TO_TICKS(200));
+                       mid(AO_MS_TO_TICKS(200));
                }
        }
        pause(AO_MS_TO_TICKS(300));
@@ -118,24 +122,24 @@ ao_report_continuity(void) __reentrant
                     (ao_report_igniter_ready(ao_igniter_main) << 1));
        if (c) {
                while (c--) {
-                       ao_beep_for(AO_BEEP_HIGH, AO_MS_TO_TICKS(25));
+                       high(AO_MS_TO_TICKS(25));
                        pause(AO_MS_TO_TICKS(100));
                }
        } else {
                c = 10;
                while (c--) {
-                       ao_beep_for(AO_BEEP_HIGH, AO_MS_TO_TICKS(20));
-                       ao_beep_for(AO_BEEP_LOW, AO_MS_TO_TICKS(20));
+                       high(AO_MS_TO_TICKS(20));
+                       low(AO_MS_TO_TICKS(20));
                }
        }
        if (ao_log_full()) {
                pause(AO_MS_TO_TICKS(100));
                c = 2;
                while (c--) {
-                       ao_beep_for(AO_BEEP_LOW, AO_MS_TO_TICKS(100));
-                       ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(100));
-                       ao_beep_for(AO_BEEP_HIGH, AO_MS_TO_TICKS(100));
-                       ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(100));
+                       low(AO_MS_TO_TICKS(100));
+                       mid(AO_MS_TO_TICKS(100));
+                       high(AO_MS_TO_TICKS(100));
+                       mid(AO_MS_TO_TICKS(100));
                }
        }
        c = 50;
index 7aad929fb8706e7a247cc855a19b164c5bf8ec3d..dd79f3fc716825ce6a600dfd7bcb0bc77ec589a5 100644 (file)
@@ -42,16 +42,22 @@ ao_telemetry(void)
                while (ao_telemetry_interval == 0)
                        ao_sleep(&ao_telemetry_interval);
                telemetry.flight_state = ao_flight_state;
+#if HAS_ACCEL
                telemetry.flight_accel = ao_flight_accel;
                telemetry.ground_accel = ao_ground_accel;
                telemetry.flight_vel = ao_flight_vel;
+#endif
                telemetry.flight_pres = ao_flight_pres;
                telemetry.ground_pres = ao_ground_pres;
+#if HAS_ADC
                ao_adc_get(&telemetry.adc);
+#endif
+#if HAS_GPS
                ao_mutex_get(&ao_gps_mutex);
                memcpy(&telemetry.gps, &ao_gps_data, sizeof (struct ao_gps_data));
                memcpy(&telemetry.gps_tracking, &ao_gps_tracking_data, sizeof (struct ao_gps_tracking_data));
                ao_mutex_put(&ao_gps_mutex);
+#endif
                ao_radio_send(&telemetry, sizeof (telemetry));
                ao_delay(ao_telemetry_interval);
                if (ao_rdf &&