Add configurable BMA456 tap detection profile in bosch456.h.
Centralize multitap tuning so sensitivity and timing can be adjusted without changing driver init logic. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
|
||||
#include "driver/i2c_types.h"
|
||||
#include "esp_err.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/** 7-bit I2C address (SDO low). */
|
||||
#define BMA456_I2C_ADDR 0x18
|
||||
@@ -20,6 +22,40 @@
|
||||
/** Software filter: log accel only when |axis - last| > deadzone (raw LSB). */
|
||||
#define BMA456_DEFAULT_ACCEL_DEADZONE 100u
|
||||
|
||||
/**
|
||||
* BMA456H multitap tuning (see BST-BMA456-AN000).
|
||||
*
|
||||
* Time fields use register units: value × 5 ms (e.g. 100 → 500 ms).
|
||||
* tap_sens_thres: 0 = most sensitive … 15 = least (~78 mg per LSB).
|
||||
* axis_sel: 0 = X, 1 = Y, 2 = Z.
|
||||
* wait_for_timeout: 0 = report immediately, 1 = wait max_gest_dur for classification.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t tap_sens_thres;
|
||||
uint16_t max_gest_dur;
|
||||
uint16_t tap_shock_dur;
|
||||
uint16_t quite_time_after_gest;
|
||||
uint16_t wait_for_timeout;
|
||||
uint16_t axis_sel;
|
||||
bool enable_single;
|
||||
bool enable_double;
|
||||
bool enable_triple;
|
||||
} bma456_tap_config_t;
|
||||
|
||||
/** Edit these values to tune tap detection, then rebuild. */
|
||||
#define BMA456_TAP_CONFIG_DEFAULT \
|
||||
{ \
|
||||
.tap_sens_thres = 5, /* sensitive; 0=max, Bosch default=9 */ \
|
||||
.max_gest_dur = 100, /* 500 ms window for double/triple */ \
|
||||
.tap_shock_dur = 6, /* 30 ms debounce after each impulse */ \
|
||||
.quite_time_after_gest = 60, /* 300 ms min gap between gestures */ \
|
||||
.wait_for_timeout = 0, /* 0 = faster single-tap response */ \
|
||||
.axis_sel = 2, /* Z axis */ \
|
||||
.enable_single = true, \
|
||||
.enable_double = true, \
|
||||
.enable_triple = true, \
|
||||
}
|
||||
|
||||
/**
|
||||
* Probe and configure the sensor on bus_handle (100 kHz device).
|
||||
* On failure the device is removed and ESP_ERR_NOT_FOUND / ESP_FAIL is returned;
|
||||
|
||||
Reference in New Issue
Block a user