]> git.earman.xyz Git - sensor-watch.git/commitdiff
fix long press bug (seems related to disabling an interrupt)
authorJoey Castillo <joeycastillo@utexas.edu>
Sat, 17 May 2025 15:55:03 +0000 (11:55 -0400)
committerJoey Castillo <joeycastillo@utexas.edu>
Sat, 17 May 2025 15:55:03 +0000 (11:55 -0400)
movement.c

index d3281c433f7dfd9c15a0676435c684040945efd1..1a6f38eb80280bf227099bad465a8f291309f8e4 100644 (file)
@@ -534,8 +534,6 @@ bool movement_enable_tap_detection_if_available(void) {
 
         // enable tap detection on INT1/A3.
         lis2dw_configure_int1(LIS2DW_CTRL4_INT1_SINGLE_TAP | LIS2DW_CTRL4_INT1_6D);
-        // and enable the cb_accelerometer_event interrupt callback, so we can catch tap events.
-        watch_register_interrupt_callback(HAL_GPIO_A3_pin(), cb_accelerometer_event, INTERRUPT_TRIGGER_RISING);
 
         return true;
     }
@@ -549,8 +547,6 @@ bool movement_disable_tap_detection_if_available(void) {
         lis2dw_set_low_noise_mode(false);
         lis2dw_set_data_rate(LIS2DW_DATA_RATE_LOWEST);
         lis2dw_set_mode(LIS2DW_MODE_LOW_POWER);
-        // disable the interrupt on INT1/A3...
-        eic_disable_interrupt(HAL_GPIO_A3_pin());
         // ...disable Z axis (not sure if this is needed, does this save power?)...
         lis2dw_configure_tap_threshold(0, 0, 0, 0);
 
@@ -736,6 +732,10 @@ void app_setup(void) {
             // Still if you want to wake on motion, you can do it by uncommenting this line:
             // watch_register_extwake_callback(HAL_GPIO_A4_pin(), cb_accelerometer_wake, false);
 
+            // later on, we are going to use INT1 for tap detection. We'll set up that interrupt here,
+            // but it will only fire once tap recognition is enabled.
+            watch_register_interrupt_callback(HAL_GPIO_A3_pin(), cb_accelerometer_event, INTERRUPT_TRIGGER_RISING);
+
             lis2dw_enable_interrupts();
         } else {
             watch_disable_i2c();