]> git.earman.xyz Git - sensor-watch.git/commitdiff
fix signal tunes not firing in background, and split out foreground/background chime...
authorJeremy O'Brien <neutral@fastmail.com>
Fri, 22 Sep 2023 11:29:04 +0000 (07:29 -0400)
committerJeremy O'Brien <neutral@fastmail.com>
Fri, 22 Sep 2023 11:29:04 +0000 (07:29 -0400)
movement/movement.c
movement/movement.h
movement/watch_faces/clock/repetition_minute_face.c
movement/watch_faces/clock/simple_clock_bin_led_face.c
movement/watch_faces/clock/simple_clock_face.c
movement/watch_faces/clock/weeknumber_clock_face.c

index 0c6ed31978c6076122be9215a12cda29129797f7..f2292e5f4cf5f0a5b61eb8df53e0726ad20e510e 100644 (file)
@@ -294,9 +294,27 @@ void movement_request_wake() {
 }
 
 void movement_play_signal(void) {
+    watch_buzzer_play_note(BUZZER_NOTE_C8, 75);
+    watch_buzzer_play_note(BUZZER_NOTE_REST, 100);
+    watch_buzzer_play_note(BUZZER_NOTE_C8, 100);
+}
+
+void movement_play_signal_background(void) {
+    watch_enable_buzzer();
+    movement_play_signal();
+    watch_disable_buzzer();
+}
+
+void movement_play_tune(void) {
     watch_buzzer_play_sequence(signal_tune, NULL);
 }
 
+/* Special version of movement_play_tune meant for use during LE mode */
+void movement_play_tune_background(void) {
+    watch_enable_buzzer();
+    watch_buzzer_play_sequence(signal_tune, watch_disable_buzzer);
+}
+
 void movement_play_alarm(void) {
     movement_play_alarm_beeps(5, BUZZER_NOTE_C8);
 }
index 66bf6af46ce3bdee1e83277c47c80588471025f9..c6380cec74ecdaf41c304263cae9bdf3cb1787c3 100644 (file)
@@ -307,6 +307,9 @@ void movement_cancel_background_task_for_face(uint8_t watch_face_index);
 void movement_request_wake(void);
 
 void movement_play_signal(void);
+void movement_play_signal_background(void);
+void movement_play_tune(void);
+void movement_play_tune_background(void);
 void movement_play_alarm(void);
 void movement_play_alarm_beeps(uint8_t rounds, BuzzerNote alarm_note);
 
index a0fbe077058c079e2306292d437865ae92bc41c9..917c57150f31f922974b04087042ebf2983fa250 100644 (file)
@@ -151,18 +151,10 @@ bool repetition_minute_face_loop(movement_event_t event, movement_settings_t *se
             else watch_clear_indicator(WATCH_INDICATOR_BELL);
             break;
         case EVENT_BACKGROUND_TASK:
-            // uncomment this line to snap back to the clock face when the hour signal sounds:
-            // movement_move_to_face(state->watch_face_index);
             if (watch_is_buzzer_or_led_enabled()) {
-                // if we are in the foreground, we can just beep.
                 movement_play_signal();
             } else {
-                // if we were in the background, we need to enable the buzzer peripheral first,
-                watch_enable_buzzer();
-                // beep quickly (this call blocks for 275 ms),
-                movement_play_signal();
-                // and then turn the buzzer peripheral off again.
-                watch_disable_buzzer();
+                movement_play_signal_background();
             }
             break;
         case EVENT_LIGHT_LONG_UP:
index 640f0d77f7ea95cb71732a15753ce61cf6327723..09c8457b9e40cb0457456fa55b6327decc5d832f 100644 (file)
@@ -181,15 +181,9 @@ bool simple_clock_bin_led_face_loop(movement_event_t event, movement_settings_t
             // uncomment this line to snap back to the clock face when the hour signal sounds:
             // movement_move_to_face(state->watch_face_index);
             if (watch_is_buzzer_or_led_enabled()) {
-                // if we are in the foreground, we can just beep.
                 movement_play_signal();
             } else {
-                // if we were in the background, we need to enable the buzzer peripheral first,
-                watch_enable_buzzer();
-                // beep quickly (this call blocks for 275 ms),
-                movement_play_signal();
-                // and then turn the buzzer peripheral off again.
-                watch_disable_buzzer();
+                movement_play_signal_background();
             }
             break;
         case EVENT_LIGHT_LONG_PRESS:
index 91400b6c316b51ae081cb0424d5cb68363c0072c..ebe7542f0d3772ffc1eb3836d9706151b576e651 100644 (file)
@@ -137,15 +137,9 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting
             // uncomment this line to snap back to the clock face when the hour signal sounds:
             // movement_move_to_face(state->watch_face_index);
             if (watch_is_buzzer_or_led_enabled()) {
-                // if we are in the foreground, we can just beep.
-                movement_play_signal();
+                movement_play_tune();
             } else {
-                // if we were in the background, we need to enable the buzzer peripheral first,
-                watch_enable_buzzer();
-                // beep quickly (this call blocks for 275 ms),
-                movement_play_signal();
-                // and then turn the buzzer peripheral off again.
-                watch_disable_buzzer();
+                movement_play_tune_background();
             }
             break;
         default:
index 4e40ebdcaa21a6b3cc56667b6637a215890730e8..b4514bf143bdfc060aa33f68d797c6b4b53d5aa9 100644 (file)
@@ -131,15 +131,9 @@ bool weeknumber_clock_face_loop(movement_event_t event, movement_settings_t *set
             // uncomment this line to snap back to the clock face when the hour signal sounds:
             // movement_move_to_face(state->watch_face_index);
             if (watch_is_buzzer_or_led_enabled()) {
-                // if we are in the foreground, we can just beep.
                 movement_play_signal();
             } else {
-                // if we were in the background, we need to enable the buzzer peripheral first,
-                watch_enable_buzzer();
-                // beep quickly (this call blocks for 275 ms),
-                movement_play_signal();
-                // and then turn the buzzer peripheral off again.
-                watch_disable_buzzer();
+                movement_play_signal_background();
             }
             break;
         default: