+ /* 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:
+ case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_UP:
+ return accel_cal_plus_cooked;
+ case AltosLib.AO_PAD_ORIENTATION_ANTENNA_DOWN:
+ case AltosLib.AO_PAD_ORIENTATION_WORDS_UPSIDEDOWN:
+ case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_DOWN:
+ return invert_accel_value(accel_cal_minus_cooked);
+ default:
+ return AltosLib.MISSING;
+ }
+ }
+
+ /* 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:
+ case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_UP:
+ return accel_cal_minus_cooked;
+ case AltosLib.AO_PAD_ORIENTATION_ANTENNA_DOWN:
+ case AltosLib.AO_PAD_ORIENTATION_WORDS_UPSIDEDOWN:
+ case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_DOWN:
+ return invert_accel_value(accel_cal_plus_cooked);
+ default:
+ return AltosLib.MISSING;
+ }
+ }
+
+ /* Once we have all of the values from the config data, compute the
+ * accel cal values relative to Antenna Up orientation.
+ */
+ 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)
+ {
+ switch (pad_orientation) {
+ case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP:
+ case AltosLib.AO_PAD_ORIENTATION_WORDS_UPRIGHT:
+ case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_UP:
+ 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:
+ case AltosLib.AO_PAD_ORIENTATION_WORDS_UPSIDEDOWN:
+ case AltosLib.AO_PAD_ORIENTATION_BIG_PARTS_DOWN:
+ 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:
+ break;
+ }
+ }
+ }
+