X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosConfigData.java;h=3c5f6c06678977f6a7790c850e125a543dbc0611;hb=f32488556ce25e439fbab941f8019db639824f98;hp=35a8602db4097651b149700ba6dfe863e36eead2;hpb=eee9f6128da146b0e9c711d49b2a3eb49a95aaf3;p=fw%2Faltos diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 35a8602d..3c5f6c06 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -16,12 +16,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_12; +package org.altusmetrum.altoslib_14; import java.util.*; import java.text.*; import java.util.concurrent.*; +/* Don't change the field names in this structure; they're part of all .eeprom files */ public class AltosConfigData { /* Version information */ @@ -52,7 +53,7 @@ public class AltosConfigData { public int radio_setting; /* HAS_ACCEL */ - private int accel_cal_plus_raw, accel_cal_minus_raw; + public int accel_cal_plus, accel_cal_minus; private int accel_cal_plus_cooked, accel_cal_minus_cooked; private boolean accel_cal_adjusted; public int pad_orientation; @@ -77,6 +78,7 @@ public class AltosConfigData { public int aprs_interval; public int aprs_ssid; public int aprs_format; + public int aprs_offset; /* HAS_BEEP */ public int beep; @@ -199,7 +201,10 @@ public class AltosConfigData { case AltosLib.AO_LOG_FORMAT_TELEMETRUM: case AltosLib.AO_LOG_FORMAT_TELEMEGA: case AltosLib.AO_LOG_FORMAT_TELEMEGA_3: + case AltosLib.AO_LOG_FORMAT_TELEMEGA_4: return 4095 - value; + case AltosLib.AO_LOG_FORMAT_EASYMEGA_2: + return -value; default: return AltosLib.MISSING; } @@ -273,8 +278,8 @@ public class AltosConfigData { accel_cal_plus_cooked = AltosLib.MISSING; accel_cal_minus_cooked = AltosLib.MISSING; - accel_cal_plus_raw = AltosLib.MISSING; - accel_cal_minus_raw = AltosLib.MISSING; + accel_cal_plus = AltosLib.MISSING; + accel_cal_minus = AltosLib.MISSING; pad_orientation = AltosLib.MISSING; accel_cal_adjusted = false; @@ -292,6 +297,7 @@ public class AltosConfigData { aprs_interval = AltosLib.MISSING; aprs_ssid = AltosLib.MISSING; aprs_format = AltosLib.MISSING; + aprs_offset = AltosLib.MISSING; beep = AltosLib.MISSING; @@ -309,6 +315,7 @@ public class AltosConfigData { /* Return + accel calibration relative to a specific pad orientation */ public int accel_cal_plus(int pad_orientation) { + adjust_accel_cal(); switch (pad_orientation) { case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP: return accel_cal_plus_cooked; @@ -321,6 +328,7 @@ public class AltosConfigData { /* Return - accel calibration relative to a specific pad orientation */ public int accel_cal_minus(int pad_orientation) { + adjust_accel_cal(); switch (pad_orientation) { case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP: return accel_cal_minus_cooked; @@ -337,19 +345,19 @@ public class AltosConfigData { private void adjust_accel_cal() { if (!accel_cal_adjusted && pad_orientation != AltosLib.MISSING && - accel_cal_plus_raw != AltosLib.MISSING && - accel_cal_minus_raw != AltosLib.MISSING && + accel_cal_plus != AltosLib.MISSING && + accel_cal_minus != AltosLib.MISSING && log_format != AltosLib.AO_LOG_FORMAT_UNKNOWN) { switch (pad_orientation) { case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP: - accel_cal_plus_cooked = accel_cal_plus_raw; - accel_cal_minus_cooked = accel_cal_minus_raw; + accel_cal_plus_cooked = accel_cal_plus; + accel_cal_minus_cooked = accel_cal_minus; accel_cal_adjusted = true; break; case AltosLib.AO_PAD_ORIENTATION_ANTENNA_DOWN: - accel_cal_plus_cooked = invert_accel_value(accel_cal_minus_raw); - accel_cal_minus_cooked = invert_accel_value(accel_cal_plus_raw); + accel_cal_plus_cooked = invert_accel_value(accel_cal_minus); + accel_cal_minus_cooked = invert_accel_value(accel_cal_plus); accel_cal_adjusted = true; break; default: @@ -422,8 +430,8 @@ public class AltosConfigData { if (line.startsWith("Accel cal")) { String[] bits = line.split("\\s+"); if (bits.length >= 6) { - accel_cal_plus_raw = Integer.parseInt(bits[3]); - accel_cal_minus_raw = Integer.parseInt(bits[5]); + accel_cal_plus = Integer.parseInt(bits[3]); + accel_cal_minus = Integer.parseInt(bits[5]); accel_cal_adjusted = false; } } @@ -459,6 +467,7 @@ public class AltosConfigData { try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {} try { aprs_ssid = get_int(line, "APRS SSID:"); } catch (Exception e) {} try { aprs_format = get_int(line, "APRS format:"); } catch (Exception e) {} + try { aprs_offset = get_int(line, "APRS offset:"); } catch (Exception e) {} /* HAS_BEEP */ try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {} @@ -558,6 +567,8 @@ public class AltosConfigData { return false; if (product.startsWith("TeleMetrum-v2")) return false; + if (product.startsWith("TeleMetrum-v3")) + return false; if (product.startsWith("EasyMega")) return false; return true; @@ -578,6 +589,30 @@ public class AltosConfigData { throw new AltosUnknownProduct(product); } + public boolean adxl375_inverted() throws AltosUnknownProduct { + if (product != null) { + if (product.startsWith("EasyMega-v2")) + return true; + if (product.startsWith("TeleMetrum-v3")) + return true; + if (product.startsWith("TeleMega-v4")) + return true; + } + throw new AltosUnknownProduct(product); + } + + public int adxl375_axis() throws AltosUnknownProduct { + if (product != null) { + if (product.startsWith("EasyMega-v2")) + return AltosAdxl375.X_AXIS; + if (product.startsWith("TeleMetrum-v3")) + return AltosAdxl375.X_AXIS; + if (product.startsWith("TeleMega-v4")) + return AltosAdxl375.X_AXIS; + } + throw new AltosUnknownProduct(product); + } + public void get_values(AltosConfigValues source) throws AltosConfigDataException { /* HAS_FLIGHT */ @@ -629,6 +664,8 @@ public class AltosConfigData { aprs_ssid = source.aprs_ssid(); if (aprs_format != AltosLib.MISSING) aprs_format = source.aprs_format(); + if (aprs_offset != AltosLib.MISSING) + aprs_offset = source.aprs_offset(); /* HAS_BEEP */ if (beep != AltosLib.MISSING) @@ -686,6 +723,7 @@ public class AltosConfigData { dest.set_aprs_interval(aprs_interval); dest.set_aprs_ssid(aprs_ssid); dest.set_aprs_format(aprs_format); + dest.set_aprs_offset(aprs_offset); dest.set_beep(beep); dest.set_tracker_motion(tracker_motion); dest.set_tracker_interval(tracker_interval); @@ -790,6 +828,8 @@ public class AltosConfigData { link.printf("c S %d\n", aprs_ssid); if (aprs_format != AltosLib.MISSING) link.printf("c C %d\n", aprs_format); + if (aprs_offset != AltosLib.MISSING) + link.printf("c O %d\n", aprs_offset); /* HAS_BEEP */ if (beep != AltosLib.MISSING)