diff --git a/movement.c b/movement.c index 8caf5e16..7a096bde 100644 --- a/movement.c +++ b/movement.c @@ -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; } diff --git a/movement.h b/movement.h index 7b81e9ec..1305c939 100644 --- a/movement.h +++ b/movement.h @@ -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 diff --git a/watch-faces/complication/blackjack_face.c b/watch-faces/complication/blackjack_face.c index c5dda6b6..10df36a6 100755 --- a/watch-faces/complication/blackjack_face.c +++ b/watch-faces/complication/blackjack_face.c @@ -354,7 +354,7 @@ static void handle_button_presses(bool tap_control_on, bool hit) { { case BJ_TITLE_SCREEN: if (!tap_turned_on && tap_control_on) { - if (movement_enable_tap_detection_if_available()) tap_turned_on = true; + if (movement_enable_tap_detection_if_available(true)) tap_turned_on = true; } begin_playing(tap_control_on); break; @@ -384,7 +384,7 @@ static void toggle_tap_control(blackjack_face_state_t *state) { state->tap_control_on = false; watch_clear_indicator(WATCH_INDICATOR_SIGNAL); } else { - bool tap_could_enable = movement_enable_tap_detection_if_available(); + bool tap_could_enable = movement_enable_tap_detection_if_available(true); if (tap_could_enable) { state->tap_control_on = true; watch_set_indicator(WATCH_INDICATOR_SIGNAL); diff --git a/watch-faces/complication/countdown_face.c b/watch-faces/complication/countdown_face.c index 9785ab3c..f69478e9 100644 --- a/watch-faces/complication/countdown_face.c +++ b/watch-faces/complication/countdown_face.c @@ -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; } diff --git a/watch-faces/complication/endless_runner_face.c b/watch-faces/complication/endless_runner_face.c index 8a4b7a3b..adcdd74b 100644 --- a/watch-faces/complication/endless_runner_face.c +++ b/watch-faces/complication/endless_runner_face.c @@ -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; } } diff --git a/watch-faces/complication/ping_face.c b/watch-faces/complication/ping_face.c index a0591ba3..1f901f82 100644 --- a/watch-faces/complication/ping_face.c +++ b/watch-faces/complication/ping_face.c @@ -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; } } diff --git a/watch-faces/complication/probability_face.c b/watch-faces/complication/probability_face.c index b9a991dc..05417e0f 100644 --- a/watch-faces/complication/probability_face.c +++ b/watch-faces/complication/probability_face.c @@ -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; } }