diff options
author | Ching-Kang Yen <chingkang@chromium.org> | 2020-09-18 00:29:51 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-09-29 13:31:20 +0000 |
commit | 9513a63a626021b071199d02b7c73112eb746833 (patch) | |
tree | 17dd2259d9c0e1a617e0814f20785405b10cd17a /common/body_detection.c | |
parent | 17d47b68f8730a5404e9d2379a4b1a20c87d045b (diff) | |
download | chrome-ec-9513a63a626021b071199d02b7c73112eb746833.tar.gz |
common: body_detection: modify calculation of noise level
We used rms_noise^2 as noise level for body_detection. But, there are
still some different noise level based on different devices. Add the
CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR to adjust the noise_level.
Default value is 120%, since the 100% of the rms_noise^2 is not enough,
especially in 200Hz.
BRANCH=None
BUG=b:123434029
TEST=make buildall; make BOARD=ampton, re-flash the DUT, see if the body
detection works
Signed-off-by: Ching-Kang Yen <chingkang@chromium.org>
Change-Id: I2a7416b0bd8d0aac51d16c3aed9d962837f52c0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2416477
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Heng-ruey Hsu <henryhsu@chromium.org>
Diffstat (limited to 'common/body_detection.c')
-rw-r--r-- | common/body_detection.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/common/body_detection.c b/common/body_detection.c index 020314e71e..f7ea95c8c4 100644 --- a/common/body_detection.c +++ b/common/body_detection.c @@ -147,7 +147,16 @@ static void determine_threshold_scale(int range, int resolution, int rms_noise) const int data_1g = BIT(resolution - 1) / range; const int multiplier = POW2(data_1g); const int divisor = POW2(9800); - const int var_noise = POW2((int64_t)rms_noise) * POW2(98) / POW2(10000); + /* + * We are measuring the var(X) + var(Y), so theoretically, the + * var(noise) should be 2 * rms_noise^2. However, in most case, on a + * very stationary plane, the average of var(noise) are less than 2 * + * rms_noise^2. We can multiply the rms_noise^2 with the + * CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR / 100. + */ + const int var_noise = POW2((uint64_t)rms_noise) * + CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR * POW2(98) + / 100 / POW2(10000); var_threshold_scaled = (uint64_t) (CONFIG_BODY_DETECTION_VAR_THRESHOLD + var_noise) * |