X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosConfigData.java;h=a97b996fa89800ba1000791196d933817ff32bc1;hb=76c5e6bf7ecc30ae77a9744a4af26dca3dc46254;hp=35a8602db4097651b149700ba6dfe863e36eead2;hpb=eee9f6128da146b0e9c711d49b2a3eb49a95aaf3;p=fw%2Faltos diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 35a8602d..a97b996f 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_13; 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; @@ -199,7 +200,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 +277,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; @@ -309,6 +313,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 +326,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 +343,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 +428,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; } } @@ -558,6 +564,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 +586,26 @@ 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; + } + 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; + } + throw new AltosUnknownProduct(product); + } + public void get_values(AltosConfigValues source) throws AltosConfigDataException { /* HAS_FLIGHT */