altos/kernel: Allow TeleGPS v2 to scale battery in telem
authorKeith Packard <keithp@keithp.com>
Mon, 1 May 2017 00:35:28 +0000 (17:35 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 1 May 2017 00:35:28 +0000 (17:35 -0700)
TeleGPS v2 uses the STMF0 processor instead of the LPC11, which means
the ADC range is different. As the raw ADC value was getting sent to
represent battery voltage in the config packet, we need to scale that
for the different processor. This patch allows that to happen.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_telemetry.c

index fa8178240e45b97f60c71717eb77d76fd3e3e69c..a4c73a869343152800c030bac0490ff3cc1e30e0 100644 (file)
@@ -296,6 +296,10 @@ static __pdata int8_t ao_telemetry_config_max;
 static __pdata int8_t ao_telemetry_config_cur;
 static __pdata uint16_t ao_telemetry_flight_number;
 
+#ifndef ao_telemetry_battery_convert
+#define ao_telemetry_battery_convert(a) (a)
+#endif
+
 static void
 ao_send_configuration(void)
 {
@@ -308,7 +312,7 @@ ao_send_configuration(void)
                telemetry.configuration.config_minor = AO_CONFIG_MINOR;
 #if AO_idProduct_NUMBER == 0x25 && HAS_ADC
                /* TeleGPS gets battery voltage instead of apogee delay */
-               telemetry.configuration.apogee_delay = ao_data_ring[ao_data_ring_prev(ao_data_head)].adc.v_batt;
+               telemetry.configuration.apogee_delay = ao_telemetry_battery_convert(ao_data_ring[ao_data_ring_prev(ao_data_head)].adc.v_batt);
 #else
                telemetry.configuration.apogee_delay = ao_config.apogee_delay;
                telemetry.configuration.main_deploy = ao_config.main_deploy;