diff options
author | Ching-Kang Yen <chingkang@chromium.org> | 2020-07-31 02:04:51 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-09-03 07:15:42 +0000 |
commit | 53a2ee971270fcf759766a83496da05685ec8151 (patch) | |
tree | 03c7627b41a63a53ac54e0158cb526c8b9982ffb /include/body_detection.h | |
parent | 90c79d90699268d31a3a2d8f48af5955e493005b (diff) | |
download | chrome-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/body_detection.h')
-rw-r--r-- | include/body_detection.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/body_detection.h b/include/body_detection.h new file mode 100644 index 0000000000..d3c1865e36 --- /dev/null +++ b/include/body_detection.h @@ -0,0 +1,33 @@ +/* Copyright 2020 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. + */ + +#ifndef __CROS_EC_BODY_DETECTION_H +#define __CROS_EC_BODY_DETECTION_H + +#include <stdint.h> + +enum body_detect_states { + BODY_DETECTION_OFF_BODY, + BODY_DETECTION_ON_BODY +}; + +/* get/set the state of body detection */ +enum body_detect_states body_detect_get_state(void); +void body_detect_change_state(enum body_detect_states state); + +/* Reset the data. This should be called when ODR is changed*/ +void body_detect_reset(void); + +/* Body detect main function. This should be called when new sensor data come */ +void body_detect(void); + +/* enable/disable body detection */ +void body_detect_set_enable(int enable); + +/* get enable state of body detection */ +int body_detect_get_enable(void); + + +#endif /* __CROS_EC_BODY_DETECTION_H */ |