summaryrefslogtreecommitdiff
path: root/include/math_util.h
diff options
context:
space:
mode:
authorChing-Kang Yen <chingkang@chromium.org>2020-07-31 02:04:51 +0800
committerCommit Bot <commit-bot@chromium.org>2020-09-03 07:15:42 +0000
commit53a2ee971270fcf759766a83496da05685ec8151 (patch)
tree03c7627b41a63a53ac54e0158cb526c8b9982ffb /include/math_util.h
parent90c79d90699268d31a3a2d8f48af5955e493005b (diff)
downloadchrome-ec-53a2ee971270fcf759766a83496da05685ec8151.tar.gz
common: implement body_detection state machine
Implement body_detection state machine. Detect whether the user is close to the devices or not. Use the variance of acceleration from accelerometer to compute the motion confidence. If motion confidence is high enough, set the motion state to ON_BODY. If low enough, set it to OFF_BODY. Also, make gesture_cal() be called only when the gesture sensor data is updated. BRANCH=None BUG=b:123434029 TEST=make buildall, flash the ec, watch the ec console log Change-Id: If886b7f9fc505ef4db4d7abb08194b8f866121bb Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2230938 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'include/math_util.h')
-rw-r--r--include/math_util.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/math_util.h b/include/math_util.h
index 6b60d4a1d6..266bde6743 100644
--- a/include/math_util.h
+++ b/include/math_util.h
@@ -48,6 +48,9 @@ typedef int64_t fp_inter_t;
#endif
+/* Some useful math functions. Use with integers only! */
+#define POW2(x) ((x) * (x))
+
/*
* Fixed-point addition and subtraction can be done directly, because they
* work identically.