From: Keith Packard Date: Wed, 30 May 2018 18:38:24 +0000 (-0700) Subject: altoslib: Revert field name changes for accel cal values X-Git-Tag: 1.8.6~1^2~36 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=82ed4f5c45b1a9f114577a59fac546c81d69f810;hp=484ffebc54048bbe276e0e2c0e2ab52c6a1761c1 altoslib: Revert field name changes for accel cal values These names get written in the JSON part of all .eeprom files, so we can't change the names or the values won't be read and written correctly. Signed-off-by: Keith Packard --- diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 35a8602d..8d0bb479 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -22,6 +22,7 @@ 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; @@ -273,8 +274,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 +310,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 +323,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 +340,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 +425,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; } }