summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/nautilus/board.h10
-rw-r--r--common/motion_lid.c20
-rw-r--r--include/config.h9
3 files changed, 24 insertions, 15 deletions
diff --git a/board/nautilus/board.h b/board/nautilus/board.h
index 74eced7a49..31c48f9b75 100644
--- a/board/nautilus/board.h
+++ b/board/nautilus/board.h
@@ -126,7 +126,15 @@
#define CONFIG_LID_ANGLE_UPDATE
#define CONFIG_LID_ANGLE_TABLET_MODE
#define CONFIG_LID_ANGLE_INVALID_CHECK
-/* Lower maximal ODR to 100Hz */
+/*
+ * Workound for b/79670788.
+ *
+ * Be more lenient when determining valid lid angles.
+ */
+#undef CONFIG_NOISY_MAGNITUDE_DEVIATION
+#define CONFIG_NOISY_MAGNITUDE_DEVIATION FLOAT_TO_FP(1.5)
+
+/* Lower maximal ODR to 100Hz. */
#define CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ 100000
/* FIFO size is in power of 2. */
diff --git a/common/motion_lid.c b/common/motion_lid.c
index 38efea172e..a7c9f13f3b 100644
--- a/common/motion_lid.c
+++ b/common/motion_lid.c
@@ -105,15 +105,6 @@ static int lid_angle_is_reliable;
#define DEBOUNCE_ANGLE_DELTA FLOAT_TO_FP(45)
/*
- * Since the accelerometers are on the same physical device, they should be
- * under the same acceleration. This constant, which mirrors
- * kNoisyMagnitudeDeviation used in Chromium, is an integer which defines the
- * maximum deviation in magnitude between the base and lid vectors. The units
- * are in m/s^2.
- */
-#define NOISY_MAGNITUDE_DEVIATION 1
-
-/*
* Define the accelerometer orientation matrices based on the standard
* reference frame in use (note: accel data is converted to standard ref
* frame before calculating lid angle).
@@ -280,8 +271,9 @@ static int calculate_lid_angle(const vector_3_t base, const vector_3_t lid,
scaled_lid[Z] * scaled_lid[Z]) >> 6;
/*
- * Check to see if they differ than more than NOISY_MAGNITUDE_DEVIATION.
- * If the vectors do, then the measured angle is unreliable.
+ * Check to see if they differ than more than
+ * CONFIG_NOISY_MAGNITUDE_DEVIATION. If the vectors do, then the
+ * measured angle is unreliable.
*
* Note, that we don't actually have to take the square root to get the
* magnitude, but we can work with the magnitudes squared directly as
@@ -297,10 +289,10 @@ static int calculate_lid_angle(const vector_3_t base, const vector_3_t lid,
* If we assume that the average acceleration should be about 1g, then
* we have:
*
- * (A^2 - B^2) < 2 * 1g * NOISY_MAGNITUDE_DEVIATION
+ * (A^2 - B^2) < 2 * 1g * CONFIG_NOISY_MAGNITUDE_DEVIATION
*/
- if (ABS(base_magnitude2 - lid_magnitude2) >
- (2 * 10 * NOISY_MAGNITUDE_DEVIATION))
+ if (FLOAT_TO_FP(ABS(base_magnitude2 - lid_magnitude2)) >
+ FLOAT_TO_FP(2 * 10 * CONFIG_NOISY_MAGNITUDE_DEVIATION))
reliable = 0;
#ifdef CONFIG_LID_ANGLE_INVALID_CHECK
diff --git a/include/config.h b/include/config.h
index 5bf4f302bc..c8980a9aaf 100644
--- a/include/config.h
+++ b/include/config.h
@@ -2126,6 +2126,15 @@
/* Do not try hold I/O pins at frozen level during deep sleep */
#undef CONFIG_NO_PINHOLD
+/*
+ * Since the accelerometers are on the same physical device, they should be
+ * under the same acceleration. This constant, which mirrors
+ * kNoisyMagnitudeDeviation used in Chromium, is an integer, 1, which defines
+ * the maximum deviation in magnitude between the base and lid vectors. The
+ * units are in m/s^2.
+ */
+#define CONFIG_NOISY_MAGNITUDE_DEVIATION FLOAT_TO_FP(1)
+
/* Support one-wire interface */
#undef CONFIG_ONEWIRE