]> git.earman.xyz Git - sensor-watch.git/commitdiff
Reapply "Added double-tap capabilities to LIS2DW"
authorDavid Volovskiy <devolov@gmail.com>
Tue, 2 Dec 2025 01:14:54 +0000 (20:14 -0500)
committerDavid Volovskiy <devolov@gmail.com>
Tue, 2 Dec 2025 01:14:54 +0000 (20:14 -0500)
This reverts commit 3bd1254b5fbb53ce84bddd1fb806da3237a8f245.

movement.c
watch-library/shared/driver/lis2dw.c
watch-library/shared/driver/lis2dw.h

index eb478ec945041fd854d42d3f1e031b797b6046fe..a37e8df2d58fd556766fb9ce8261e28b0c1f4c44 100644 (file)
@@ -514,7 +514,7 @@ bool movement_enable_tap_detection_if_available(void) {
     if (movement_state.has_lis2dw) {
         // configure tap duration threshold and enable Z axis
         lis2dw_configure_tap_threshold(0, 0, 12, LIS2DW_REG_TAP_THS_Z_Z_AXIS_ENABLE);
-        lis2dw_configure_tap_duration(10, 2, 2);
+        lis2dw_configure_tap_duration(2, 2, 2);
 
         // ramp data rate up to 400 Hz and high performance mode
         lis2dw_set_low_noise_mode(true);
@@ -526,7 +526,7 @@ bool movement_enable_tap_detection_if_available(void) {
         delay_ms(3);
 
         // enable tap detection on INT1/A3.
-        lis2dw_configure_int1(LIS2DW_CTRL4_INT1_SINGLE_TAP | LIS2DW_CTRL4_INT1_6D);
+        lis2dw_configure_int1(LIS2DW_CTRL4_INT1_SINGLE_TAP | LIS2DW_CTRL4_INT1_DOUBLE_TAP);
 
         return true;
     }
@@ -540,6 +540,7 @@ bool movement_disable_tap_detection_if_available(void) {
         lis2dw_set_low_noise_mode(false);
         lis2dw_set_data_rate(movement_state.accelerometer_background_rate);
         lis2dw_set_mode(LIS2DW_MODE_LOW_POWER);
+        lis2dw_disable_double_tap();
         // ...disable Z axis (not sure if this is needed, does this save power?)...
         lis2dw_configure_tap_threshold(0, 0, 0, 0);
 
index b716f790384ea027ea2dc36e6ae8458d0fb52578..1c89f244f75b356b164c9a3c25fbb0055f5e0ffd 100644 (file)
@@ -302,6 +302,20 @@ void lis2dw_clear_fifo(void) {
 #endif
 }
 
+void lis2dw_enable_double_tap(void) {
+#ifdef I2C_SERCOM
+    uint8_t configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_THS);
+    watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_THS, configuration | LIS2DW_WAKE_UP_THS_ENABLE_DOUBLE_TAP);
+#endif
+}
+
+void lis2dw_disable_double_tap(void) {
+#ifdef I2C_SERCOM
+    uint8_t configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_THS);
+    watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_THS, configuration & ~LIS2DW_WAKE_UP_THS_ENABLE_DOUBLE_TAP);
+#endif
+}
+
 void lis2dw_enable_sleep(void) {
 #ifdef I2C_SERCOM
     uint8_t configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_THS);
index 57ff05b2ab75ed4ea9392d504b77052a26c06e97..3b017c6543e108a96ca795b9e53efd90b2454e8b 100644 (file)
@@ -343,6 +343,10 @@ bool lis2dw_read_fifo(lis2dw_fifo_t *fifo_data);
 
 void lis2dw_clear_fifo(void);
 
+void lis2dw_enable_double_tap(void);
+
+void lis2dw_disable_double_tap(void);
+
 void lis2dw_enable_sleep(void);
 
 void lis2dw_disable_sleep(void);