]> git.earman.xyz Git - sensor-watch.git/commitdiff
movement:Allow disabling double tap detection in movement_enable_tap_detection_if_ava...
authorPaul Riou <paul@mirliton.io>
Sun, 26 Apr 2026 12:12:42 +0000 (13:12 +0100)
committerPaul Riou <paul@mirliton.io>
Sun, 26 Apr 2026 14:08:57 +0000 (15:08 +0100)
We will want to disable it in the countdown face.

movement.c
movement.h
watch-faces/complication/blackjack_face.c
watch-faces/complication/countdown_face.c
watch-faces/complication/endless_runner_face.c
watch-faces/complication/ping_face.c
watch-faces/complication/probability_face.c

index 8caf5e1601fa31fe78b921e997e7e76733c42d1c..7a096bdef432c4a46fdb17f80b5f8df4c2c02e9c 100644 (file)
@@ -845,7 +845,7 @@ void movement_set_alarm_enabled(bool value) {
     movement_state.alarm_enabled = value;
 }
 
-bool movement_enable_tap_detection_if_available(void) {
+bool movement_enable_tap_detection_if_available(bool enable_double_tap) {
     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);
@@ -855,13 +855,20 @@ bool movement_enable_tap_detection_if_available(void) {
         lis2dw_set_low_noise_mode(true);
         lis2dw_set_data_rate(LIS2DW_DATA_RATE_HP_400_HZ);
         lis2dw_set_mode(LIS2DW_MODE_LOW_POWER);
-        lis2dw_enable_double_tap();
+
+        if (enable_double_tap) {
+            lis2dw_enable_double_tap();
+        }
 
         // Settling time (1 sample duration, i.e. 1/400Hz)
         delay_ms(3);
 
         // enable tap detection on INT1/A3.
-        lis2dw_configure_int1(LIS2DW_CTRL4_INT1_SINGLE_TAP | LIS2DW_CTRL4_INT1_DOUBLE_TAP);
+        uint8_t int1_sources = LIS2DW_CTRL4_INT1_SINGLE_TAP;
+        if (enable_double_tap) {
+            int1_sources |= LIS2DW_CTRL4_INT1_DOUBLE_TAP;
+        }
+        lis2dw_configure_int1(int1_sources);
 
         return true;
     }
index 7b81e9ec55c6c5357602a9f9bb7cc574733b5f6a..1305c9397e14fe63e21c66eaf46866678bef3ba0 100644 (file)
@@ -395,7 +395,7 @@ bool movement_alarm_enabled(void);
 void movement_set_alarm_enabled(bool value);
 
 // if the board has an accelerometer, these functions will enable or disable tap detection.
-bool movement_enable_tap_detection_if_available(void);
+bool movement_enable_tap_detection_if_available(bool enable_double_tap);
 bool movement_disable_tap_detection_if_available(void);
 
 // gets and sets the accelerometer data rate in the background
index c5dda6b6bcb75156e026d4f0cb27b7dea8857416..10df36a621b3b0d3528139f17cc560e39c769bcc 100755 (executable)
@@ -354,7 +354,7 @@ static void handle_button_presses(bool tap_control_on, bool hit) {
     {\r
     case BJ_TITLE_SCREEN:\r
         if (!tap_turned_on && tap_control_on) {\r
-            if (movement_enable_tap_detection_if_available()) tap_turned_on = true;\r
+            if (movement_enable_tap_detection_if_available(true)) tap_turned_on = true;\r
         }\r
         begin_playing(tap_control_on);\r
         break;\r
@@ -384,7 +384,7 @@ static void toggle_tap_control(blackjack_face_state_t *state) {
         state->tap_control_on = false;\r
         watch_clear_indicator(WATCH_INDICATOR_SIGNAL);\r
     } else {\r
-        bool tap_could_enable = movement_enable_tap_detection_if_available();\r
+        bool tap_could_enable = movement_enable_tap_detection_if_available(true);\r
         if (tap_could_enable) {\r
             state->tap_control_on = true;\r
             watch_set_indicator(WATCH_INDICATOR_SIGNAL);\r
index 9785ab3c3b079fa37b14e9417c721a8f68895d90..f69478e9b19e93827450363145a829b9cac40d1f 100644 (file)
@@ -218,7 +218,7 @@ void countdown_face_activate(void *context) {
 
     movement_request_tick_frequency(1);
     quick_ticks_running = false;
-    if (state->mode != cd_running && movement_enable_tap_detection_if_available()) {
+    if (state->mode != cd_running && movement_enable_tap_detection_if_available(true)) {
         state->tap_detection_ticks = TAP_DETECTION_SECONDS;
         state->has_tapped_once = false;
     }
index 8a4b7a3b176b3db611e55c5173ef9acc84e8adfa..adcdd74b2918514c915455dc5074bb1088ebfdab 100644 (file)
@@ -327,7 +327,7 @@ static void toggle_sound(endless_runner_state_t *state) {
 
 static void enable_tap_control(endless_runner_state_t *state) {
     if (!state->tap_control_on) {
-        movement_enable_tap_detection_if_available();
+        movement_enable_tap_detection_if_available(true);
         state->tap_control_on = true;
     }
 }
index a0591ba37a3ed62082219132d5ce9b89e011b1ed..1f901f82e016f3b940a3bd518afbfb9cfaa855a1 100644 (file)
@@ -367,7 +367,7 @@ static void toggle_sound(ping_state_t *state) {
 
 static void enable_tap_control(ping_state_t *state) {
     if (!state->tap_control_on) {
-        movement_enable_tap_detection_if_available();
+        movement_enable_tap_detection_if_available(true);
         state->tap_control_on = true;
     }
 }
index b9a991dccf77bfa866fc6fa6781f265be9598c31..05417e0f558d2e591ec426a97cd2da41005f694f 100644 (file)
@@ -237,7 +237,7 @@ void probability_face_activate(void *context)
     movement_request_tick_frequency(1);
 
     // Enable tap detection for a few seconds when face is activated
-    if (movement_enable_tap_detection_if_available()) {
+    if (movement_enable_tap_detection_if_available(true)) {
         state->tap_detection_ticks = TAP_DETECTION_SECONDS;
     }
 }