diff options
| -rw-r--r-- | altoslib/AltosIdleFetch.java | 5 | ||||
| -rw-r--r-- | altoslib/AltosSensorTMini.java | 70 | ||||
| -rw-r--r-- | altoslib/AltosTelemetryMini.java | 72 | ||||
| -rw-r--r-- | altoslib/AltosTelemetryStandard.java | 3 | ||||
| -rw-r--r-- | altoslib/Makefile.am | 2 | ||||
| -rw-r--r-- | ao-tools/ao-telem/ao-telem.c | 13 | 
6 files changed, 164 insertions, 1 deletions
diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index 42943c07..64c421f4 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -37,6 +37,7 @@ class AltosIdler {  	static final int	idle_sensor_metrum = 11;  	static final int	idle_sensor_mega = 12;  	static final int	idle_sensor_emini = 13; +	static final int	idle_sensor_tmini = 14;  	public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException {  		for (int idler : idlers) { @@ -69,6 +70,8 @@ class AltosIdler {  			case idle_sensor_emini:  				AltosSensorEMini.update_state(state, link, config_data);  				break; +			case idle_sensor_tmini: +				AltosSensorTMini.update_state(state, link, config_data);  			}  			if (idle != null)  				idle.update_state(state); @@ -99,7 +102,7 @@ public class AltosIdleFetch implements AltosStateUpdate {  		new AltosIdler("TeleMini-v2",  			       AltosIdler.idle_ms5607, -			       AltosIdler.idle_sensor_tm), +			       AltosIdler.idle_sensor_tmini),  		new AltosIdler("TeleMetrum-v1",  			       AltosIdler.idle_gps, diff --git a/altoslib/AltosSensorTMini.java b/altoslib/AltosSensorTMini.java new file mode 100644 index 00000000..be071e5d --- /dev/null +++ b/altoslib/AltosSensorTMini.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2012 Keith Packard <keithp@keithp.com> + * + * 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. + */ + +package org.altusmetrum.altoslib_2; + +import java.util.concurrent.TimeoutException; + +public class AltosSensorTMini { +	public int	tick; +	public int	apogee; +	public int	main; +	public int	batt; + +	static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) { +		try { +			AltosSensorTMini	sensor_tmini = new AltosSensorTMini(link); + +			if (sensor_tmini == null) +				return; +			state.set_battery_voltage(AltosConvert.easy_mini_voltage(sensor_tmini.batt)); +			state.set_apogee_voltage(AltosConvert.easy_mini_voltage(sensor_tmini.apogee)); +			state.set_main_voltage(AltosConvert.easy_mini_voltage(sensor_tmini.main)); +			 +		} catch (TimeoutException te) { +		} catch (InterruptedException ie) { +		} +	} + +	public AltosSensorTMini(AltosLink link) throws InterruptedException, TimeoutException { +		String[] items = link.adc(); +		for (int i = 0; i < items.length;) { +			if (items[i].equals("tick:")) { +				tick = Integer.parseInt(items[i+1]); +				i += 2; +				continue; +			} +			if (items[i].equals("apogee:")) { +				apogee = Integer.parseInt(items[i+1]); +				i += 2; +				continue; +			} +			if (items[i].equals("main:")) { +				main = Integer.parseInt(items[i+1]); +				i += 2; +				continue; +			} +			if (items[i].equals("batt:")) { +				batt = Integer.parseInt(items[i+1]); +				i += 2; +				continue; +			} +			i++; +		} +	} +} + diff --git a/altoslib/AltosTelemetryMini.java b/altoslib/AltosTelemetryMini.java new file mode 100644 index 00000000..e7109460 --- /dev/null +++ b/altoslib/AltosTelemetryMini.java @@ -0,0 +1,72 @@ +/* + * Copyright © 2011 Keith Packard <keithp@keithp.com> + * + * 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. + */ + +package org.altusmetrum.altoslib_2; + + +public class AltosTelemetryMini extends AltosTelemetryStandard { +	int	state; + +	int	v_batt; +	int	sense_a; +	int	sense_m; + +	int	pres; +	int	temp; + +	int	acceleration; +	int	speed; +	int	height; + +	int	ground_pres; + +	public AltosTelemetryMini(int[] bytes) { +		super(bytes); + +		state	      = int8(5); + +		v_batt        = int16(6); +		sense_a       = int16(8); +		sense_m       = int16(10); + +		pres          = int32(12); +		temp          = int16(16); + +		acceleration  = int16(18); +		speed         = int16(20); +		height        = int16(22); + +		ground_pres   = int32(24); +	} + +	public void update_state(AltosState state) { +		super.update_state(state); + +		state.set_state(this.state); + +		state.set_battery_voltage(AltosConvert.tele_mini_voltage(v_batt)); +		state.set_apogee_voltage(AltosConvert.tele_mini_voltage(sense_a)); +		state.set_main_voltage(AltosConvert.tele_mini_voltage(sense_m)); + +		state.set_ground_pressure(ground_pres); + +		state.set_pressure(pres); +		state.set_temperature(temp/100.0); + +		state.set_kalman(height, speed/16.0, acceleration/16.0); +	} +} diff --git a/altoslib/AltosTelemetryStandard.java b/altoslib/AltosTelemetryStandard.java index fbcc970c..3186ae09 100644 --- a/altoslib/AltosTelemetryStandard.java +++ b/altoslib/AltosTelemetryStandard.java @@ -85,6 +85,9 @@ public abstract class AltosTelemetryStandard extends AltosTelemetry {  		case packet_type_metrum_data:  			telem = new AltosTelemetryMetrumData(bytes);  			break; +		case packet_type_mini: +			telem = new AltosTelemetryMini(bytes); +			break;  		default:  			telem = new AltosTelemetryRaw(bytes);  			break; diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 2c78ae72..c1cf053c 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -73,6 +73,7 @@ altoslib_JAVA = \  	AltosSensorMM.java \  	AltosSensorEMini.java \  	AltosSensorTM.java \ +	AltosSensorTMini.java \  	AltosSensorMega.java \  	AltosSensorMetrum.java \  	AltosState.java \ @@ -87,6 +88,7 @@ altoslib_JAVA = \  	AltosTelemetryMap.java \  	AltosTelemetryMegaSensor.java \  	AltosTelemetryMegaData.java \ +	AltosTelemetryMini.java \  	AltosTelemetryMetrumSensor.java \  	AltosTelemetryMetrumData.java \  	AltosTelemetryReader.java \ diff --git a/ao-tools/ao-telem/ao-telem.c b/ao-tools/ao-telem/ao-telem.c index 893e2340..f1755b82 100644 --- a/ao-tools/ao-telem/ao-telem.c +++ b/ao-tools/ao-telem/ao-telem.c @@ -214,6 +214,19 @@ main (int argc, char **argv)  						telem.metrum_data.accel_plus_g,  						telem.metrum_data.accel_minus_g);  					break; +				case AO_TELEMETRY_MINI: +					printf ("state %1d v_batt %5d sense_a %5d sense_m %5d pres %9d temp %6.2f acceleration %6.2f speed %6.2f height %5d ground_pres %9d\n", +						telem.mini.state, +						telem.mini.v_batt, +						telem.mini.sense_a, +						telem.mini.sense_m, +						telem.mini.pres, +						telem.mini.temp / 100.0, +						telem.mini.acceleration / 16.0, +						telem.mini.speed / 16.0, +						telem.mini.height, +						telem.mini.ground_pres); +					break;  				default:  					printf("\n");  				}  | 
