From c743eaa060080a7bd236466b93cff3abc96f405b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 15 Jan 2014 12:40:26 -0800 Subject: altos: Report battery, apogee and main voltages over APRS This makes APRS more usable when you mute the RF audio on the HT. Signed-off-by: Keith Packard --- src/core/ao_convert_volt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/core/ao_convert_volt.c (limited to 'src/core/ao_convert_volt.c') diff --git a/src/core/ao_convert_volt.c b/src/core/ao_convert_volt.c new file mode 100644 index 00000000..8556d423 --- /dev/null +++ b/src/core/ao_convert_volt.c @@ -0,0 +1,33 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" + +#define scale(v,p,m) ((int32_t) (v) * (AO_ADC_REFERENCE_DV * ((p) + (m))) / (AO_ADC_MAX * (m))) + +int16_t +ao_battery_decivolt(int16_t adc) +{ + return scale(adc, AO_BATTERY_DIV_PLUS, AO_BATTERY_DIV_MINUS); +} + +int16_t +ao_ignite_decivolt(int16_t adc) +{ + return scale(adc, AO_IGNITE_DIV_PLUS, AO_IGNITE_DIV_MINUS); +} + -- cgit v1.2.3