mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-07 16:11:43 +00:00
Motion sense calculations do not require huge amounts of precision, so
fixed point is plenty accurate. And fixed point works on Cortex-M0,
which lacks a FPU.
BUG=chrome-os-partner:36126
BRANCH=minnie (samus already works with the FPU, but could grab this if we
want additional testing)
TEST=manual
1. Boot system
2. At EC console: accelinfo on 250
3. Move lid through several different angles (30 degrees to max open) and
see that it updates correctly and relatively smoothly. A few degrees
of angle jitter is normal.
4. At several angles, rotate the chromebook around and see that the lid
angle remains relatively stable.
5. If the hinge is made normal to the ground (or within 15 degrees of
vertical), the angle should read 500, since the acceleration vectors
don't yield good results in that orientation (for either fixed or float
math).
And run 'make buildall -j', which tests arc_cos() and lid angle calculations
Change-Id: I70a0d08b8914629a3e21ae5578cbe8e50f29ad68
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/244116
Reviewed-by: Alec Berg <alecaberg@chromium.org>
52 lines
1.4 KiB
C
52 lines
1.4 KiB
C
/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* Header for motion_lid.h */
|
|
|
|
#ifndef __CROS_EC_MOTION_LID_H
|
|
#define __CROS_EC_MOTION_LID_H
|
|
|
|
/* Anything outside of lid angle range [-180, 180] should work. */
|
|
#define LID_ANGLE_UNRELIABLE 500
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
struct accel_orientation {
|
|
/* Rotation matrix to rotate positive 90 degrees around the hinge. */
|
|
matrix_3x3_t rot_hinge_90;
|
|
|
|
/*
|
|
* Rotation matrix to rotate 180 degrees around the hinge. The value
|
|
* here should be rot_hinge_90 ^ 2.
|
|
*/
|
|
matrix_3x3_t rot_hinge_180;
|
|
|
|
/* Vector pointing along hinge axis. */
|
|
vector_3_t hinge_axis;
|
|
};
|
|
|
|
/* Link global structure for orientation. This must be defined in board.c. */
|
|
extern const struct accel_orientation acc_orient;
|
|
|
|
|
|
/**
|
|
* Get last calculated lid angle. Note, the lid angle calculated by the EC
|
|
* is un-calibrated and is an approximate angle.
|
|
*
|
|
* @return lid angle in degrees in range [0, 360], or LID_ANGLE_UNRELIABLE
|
|
* if the lid angle can't be determined.
|
|
*/
|
|
int motion_lid_get_angle(void);
|
|
|
|
int host_cmd_motion_lid(struct host_cmd_handler_args *args);
|
|
|
|
void motion_lid_calc(void);
|
|
|
|
#endif /* __CROS_EC_MOTION_LID_H */
|
|
|
|
|