X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosEepromMetrum2.java;h=f685b3ce0e7eb2355d5f9e9fc1dca9fb57c0fcf5;hb=c296acd643698d0128e2f58f91a9cfeea63f580a;hp=5a616e6cd835aeff3cf781f2569a2d64deb7410b;hpb=77dc89ed5b7bf8f5b3fa3b6131660f1a98f583ea;p=fw%2Faltos diff --git a/altoslib/AltosEepromMetrum2.java b/altoslib/AltosEepromMetrum2.java index 5a616e6c..f685b3ce 100644 --- a/altoslib/AltosEepromMetrum2.java +++ b/altoslib/AltosEepromMetrum2.java @@ -3,7 +3,8 @@ * * 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. + * 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 @@ -15,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_1; +package org.altusmetrum.altoslib_11; import java.io.*; import java.util.*; @@ -49,7 +50,8 @@ public class AltosEepromMetrum2 extends AltosEeprom { /* AO_LOG_GPS_POS elements */ public int latitude() { return data32(0); } public int longitude() { return data32(4); } - public int altitude() { return data16(8); } + public int altitude_low() { return data16(8); } + public int altitude_high() { return data16(10); } /* AO_LOG_GPS_TIME elements */ public int hour() { return data8(0); } @@ -59,7 +61,8 @@ public class AltosEepromMetrum2 extends AltosEeprom { public int year() { return data8(4); } public int month() { return data8(5); } public int day() { return data8(6); } - + public int pdop() { return data8(7); } + /* AO_LOG_GPS_SAT elements */ public int nsat() { return data8(0); } public int more() { return data8(1); } @@ -71,6 +74,8 @@ public class AltosEepromMetrum2 extends AltosEeprom { } public void update_state(AltosState state) { + super.update_state(state); + AltosGPS gps; /* Flush any pending GPS changes */ @@ -89,11 +94,8 @@ public class AltosEepromMetrum2 extends AltosEeprom { } } - if (cmd != AltosLib.AO_LOG_FLIGHT) - state.set_tick(tick); switch (cmd) { case AltosLib.AO_LOG_FLIGHT: - state.set_boost_tick(tick); state.set_flight(flight()); state.set_ground_accel(ground_accel()); state.set_ground_pressure(ground_pres()); @@ -115,13 +117,16 @@ public class AltosEepromMetrum2 extends AltosEeprom { break; case AltosLib.AO_LOG_GPS_POS: - gps = state.make_temp_gps(); + gps = state.make_temp_gps(false); gps.lat = latitude() / 1e7; gps.lon = longitude() / 1e7; - gps.alt = altitude(); + if (state.altitude_32()) + gps.alt = (altitude_low() & 0xffff) | (altitude_high() << 16); + else + gps.alt = altitude_low(); break; case AltosLib.AO_LOG_GPS_TIME: - gps = state.make_temp_gps(); + gps = state.make_temp_gps(false); gps.hour = hour(); gps.minute = minute(); @@ -134,13 +139,13 @@ public class AltosEepromMetrum2 extends AltosEeprom { gps.nsat = (flags & AltosLib.AO_GPS_NUM_SAT_MASK) >> AltosLib.AO_GPS_NUM_SAT_SHIFT; - gps.year = year(); + gps.year = 2000 + year(); gps.month = month(); gps.day = day(); + gps.pdop = pdop() / 10.0; break; case AltosLib.AO_LOG_GPS_SAT: - state.set_tick(tick); - gps = state.make_temp_gps(); + gps = state.make_temp_gps(true); int n = nsat(); for (int i = 0; i < n; i++) @@ -154,7 +159,7 @@ public class AltosEepromMetrum2 extends AltosEeprom { } static public LinkedList read(FileInputStream input) { - LinkedList megas = new LinkedList(); + LinkedList metrums = new LinkedList(); for (;;) { try { @@ -162,9 +167,10 @@ public class AltosEepromMetrum2 extends AltosEeprom { if (line == null) break; try { - AltosEepromMetrum2 mega = new AltosEepromMetrum2(line); - if (mega.cmd != AltosLib.AO_LOG_INVALID) - megas.add(mega); + AltosEepromMetrum2 metrum = new AltosEepromMetrum2(line); + + if (metrum.cmd != AltosLib.AO_LOG_INVALID) + metrums.add(metrum); } catch (Exception e) { System.out.printf ("exception\n"); } @@ -173,6 +179,6 @@ public class AltosEepromMetrum2 extends AltosEeprom { } } - return megas; + return metrums; } }