summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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))