summaryrefslogtreecommitdiff
path: root/altoslib
diff options
context:
space:
mode:
Diffstat (limited to 'altoslib')
-rw-r--r--altoslib/AltosAdxl375.java93
-rw-r--r--altoslib/AltosCalData.java24
-rw-r--r--altoslib/AltosConfigData.java18
-rw-r--r--altoslib/AltosConvert.java8
-rw-r--r--altoslib/AltosEepromRecordMega.java113
-rw-r--r--altoslib/AltosEepromRecordSet.java1
-rw-r--r--altoslib/AltosFlash.java6
-rw-r--r--altoslib/AltosHexsym.java6
-rw-r--r--altoslib/AltosIdleFetch.java31
-rw-r--r--altoslib/AltosLib.java1
-rw-r--r--altoslib/AltosProgrammer.java2
-rw-r--r--altoslib/AltosRomconfig.java10
-rw-r--r--altoslib/AltosSelfFlash.java6
-rw-r--r--altoslib/AltosSensorTGPS1.java (renamed from altoslib/AltosSensorTGPS.java)8
-rw-r--r--altoslib/AltosSensorTGPS2.java56
-rw-r--r--altoslib/AltosTelemetryConfiguration.java12
-rw-r--r--altoslib/Makefile.am4
17 files changed, 367 insertions, 32 deletions
diff --git a/altoslib/AltosAdxl375.java b/altoslib/AltosAdxl375.java
new file mode 100644
index 00000000..2129ed6e
--- /dev/null
+++ b/altoslib/AltosAdxl375.java
@@ -0,0 +1,93 @@
+/*
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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_13;
+
+import java.util.concurrent.*;
+
+public class AltosAdxl375 implements Cloneable {
+
+ private int accel;
+ private int axis;
+
+ public static final int X_AXIS = 0;
+ public static final int Y_AXIS = 1;
+ public static final int Z_AXIS = 2;
+
+ public boolean parse_line(String line) throws NumberFormatException {
+ if (line.startsWith("ADXL375 value")) {
+ System.out.printf("adxl parse line %s\n", line);
+ String[] items = line.split("\\s+");
+ if (axis == AltosLib.MISSING)
+ throw new NumberFormatException("No ADXL375 axis specified");
+ if (items.length >= 3) {
+ accel = Integer.parseInt(items[2 + axis]);
+ System.out.printf("accel %d\n", accel);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public AltosAdxl375 clone() {
+ AltosAdxl375 n = new AltosAdxl375(axis);
+
+ n.accel = accel;
+ return n;
+ }
+
+ static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException, AltosUnknownProduct {
+ try {
+ AltosCalData cal_data = listener.cal_data();
+ AltosAdxl375 adxl375 = new AltosAdxl375(link, cal_data.adxl375_axis);
+
+ if (adxl375 != null) {
+ int accel = adxl375.accel;
+ if (cal_data.adxl375_inverted)
+ accel = -accel;
+ if (cal_data.pad_orientation == 1)
+ accel = -accel;
+ listener.set_acceleration(cal_data.acceleration(accel));
+ }
+ } catch (TimeoutException te) {
+ } catch (NumberFormatException ne) {
+ }
+ }
+
+ public AltosAdxl375() {
+ accel = AltosLib.MISSING;
+ axis = AltosLib.MISSING;
+ }
+
+ public AltosAdxl375(int axis) {
+ this();
+ this.axis = axis;
+ }
+
+ public AltosAdxl375(AltosLink link, int axis) throws InterruptedException, TimeoutException, NumberFormatException {
+ this(axis);
+ link.printf("A\n");
+ for (;;) {
+ String line = link.get_reply_no_dialog(5000);
+ if (line == null)
+ throw new TimeoutException();
+ if (parse_line(line))
+ break;
+ }
+ }
+}
diff --git a/altoslib/AltosCalData.java b/altoslib/AltosCalData.java
index d448fdfe..22d19def 100644
--- a/altoslib/AltosCalData.java
+++ b/altoslib/AltosCalData.java
@@ -133,6 +133,18 @@ public class AltosCalData {
mma655x_inverted = inverted;
}
+ public boolean adxl375_inverted = false;
+
+ public void set_adxl375_inverted(boolean inverted) {
+ adxl375_inverted = inverted;
+ }
+
+ public int adxl375_axis = AltosLib.MISSING;
+
+ public void set_adxl375_axis(int axis) {
+ adxl375_axis = axis;
+ }
+
public int pad_orientation = AltosLib.MISSING;
public void set_pad_orientation(int orientation) {
@@ -142,7 +154,9 @@ public class AltosCalData {
/* Compute acceleration */
public double acceleration(double sensor) {
- return AltosConvert.acceleration_from_sensor(sensor, accel_plus_g, accel_minus_g, ground_accel);
+ double accel;
+ accel = AltosConvert.acceleration_from_sensor(sensor, accel_plus_g, accel_minus_g, ground_accel);
+ return accel;
}
public AltosMs5607 ms5607 = null;
@@ -404,6 +418,14 @@ public class AltosCalData {
set_mma655x_inverted(config_data.mma655x_inverted());
} catch (AltosUnknownProduct up) {
}
+ try {
+ set_adxl375_inverted(config_data.adxl375_inverted());
+ } catch (AltosUnknownProduct up) {
+ }
+ try {
+ set_adxl375_axis(config_data.adxl375_axis());
+ } catch (AltosUnknownProduct up) {
+ }
set_pad_orientation(config_data.pad_orientation);
}
}
diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java
index 48dab421..d315f96a 100644
--- a/altoslib/AltosConfigData.java
+++ b/altoslib/AltosConfigData.java
@@ -201,6 +201,8 @@ public class AltosConfigData {
case AltosLib.AO_LOG_FORMAT_TELEMEGA:
case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
return 4095 - value;
+ case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
+ return -value;
default:
return AltosLib.MISSING;
}
@@ -581,6 +583,22 @@ public class AltosConfigData {
throw new AltosUnknownProduct(product);
}
+ public boolean adxl375_inverted() throws AltosUnknownProduct {
+ if (product != null) {
+ if (product.startsWith("EasyMega-v2"))
+ return true;
+ }
+ throw new AltosUnknownProduct(product);
+ }
+
+ public int adxl375_axis() throws AltosUnknownProduct {
+ if (product != null) {
+ if (product.startsWith("EasyMega-v2"))
+ return AltosAdxl375.X_AXIS;
+ }
+ throw new AltosUnknownProduct(product);
+ }
+
public void get_values(AltosConfigValues source) throws AltosConfigDataException {
/* HAS_FLIGHT */
diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java
index d2460187..ce1b8f7f 100644
--- a/altoslib/AltosConvert.java
+++ b/altoslib/AltosConvert.java
@@ -258,12 +258,18 @@ public class AltosConvert {
return sensor / 32767.0 * supply * 127/27;
}
- static double tele_gps_voltage(int sensor) {
+ static double tele_gps_1_voltage(int sensor) {
double supply = 3.3;
return sensor / 32767.0 * supply * (5.6 + 10.0) / 10.0;
}
+ static double tele_gps_2_voltage(int sensor) {
+ double supply = 3.3;
+
+ return sensor / 4095.0 * supply * (5.6 + 10.0) / 10.0;
+ }
+
static double tele_bt_3_battery(int raw) {
if (raw == AltosLib.MISSING)
return AltosLib.MISSING;
diff --git a/altoslib/AltosEepromRecordMega.java b/altoslib/AltosEepromRecordMega.java
index 6b28c50a..c37dbfa2 100644
--- a/altoslib/AltosEepromRecordMega.java
+++ b/altoslib/AltosEepromRecordMega.java
@@ -32,6 +32,7 @@ public class AltosEepromRecordMega extends AltosEepromRecord {
switch (log_format) {
case AltosLib.AO_LOG_FORMAT_TELEMEGA:
case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
+ case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
return data32(16);
case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
return data16(14);
@@ -43,6 +44,7 @@ public class AltosEepromRecordMega extends AltosEepromRecord {
switch (log_format) {
case AltosLib.AO_LOG_FORMAT_TELEMEGA:
case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
+ case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
return data32(20);
case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
return data16(16);
@@ -54,6 +56,7 @@ public class AltosEepromRecordMega extends AltosEepromRecord {
switch (log_format) {
case AltosLib.AO_LOG_FORMAT_TELEMEGA:
case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
+ case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
return data32(24);
case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
return data16(18);
@@ -78,6 +81,98 @@ public class AltosEepromRecordMega extends AltosEepromRecord {
private int mag_x() { return data16(20); }
private int mag_z() { return data16(22); }
private int mag_y() { return data16(24); }
+
+ private int accel_across() {
+ switch (log_format) {
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
+ return accel_x();
+ case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
+ return -accel_y();
+ default:
+ return AltosLib.MISSING;
+ }
+ }
+
+ private int accel_along(){
+ switch (log_format) {
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
+ return accel_y();
+ case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
+ return accel_x();
+ default:
+ return AltosLib.MISSING;
+ }
+ }
+
+ private int accel_through() {
+ return accel_z();
+ }
+
+ private int gyro_pitch() {
+ switch (log_format) {
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
+ return gyro_x();
+ case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
+ return -gyro_y();
+ default:
+ return AltosLib.MISSING;
+ }
+ }
+
+ private int gyro_roll() {
+ switch (log_format) {
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
+ return gyro_y();
+ case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
+ return gyro_x();
+ default:
+ return AltosLib.MISSING;
+ }
+ }
+
+ private int gyro_yaw() {
+ return gyro_z();
+ }
+
+ private int mag_across() {
+ switch (log_format) {
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
+ return mag_x();
+ case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
+ return -mag_y();
+ default:
+ return AltosLib.MISSING;
+ }
+ }
+
+ private int mag_along() {
+ switch (log_format) {
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
+ return mag_y();
+ case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
+ return mag_y();
+ default:
+ return AltosLib.MISSING;
+ }
+ }
+
+ private int mag_through() {
+ return mag_z();
+ }
+
+
private int accel() { return data16(26); }
/* AO_LOG_TEMP_VOLT elements */
@@ -138,16 +233,16 @@ public class AltosEepromRecordMega extends AltosEepromRecord {
listener.set_pressure(pt.pres);
listener.set_temperature(pt.temp);
- int accel_along = accel_y();
- int accel_across = accel_x();
- int accel_through = accel_z();
- int gyro_roll = gyro_y();
- int gyro_pitch = gyro_x();
- int gyro_yaw = gyro_z();
+ int accel_along = accel_along();
+ int accel_across = accel_across();
+ int accel_through = accel_through();
+ int gyro_roll = gyro_roll();
+ int gyro_pitch = gyro_pitch();
+ int gyro_yaw = gyro_yaw();
- int mag_along = mag_y();
- int mag_across = mag_x();
- int mag_through = mag_z();
+ int mag_along = mag_along();
+ int mag_across = mag_across();
+ int mag_through = mag_through();
if (log_format == AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD)
cal_data.check_imu_wrap(gyro_roll, gyro_pitch, gyro_yaw);
diff --git a/altoslib/AltosEepromRecordSet.java b/altoslib/AltosEepromRecordSet.java
index 27f81df6..e26a1e00 100644
--- a/altoslib/AltosEepromRecordSet.java
+++ b/altoslib/AltosEepromRecordSet.java
@@ -71,6 +71,7 @@ public class AltosEepromRecordSet implements AltosRecordSet {
case AltosLib.AO_LOG_FORMAT_TELEMEGA:
case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
+ case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
record = new AltosEepromRecordMega(eeprom);
break;
case AltosLib.AO_LOG_FORMAT_TELEMETRUM:
diff --git a/altoslib/AltosFlash.java b/altoslib/AltosFlash.java
index e6b05713..434a0265 100644
--- a/altoslib/AltosFlash.java
+++ b/altoslib/AltosFlash.java
@@ -331,9 +331,13 @@ public class AltosFlash extends AltosProgrammer {
rom_config = romconfig;
}
- public AltosRomconfig target_romconfig() throws InterruptedException {
+ public AltosRomconfig target_romconfig(AltosUsbId usb_id, String usb_product) throws InterruptedException {
if (!check_rom_config())
return null;
+ if (rom_config.usb_id == null)
+ rom_config.usb_id = usb_id;
+ if (rom_config.usb_product == null)
+ rom_config.usb_product = usb_product;
return rom_config;
}
diff --git a/altoslib/AltosHexsym.java b/altoslib/AltosHexsym.java
index b1323484..a2ba6935 100644
--- a/altoslib/AltosHexsym.java
+++ b/altoslib/AltosHexsym.java
@@ -24,8 +24,12 @@ public class AltosHexsym {
final static long invalid_addr = 0xffffffff;
+ public String toString() {
+ return String.format("%s:0x%x", name, address);
+ }
+
public AltosHexsym(String name, long address) {
this.name = name;
this.address = address;
}
-} \ No newline at end of file
+}
diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java
index 88a65e63..a68ccac7 100644
--- a/altoslib/AltosIdleFetch.java
+++ b/altoslib/AltosIdleFetch.java
@@ -32,7 +32,7 @@ class AltosIdler {
static final int idle_mag = 2;
static final int idle_mma655x = 4;
static final int idle_ms5607 = 5;
-
+ static final int idle_adxl375 = 6;
static final int idle_sensor_tm = 10;
static final int idle_sensor_metrum = 11;
@@ -40,8 +40,9 @@ class AltosIdler {
static final int idle_sensor_emini1 = 13;
static final int idle_sensor_emini2 = 14;
static final int idle_sensor_tmini2 = 15;
- static final int idle_sensor_tgps = 16;
- static final int idle_sensor_tmini3 = 17;
+ static final int idle_sensor_tgps1 = 16;
+ static final int idle_sensor_tgps2 = 17;
+ static final int idle_sensor_tmini3 = 18;
public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException, TimeoutException, AltosUnknownProduct {
for (int idler : idlers) {
@@ -58,6 +59,9 @@ class AltosIdler {
case idle_mma655x:
AltosMma655x.provide_data(listener, link);
break;
+ case idle_adxl375:
+ AltosAdxl375.provide_data(listener, link);
+ break;
case idle_ms5607:
AltosMs5607.provide_data(listener, link);
break;
@@ -79,8 +83,11 @@ class AltosIdler {
case idle_sensor_tmini2:
AltosSensorTMini2.provide_data(listener, link);
break;
- case idle_sensor_tgps:
- AltosSensorTGPS.provide_data(listener, link);
+ case idle_sensor_tgps1:
+ AltosSensorTGPS1.provide_data(listener, link);
+ break;
+ case idle_sensor_tgps2:
+ AltosSensorTGPS2.provide_data(listener, link);
break;
case idle_sensor_tmini3:
AltosSensorTMini3.provide_data(listener, link);
@@ -157,14 +164,22 @@ public class AltosIdleFetch implements AltosDataProvider {
AltosIdler.idle_ms5607,
AltosIdler.idle_imu,
AltosIdler.idle_sensor_mega),
- new AltosIdler("EasyMega",
+ new AltosIdler("EasyMega-v1",
AltosIdler.idle_mma655x,
AltosIdler.idle_ms5607,
AltosIdler.idle_imu, AltosIdler.idle_mag,
AltosIdler.idle_sensor_mega),
- new AltosIdler("TeleGPS",
+ new AltosIdler("EasyMega-v2",
+ AltosIdler.idle_adxl375,
+ AltosIdler.idle_ms5607,
+ AltosIdler.idle_imu,
+ AltosIdler.idle_sensor_mega),
+ new AltosIdler("TeleGPS-v1",
+ AltosIdler.idle_gps,
+ AltosIdler.idle_sensor_tgps1),
+ new AltosIdler("TeleGPS-v2",
AltosIdler.idle_gps,
- AltosIdler.idle_sensor_tgps),
+ AltosIdler.idle_sensor_tgps2),
};
AltosLink link;
diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java
index 8b0170ae..93567c06 100644
--- a/altoslib/AltosLib.java
+++ b/altoslib/AltosLib.java
@@ -374,6 +374,7 @@ public class AltosLib {
public static final int AO_LOG_FORMAT_TELEFIRETWO = 13;
public static final int AO_LOG_FORMAT_EASYMINI2 = 14;
public static final int AO_LOG_FORMAT_TELEMEGA_3 = 15;
+ public static final int AO_LOG_FORMAT_EASYMEGA_2 = 16;
public static final int AO_LOG_FORMAT_NONE = 127;
public static boolean isspace(int c) {
diff --git a/altoslib/AltosProgrammer.java b/altoslib/AltosProgrammer.java
index 1872392d..f87e334c 100644
--- a/altoslib/AltosProgrammer.java
+++ b/altoslib/AltosProgrammer.java
@@ -28,7 +28,7 @@ public abstract class AltosProgrammer {
abstract public void abort();
- abstract public AltosRomconfig target_romconfig() throws InterruptedException;
+ abstract public AltosRomconfig target_romconfig(AltosUsbId usb_id, String usb_product) throws InterruptedException;
abstract public AltosRomconfig image_romconfig();
diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java
index ebeb76f3..00811ce7 100644
--- a/altoslib/AltosRomconfig.java
+++ b/altoslib/AltosRomconfig.java
@@ -273,6 +273,14 @@ public class AltosRomconfig implements AltosUnitInfoListener {
throw new IOException("writing new rom config failed\n");
}
+ public String toString() {
+ return String.format("valid %b version %d serial %d radio %d usb %04x:%04x %s",
+ valid, version, serial_number, radio_calibration,
+ usb_id == null ? 0 : usb_id.vid,
+ usb_id == null ? 0 : usb_id.pid,
+ usb_product == null ? "unknown" : usb_product);
+ }
+
public AltosRomconfig(int in_serial_number, int in_radio_calibration) {
valid = true;
version = 1;
@@ -282,7 +290,7 @@ public class AltosRomconfig implements AltosUnitInfoListener {
}
public boolean valid() {
- return valid && serial_number != 0;
+ return valid;
}
public AltosRomconfig() {
diff --git a/altoslib/AltosSelfFlash.java b/altoslib/AltosSelfFlash.java
index 0250cce7..70a5ced5 100644
--- a/altoslib/AltosSelfFlash.java
+++ b/altoslib/AltosSelfFlash.java
@@ -184,9 +184,13 @@ public class AltosSelfFlash extends AltosProgrammer {
rom_config = romconfig;
}
- public AltosRomconfig target_romconfig() throws InterruptedException {
+ public AltosRomconfig target_romconfig(AltosUsbId usb_id, String usb_product) throws InterruptedException {
if (!check_rom_config())
return null;
+ if (rom_config.usb_id == null)
+ rom_config.usb_id = usb_id;
+ if (rom_config.usb_product == null)
+ rom_config.usb_product = usb_product;
return rom_config;
}
diff --git a/altoslib/AltosSensorTGPS.java b/altoslib/AltosSensorTGPS1.java
index 485e8b3c..cdd19217 100644
--- a/altoslib/AltosSensorTGPS.java
+++ b/altoslib/AltosSensorTGPS1.java
@@ -20,23 +20,23 @@ package org.altusmetrum.altoslib_13;
import java.util.concurrent.TimeoutException;
-public class AltosSensorTGPS {
+public class AltosSensorTGPS1 {
public int tick;
public int batt;
static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
try {
- AltosSensorTGPS sensor_tgps = new AltosSensorTGPS(link);
+ AltosSensorTGPS1 sensor_tgps = new AltosSensorTGPS1(link);
if (sensor_tgps == null)
return;
- listener.set_battery_voltage(AltosConvert.tele_gps_voltage(sensor_tgps.batt));
+ listener.set_battery_voltage(AltosConvert.tele_gps_1_voltage(sensor_tgps.batt));
} catch (TimeoutException te) {
}
}
- public AltosSensorTGPS(AltosLink link) throws InterruptedException, TimeoutException {
+ public AltosSensorTGPS1(AltosLink link) throws InterruptedException, TimeoutException {
String[] items = link.adc();
for (int i = 0; i < items.length - 1;) {
if (items[i].equals("tick:")) {
diff --git a/altoslib/AltosSensorTGPS2.java b/altoslib/AltosSensorTGPS2.java
new file mode 100644
index 00000000..ceca977e
--- /dev/null
+++ b/altoslib/AltosSensorTGPS2.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2015 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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_13;
+
+import java.util.concurrent.TimeoutException;
+
+public class AltosSensorTGPS2 {
+ public int tick;
+ public int batt;
+
+ static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
+ try {
+ AltosSensorTGPS2 sensor_tgps = new AltosSensorTGPS2(link);
+
+ if (sensor_tgps == null)
+ return;
+ listener.set_battery_voltage(AltosConvert.tele_gps_2_voltage(sensor_tgps.batt));
+
+ } catch (TimeoutException te) {
+ }
+ }
+
+ public AltosSensorTGPS2(AltosLink link) throws InterruptedException, TimeoutException {
+ String[] items = link.adc();
+ for (int i = 0; i < items.length - 1;) {
+ if (items[i].equals("tick:")) {
+ tick = 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/AltosTelemetryConfiguration.java b/altoslib/AltosTelemetryConfiguration.java
index 4411a77d..22fd8568 100644
--- a/altoslib/AltosTelemetryConfiguration.java
+++ b/altoslib/AltosTelemetryConfiguration.java
@@ -43,9 +43,15 @@ public class AltosTelemetryConfiguration extends AltosTelemetryStandard {
listener.set_device_type(device_type());
cal_data.set_flight(flight());
cal_data.set_config(config_major(), config_minor(), flight_log_max());
- if (device_type() == AltosLib.product_telegps)
- listener.set_battery_voltage(AltosConvert.tele_gps_voltage(v_batt()));
- else
+ if (device_type() == AltosLib.product_telegps) {
+ int v_batt = v_batt();
+ double batt;
+ if (v_batt > 4095)
+ batt = AltosConvert.tele_gps_1_voltage(v_batt);
+ else
+ batt = AltosConvert.tele_gps_2_voltage(v_batt);
+ listener.set_battery_voltage(batt);
+ } else
cal_data.set_flight_params(apogee_delay() / 100.0, main_deploy());
cal_data.set_callsign(callsign());
diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am
index 92976332..447830e5 100644
--- a/altoslib/Makefile.am
+++ b/altoslib/Makefile.am
@@ -28,6 +28,7 @@ altoslib_JAVA = \
AltosLib.java \
AltosAccelCal.java \
AltosAccelCalListener.java \
+ AltosAdxl375.java \
AltosCalData.java \
AltosCompanion.java \
AltosConfigData.java \
@@ -107,7 +108,8 @@ altoslib_JAVA = \
AltosSensorTMini3.java \
AltosSensorMega.java \
AltosSensorMetrum.java \
- AltosSensorTGPS.java \
+ AltosSensorTGPS1.java \
+ AltosSensorTGPS2.java \
AltosState.java \
AltosStateName.java \
AltosStringInputStream.java \