summaryrefslogtreecommitdiff
path: root/include/motion_lid.h
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2018-12-17 15:14:00 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-03-26 17:27:00 -0700
commit40f9e2fc0f2354e033553131fd63cfb9f755a2e2 (patch)
tree1498d7190aece44697f3bee0e797565391f99750 /include/motion_lid.h
parent4a48404aeea58bfe0c31d5fea554b5329a223131 (diff)
downloadchrome-ec-40f9e2fc0f2354e033553131fd63cfb9f755a2e2.tar.gz
motion_lid: Rewrite lid angle calculation based on chromium code
Use code from ash/wm/tablet_mode/tablet_mode_controller.cc, in particular TabletModeController::HandleHingeRotation() to calculate lid angle. Add unit tests based on ash/wm/tablet_mode/tablet_mode_controller_unittest.cc and the data file accelerometer_test_data_literals.cc. BUG=b:120346412 BRANCH=none TEST=Check unit tests pass, check it compile on FPU based EC, EC without FPU and no 64 bit support (ampton). Check lid calculation is correct on eve: - with "while true ; do ectool motionsense lid_angle ; sleep 1 ; done" Check when hinge is almost vertical lid angle is close to constant or marked are unrieliable. Check when shaking device, lid angle is also unreliable Check with evtest SW_TABLET_MODE event is trigger when lid angle is available and cross 180 region. Change-Id: I545f7333ed9b53accedb75f238f747f66bae1f5d Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1388844 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'include/motion_lid.h')
-rw-r--r--include/motion_lid.h28
1 files changed, 8 insertions, 20 deletions
diff --git a/include/motion_lid.h b/include/motion_lid.h
index 110d614811..2816a70bdb 100644
--- a/include/motion_lid.h
+++ b/include/motion_lid.h
@@ -11,27 +11,15 @@
#include "host_command.h"
#include "math_util.h"
-/**
- * This structure defines all of the data needed to specify the orientation
- * of the base and lid accelerometers in order to calculate the lid angle.
+/*
+ * We will change our tablet mode status when we are "convinced" that it has
+ * changed. This means we will have to consecutively calculate our new tablet
+ * mode while the angle is stable and come to the same conclusion. The number
+ * of consecutive calculations is the debounce count with an interval between
+ * readings set by the motion_sense task. This should avoid spurious forces
+ * that may trigger false transitions of the tablet mode switch.
*/
-struct accel_orientation {
- /* Rotation matrix to rotate positive 90 degrees around the hinge. */
- mat33_fp_t rot_hinge_90;
-
- /*
- * Rotation matrix to rotate 180 degrees around the hinge. The value
- * here should be rot_hinge_90 ^ 2.
- */
- mat33_fp_t rot_hinge_180;
-
- /* Vector pointing along hinge axis. */
- intv3_t hinge_axis;
-};
-
-/* Link global structure for orientation. This must be defined in board.c. */
-extern const struct accel_orientation acc_orient;
-
+#define TABLET_MODE_DEBOUNCE_COUNT 3
/**
* Get last calculated lid angle. Note, the lid angle calculated by the EC