From 6dc5b468f84f04f28ea83757cee0486f654fb234 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 29 Oct 2020 11:40:25 -0700 Subject: [PATCH] altoslib: Delay accel cal value adjustment until data all read Instead of trying to compute these values as soon as the necessary data are available, delay until all data are available as which data are necessary depends on the target device, and some target devices don't have some of the data values at all. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index bb7f5bcc..ea7b63fa 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -321,6 +321,9 @@ public class AltosConfigData { /* Return + accel calibration relative to a specific pad orientation */ public int accel_cal_plus(int pad_orientation) { adjust_accel_cal(); + if (!accel_cal_adjusted) + return AltosLib.MISSING; + switch (pad_orientation) { case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP: case AltosLib.AO_PAD_ORIENTATION_WORDS_UPRIGHT: @@ -338,6 +341,9 @@ public class AltosConfigData { /* Return - accel calibration relative to a specific pad orientation */ public int accel_cal_minus(int pad_orientation) { adjust_accel_cal(); + if (!accel_cal_adjusted) + return AltosLib.MISSING; + switch (pad_orientation) { case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP: case AltosLib.AO_PAD_ORIENTATION_WORDS_UPRIGHT: @@ -357,6 +363,7 @@ public class AltosConfigData { */ private void adjust_accel_cal() { if (!accel_cal_adjusted && + product != null && pad_orientation != AltosLib.MISSING && accel_cal_plus != AltosLib.MISSING && accel_cal_minus != AltosLib.MISSING) @@ -538,9 +545,6 @@ public class AltosConfigData { } } } catch (Exception e) {} - - /* Fix accel cal as soon as all of the necessary values appear */ - adjust_accel_cal(); } public AltosConfigData() { @@ -914,5 +918,6 @@ public class AltosConfigData { read_link(link, "done"); break; } + adjust_accel_cal(); } } -- 2.30.2