diff options
author | Randall Spangler <rspangler@chromium.org> | 2015-01-28 15:23:55 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-02-05 19:41:41 +0000 |
commit | fd6a6900f786d47fc5364f9013356a741da5c113 (patch) | |
tree | b701989e3564488dceb5ef965a1123aad22adcb9 /test | |
parent | df28140cc81bc87b4a278a2876db2c52158996c6 (diff) | |
download | chrome-ec-fd6a6900f786d47fc5364f9013356a741da5c113.tar.gz |
Convert motion sense calculations to fixed point.
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/math_util.c | 2 | ||||
-rw-r--r-- | test/motion_lid.c | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/test/math_util.c b/test/math_util.c index 46087e9f33..e563d8dd02 100644 --- a/test/math_util.c +++ b/test/math_util.c @@ -37,7 +37,7 @@ static int test_acos(void) /* Test a handful of values. */ for (test = -1.0; test <= 1.0; test += 0.01) { - a = arc_cos(test); + a = FP_TO_FLOAT(arc_cos(FLOAT_TO_FP(test))); b = acos(test) * RAD_TO_DEG; TEST_ASSERT(IS_FLOAT_EQUAL(a, b, ACOS_TOLERANCE_DEG)); } diff --git a/test/motion_lid.c b/test/motion_lid.c index e0f1e68e7c..a358a5056c 100644 --- a/test/motion_lid.c +++ b/test/motion_lid.c @@ -6,6 +6,7 @@ */ #include <math.h> +#include <stdio.h> #include "accelgyro.h" #include "common.h" @@ -89,15 +90,15 @@ const struct accelgyro_drv test_motion_sense = { }; const matrix_3x3_t base_standard_ref = { - { 1, 0, 0}, - { 0, 1, 0}, - { 0, 0, 1} + { FLOAT_TO_FP(1), 0, 0}, + { 0, FLOAT_TO_FP(1), 0}, + { 0, 0, FLOAT_TO_FP(1)} }; const matrix_3x3_t lid_standard_ref = { - { 1, 0, 0}, - { 1, 0, 0}, - { 0, 0, 1} + { FLOAT_TO_FP(1), 0, 0}, + { FLOAT_TO_FP(1), 0, 0}, + { 0, 0, FLOAT_TO_FP(1)} }; struct motion_sensor_t motion_sensors[] = { |