summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-09-28 09:39:09 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-29 00:09:41 -0700
commit18295c9bb2649b6e0b4a177d8e6c409ed9e9ba60 (patch)
treed367339065a9a3f72912ccc4ed410d957e0ce580
parentfec7aea0bf11912fae03dc6c9f9292395c141294 (diff)
downloadchrome-ec-18295c9bb2649b6e0b4a177d8e6c409ed9e9ba60.tar.gz
board: ryu: Match Samus double tap behavior.
Increase the change of false positive, but make double feels like Samus: - increase time beetwen tap to 500ms - decrease tap threshold to 100mg (actually 62.5mg) - increase ODR during TAP. BRANCH=smaug BUG=b:24440423 TEST=check Ryu and Samus side by side, their tap behavior is more similar. run cts -c android.hardware.cts.SingleSensorTests Change-Id: I260ad95136cb2be71ef4d71efc4bee0b28afa8e0 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/302627 Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r--board/ryu/board.c8
-rw-r--r--board/ryu/board.h4
-rw-r--r--driver/accelgyro_bmi160.c2
-rw-r--r--driver/accelgyro_bmi160.h5
4 files changed, 14 insertions, 5 deletions
diff --git a/board/ryu/board.c b/board/ryu/board.c
index 487bc75c22..73a24a05cf 100644
--- a/board/ryu/board.c
+++ b/board/ryu/board.c
@@ -18,6 +18,7 @@
#include "driver/accelgyro_bmi160.h"
#include "driver/als_si114x.h"
#include "ec_version.h"
+#include "gesture.h"
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
@@ -274,7 +275,6 @@ const matrix_3x3_t mag_standard_ref = {
{ 0, 0, FLOAT_TO_FP(1)}
};
-
struct motion_sensor_t motion_sensors[] = {
/*
@@ -301,16 +301,16 @@ struct motion_sensor_t motion_sensors[] = {
},
/* Used for double tap */
[SENSOR_CONFIG_EC_S0] = {
- .odr = 100000,
+ .odr = TAP_ODR,
/* Interrupt driven, no polling */
.ec_rate = 0,
},
[SENSOR_CONFIG_EC_S3] = {
- .odr = 100000,
+ .odr = TAP_ODR,
.ec_rate = 0,
},
[SENSOR_CONFIG_EC_S5] = {
- .odr = 100000,
+ .odr = TAP_ODR,
.ec_rate = 0,
},
},
diff --git a/board/ryu/board.h b/board/ryu/board.h
index 071f99bda3..45683d9d82 100644
--- a/board/ryu/board.h
+++ b/board/ryu/board.h
@@ -155,13 +155,15 @@
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_GESTURE_DETECTION
#define CONFIG_GESTURE_HOST_DETECTION
+#define CONFIG_GESTURE_SAMPLING_INTERVAL_MS 5
/* First sensor is motion_sensor is used for significant motion */
#define CONFIG_GESTURE_SIGMO 0
#define CONFIG_GESTURE_SIGMO_PROOF_MS 500
#define CONFIG_GESTURE_SIGMO_SKIP_MS 3000
#define CONFIG_GESTURE_SIGMO_THRES_MG 500
#define CONFIG_GESTURE_SENSOR_BATTERY_TAP 0
-#define CONFIG_GESTURE_TAP_THRES_MG 200
+#define CONFIG_GESTURE_TAP_THRES_MG 100
+#define CONFIG_GESTURE_TAP_MAX_INTERSTICE_T 500
#define CONFIG_GESTURE_DETECTION_MASK \
((1 << CONFIG_GESTURE_SIGMO) | \
(1 << CONFIG_GESTURE_SENSOR_BATTERY_TAP))
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index 650620af9f..d32ac3c582 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -748,6 +748,8 @@ static int config_interrupt(const struct motion_sensor_t *s)
raw_write8(s->addr, BMI160_CMD_REG, BMI160_CMD_INT_RESET);
#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP
+ raw_write8(s->addr, BMI160_INT_TAP_0,
+ BMI160_TAP_TH(s, CONFIG_GESTURE_TAP_MAX_INTERSTICE_T));
ret = raw_write8(s->addr, BMI160_INT_TAP_1,
BMI160_TAP_TH(s, CONFIG_GESTURE_TAP_THRES_MG));
#endif
diff --git a/driver/accelgyro_bmi160.h b/driver/accelgyro_bmi160.h
index 7d875d6675..6c57a3c4d3 100644
--- a/driver/accelgyro_bmi160.h
+++ b/driver/accelgyro_bmi160.h
@@ -321,6 +321,11 @@ enum fifo_header {
(MIN(__fls((_ms) / 250), BMI160_MOTION_PROOF_MASK))
#define BMI160_INT_TAP_0 0x63
+#define BMI160_TAP_DUR(_s, _ms) \
+ ((_ms) <= 250 ? MAX((_ms), 50) / 50 - 1 : \
+ (_ms) <= 500 ? 4 + ((_ms) - 250) / 125 : \
+ (_ms) < 700 ? 6 : 7)
+
#define BMI160_INT_TAP_1 0x64
#define BMI160_TAP_TH(_s, _mg) \
(MIN(((_mg) * 1000) / ((_s)->drv->get_range(_s) * 31250), 0x1f))